@framers/agentos 0.12.3 → 0.12.5
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/agent.d.ts +7 -5
- package/dist/api/agent.d.ts.map +1 -1
- package/dist/api/agent.js.map +1 -1
- package/dist/api/generateObject.d.ts +5 -5
- package/dist/api/generateText.d.ts +173 -50
- package/dist/api/generateText.d.ts.map +1 -1
- package/dist/api/generateText.js +272 -81
- package/dist/api/generateText.js.map +1 -1
- package/dist/api/index.d.ts +6 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +5 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/runtime/GMIChunkTransformer.d.ts +1 -1
- package/dist/api/runtime/GMIChunkTransformer.d.ts.map +1 -1
- package/dist/api/runtime/GMIChunkTransformer.js +7 -2
- package/dist/api/runtime/GMIChunkTransformer.js.map +1 -1
- package/dist/api/runtime/completionGateway.d.ts +98 -0
- package/dist/api/runtime/completionGateway.d.ts.map +1 -0
- package/dist/api/runtime/completionGateway.js +347 -0
- package/dist/api/runtime/completionGateway.js.map +1 -0
- package/dist/api/runtime/contextWindowFit.d.ts +49 -0
- package/dist/api/runtime/contextWindowFit.d.ts.map +1 -0
- package/dist/api/runtime/contextWindowFit.js +109 -0
- package/dist/api/runtime/contextWindowFit.js.map +1 -0
- package/dist/api/runtime/gatewayProviderManager.d.ts +37 -0
- package/dist/api/runtime/gatewayProviderManager.d.ts.map +1 -0
- package/dist/api/runtime/gatewayProviderManager.js +49 -0
- package/dist/api/runtime/gatewayProviderManager.js.map +1 -0
- package/dist/api/streamText.d.ts.map +1 -1
- package/dist/api/streamText.js +90 -6
- package/dist/api/streamText.js.map +1 -1
- package/dist/cognition/emergent/ComposableToolBuilder.d.ts.map +1 -1
- package/dist/cognition/emergent/ComposableToolBuilder.js +16 -8
- package/dist/cognition/emergent/ComposableToolBuilder.js.map +1 -1
- package/dist/cognition/emergent/EffectsStore.d.ts +58 -0
- package/dist/cognition/emergent/EffectsStore.d.ts.map +1 -0
- package/dist/cognition/emergent/EffectsStore.js +96 -0
- package/dist/cognition/emergent/EffectsStore.js.map +1 -0
- package/dist/cognition/emergent/EmergentCapabilityEngine.d.ts +22 -2
- package/dist/cognition/emergent/EmergentCapabilityEngine.d.ts.map +1 -1
- package/dist/cognition/emergent/EmergentCapabilityEngine.js +128 -19
- package/dist/cognition/emergent/EmergentCapabilityEngine.js.map +1 -1
- package/dist/cognition/emergent/EmergentJudge.d.ts +1 -1
- package/dist/cognition/emergent/EmergentJudge.d.ts.map +1 -1
- package/dist/cognition/emergent/EmergentToolRegistry.d.ts +12 -3
- package/dist/cognition/emergent/EmergentToolRegistry.d.ts.map +1 -1
- package/dist/cognition/emergent/EmergentToolRegistry.js +51 -4
- package/dist/cognition/emergent/EmergentToolRegistry.js.map +1 -1
- package/dist/cognition/emergent/ForgeToolMetaTool.d.ts.map +1 -1
- package/dist/cognition/emergent/ForgeToolMetaTool.js +4 -1
- package/dist/cognition/emergent/ForgeToolMetaTool.js.map +1 -1
- package/dist/cognition/emergent/SandboxedToolForge.d.ts +55 -51
- package/dist/cognition/emergent/SandboxedToolForge.d.ts.map +1 -1
- package/dist/cognition/emergent/SandboxedToolForge.js +103 -109
- package/dist/cognition/emergent/SandboxedToolForge.js.map +1 -1
- package/dist/cognition/emergent/ToolPackage.d.ts +2 -2
- package/dist/cognition/emergent/ToolPackage.d.ts.map +1 -1
- package/dist/cognition/emergent/broker/CapabilityBroker.d.ts +58 -0
- package/dist/cognition/emergent/broker/CapabilityBroker.d.ts.map +1 -0
- package/dist/cognition/emergent/broker/CapabilityBroker.js +288 -0
- package/dist/cognition/emergent/broker/CapabilityBroker.js.map +1 -0
- package/dist/cognition/emergent/broker/fetch.d.ts +44 -0
- package/dist/cognition/emergent/broker/fetch.d.ts.map +1 -0
- package/dist/cognition/emergent/broker/fetch.js +197 -0
- package/dist/cognition/emergent/broker/fetch.js.map +1 -0
- package/dist/cognition/emergent/broker/fs-read.d.ts +63 -0
- package/dist/cognition/emergent/broker/fs-read.d.ts.map +1 -0
- package/dist/cognition/emergent/broker/fs-read.js +133 -0
- package/dist/cognition/emergent/broker/fs-read.js.map +1 -0
- package/dist/cognition/emergent/broker/refusal.d.ts +10 -0
- package/dist/cognition/emergent/broker/refusal.d.ts.map +1 -0
- package/dist/cognition/emergent/broker/refusal.js +13 -0
- package/dist/cognition/emergent/broker/refusal.js.map +1 -0
- package/dist/cognition/emergent/ceiling.d.ts +75 -0
- package/dist/cognition/emergent/ceiling.d.ts.map +1 -0
- package/dist/cognition/emergent/ceiling.js +166 -0
- package/dist/cognition/emergent/ceiling.js.map +1 -0
- package/dist/cognition/emergent/index.d.ts +2 -0
- package/dist/cognition/emergent/index.d.ts.map +1 -1
- package/dist/cognition/emergent/index.js +1 -0
- package/dist/cognition/emergent/index.js.map +1 -1
- package/dist/cognition/emergent/types.d.ts +75 -2
- package/dist/cognition/emergent/types.d.ts.map +1 -1
- package/dist/cognition/emergent/types.js.map +1 -1
- package/dist/cognition/substrate/GMI.d.ts +21 -0
- package/dist/cognition/substrate/GMI.d.ts.map +1 -1
- package/dist/cognition/substrate/GMI.js +286 -88
- package/dist/cognition/substrate/GMI.js.map +1 -1
- package/dist/cognition/substrate/IGMI.d.ts +48 -1
- package/dist/cognition/substrate/IGMI.d.ts.map +1 -1
- package/dist/cognition/substrate/IGMI.js +4 -0
- package/dist/cognition/substrate/IGMI.js.map +1 -1
- package/dist/core/llm/providers/errors/ContextWindowExceededError.d.ts +22 -0
- package/dist/core/llm/providers/errors/ContextWindowExceededError.d.ts.map +1 -0
- package/dist/core/llm/providers/errors/ContextWindowExceededError.js +21 -0
- package/dist/core/llm/providers/errors/ContextWindowExceededError.js.map +1 -0
- package/dist/core/llm/providers/implementations/OpenRouterProvider.d.ts.map +1 -1
- package/dist/core/llm/providers/implementations/OpenRouterProvider.js +34 -13
- package/dist/core/llm/providers/implementations/OpenRouterProvider.js.map +1 -1
- package/dist/core/llm/routing/IModelRouter.d.ts +6 -0
- package/dist/core/llm/routing/IModelRouter.d.ts.map +1 -1
- package/dist/core/llm/routing/PolicyAwareRouter.d.ts +7 -0
- package/dist/core/llm/routing/PolicyAwareRouter.d.ts.map +1 -1
- package/dist/core/llm/routing/PolicyAwareRouter.js +12 -0
- package/dist/core/llm/routing/PolicyAwareRouter.js.map +1 -1
- package/dist/core/llm/routing/UncensoredModelCatalog.d.ts +37 -0
- package/dist/core/llm/routing/UncensoredModelCatalog.d.ts.map +1 -1
- package/dist/core/llm/routing/UncensoredModelCatalog.js +64 -74
- package/dist/core/llm/routing/UncensoredModelCatalog.js.map +1 -1
- package/dist/core/tools/ITool.d.ts +45 -0
- package/dist/core/tools/ITool.d.ts.map +1 -1
- package/dist/core/tools/ToolOrchestrator.d.ts.map +1 -1
- package/dist/core/tools/ToolOrchestrator.js +4 -8
- package/dist/core/tools/ToolOrchestrator.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The broker's `fs.readFile` for code-forged tools under a
|
|
3
|
+
* ceiling, and the path rules it shares with the forge's legacy read:
|
|
4
|
+
* lexical containment first, then the real path against the roots' real
|
|
5
|
+
* paths, each root's real path pinned on first success. The read is a
|
|
6
|
+
* stream refused past its limit, so no file is held whole before the limit
|
|
7
|
+
* applies.
|
|
8
|
+
* @module @framers/agentos/emergent/broker/fs-read
|
|
9
|
+
*/
|
|
10
|
+
import { CapabilityRefusal } from './refusal.js';
|
|
11
|
+
/**
|
|
12
|
+
* Whether a path lies under one of the roots. Decided by `path.relative`, not
|
|
13
|
+
* a string prefix: a root that ends in a separator (`/`, `C:\`) would
|
|
14
|
+
* otherwise be compared against a doubled separator, and `path.relative`
|
|
15
|
+
* applies the platform's case rules. `''` is the root itself; a result that
|
|
16
|
+
* climbs out (`..`, `../x`) or stays absolute (another Windows drive) is
|
|
17
|
+
* outside. Checking the `..` segment, not the prefix, keeps a sibling named
|
|
18
|
+
* `..foo` from reading as an escape.
|
|
19
|
+
*/
|
|
20
|
+
export declare function withinRoots(candidate: string, roots: readonly string[]): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Read roots, each root's real path resolved lazily and pinned per root.
|
|
23
|
+
*
|
|
24
|
+
* Both sides of a containment check are real paths: a root is often itself a
|
|
25
|
+
* link (on macOS `/tmp` is a link to `/private/tmp`). A resolved root stays
|
|
26
|
+
* pinned for the life of this object, so a root link repointed under a
|
|
27
|
+
* running sandbox is not followed. A failed resolution is not pinned, so a
|
|
28
|
+
* root that becomes readable later is picked up, and one unreadable root
|
|
29
|
+
* never un-pins a sibling; its lexical form never matches a real path, so it
|
|
30
|
+
* cannot widen the reads while it stays unreadable.
|
|
31
|
+
*/
|
|
32
|
+
export declare class ReadRoots {
|
|
33
|
+
readonly roots: readonly string[];
|
|
34
|
+
private readonly cache;
|
|
35
|
+
constructor(roots: readonly string[]);
|
|
36
|
+
real(): Promise<string[]>;
|
|
37
|
+
private realOf;
|
|
38
|
+
}
|
|
39
|
+
/** A read refused past its limit, with how far it got. */
|
|
40
|
+
export declare class ReadTooLarge extends CapabilityRefusal {
|
|
41
|
+
readonly bytesRead: number;
|
|
42
|
+
constructor(bytesRead: number, limit: number);
|
|
43
|
+
}
|
|
44
|
+
/** The check made before the filesystem is touched: a path string, lexically under a root. Returns the resolved path. */
|
|
45
|
+
export declare function prepareRead(filePath: unknown, roots: ReadRoots): string;
|
|
46
|
+
/**
|
|
47
|
+
* The real-path check and the read. The file read is the resolved real path,
|
|
48
|
+
* not the caller's string: resolving the caller's string again would walk a
|
|
49
|
+
* link a second time, and the link can be repointed between the two walks.
|
|
50
|
+
*/
|
|
51
|
+
export declare function readPrepared(resolved: string, roots: ReadRoots, scope: {
|
|
52
|
+
maxBytesPerRead: number;
|
|
53
|
+
timeoutMs: number;
|
|
54
|
+
}, signal: AbortSignal): Promise<{
|
|
55
|
+
text: string;
|
|
56
|
+
bytes: number;
|
|
57
|
+
}>;
|
|
58
|
+
/** The broker's read without its records: the checks, then the read. */
|
|
59
|
+
export declare function brokeredRead(filePath: unknown, roots: ReadRoots, scope: {
|
|
60
|
+
maxBytesPerRead: number;
|
|
61
|
+
timeoutMs: number;
|
|
62
|
+
}, signal: AbortSignal): Promise<string>;
|
|
63
|
+
//# sourceMappingURL=fs-read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-read.d.ts","sourceRoot":"","sources":["../../../../src/cognition/emergent/broker/fs-read.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAQhF;AAED;;;;;;;;;;GAUG;AACH,qBAAa,SAAS;IAGR,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE;IAF7C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsC;gBAEvC,KAAK,EAAE,SAAS,MAAM,EAAE;IAE7C,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIzB,OAAO,CAAC,MAAM;CAYf;AAED,0DAA0D;AAC1D,qBAAa,YAAa,SAAQ,iBAAiB;IAE/C,QAAQ,CAAC,SAAS,EAAE,MAAM;gBAAjB,SAAS,EAAE,MAAM,EAC1B,KAAK,EAAE,MAAM;CAIhB;AAED,yHAAyH;AACzH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,GAAG,MAAM,CASvE;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EACrD,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CA8C1C;AAED,wEAAwE;AACxE,wBAAsB,YAAY,CAChC,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EACrD,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,MAAM,CAAC,CAEjB"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The broker's `fs.readFile` for code-forged tools under a
|
|
3
|
+
* ceiling, and the path rules it shares with the forge's legacy read:
|
|
4
|
+
* lexical containment first, then the real path against the roots' real
|
|
5
|
+
* paths, each root's real path pinned on first success. The read is a
|
|
6
|
+
* stream refused past its limit, so no file is held whole before the limit
|
|
7
|
+
* applies.
|
|
8
|
+
* @module @framers/agentos/emergent/broker/fs-read
|
|
9
|
+
*/
|
|
10
|
+
import { createReadStream } from 'node:fs';
|
|
11
|
+
import { realpath } from 'node:fs/promises';
|
|
12
|
+
import * as path from 'node:path';
|
|
13
|
+
import { CapabilityRefusal } from './refusal.js';
|
|
14
|
+
/**
|
|
15
|
+
* Whether a path lies under one of the roots. Decided by `path.relative`, not
|
|
16
|
+
* a string prefix: a root that ends in a separator (`/`, `C:\`) would
|
|
17
|
+
* otherwise be compared against a doubled separator, and `path.relative`
|
|
18
|
+
* applies the platform's case rules. `''` is the root itself; a result that
|
|
19
|
+
* climbs out (`..`, `../x`) or stays absolute (another Windows drive) is
|
|
20
|
+
* outside. Checking the `..` segment, not the prefix, keeps a sibling named
|
|
21
|
+
* `..foo` from reading as an escape.
|
|
22
|
+
*/
|
|
23
|
+
export function withinRoots(candidate, roots) {
|
|
24
|
+
return roots.some((root) => {
|
|
25
|
+
const relative = path.relative(root, candidate);
|
|
26
|
+
return (relative === '' ||
|
|
27
|
+
(relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative)));
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Read roots, each root's real path resolved lazily and pinned per root.
|
|
32
|
+
*
|
|
33
|
+
* Both sides of a containment check are real paths: a root is often itself a
|
|
34
|
+
* link (on macOS `/tmp` is a link to `/private/tmp`). A resolved root stays
|
|
35
|
+
* pinned for the life of this object, so a root link repointed under a
|
|
36
|
+
* running sandbox is not followed. A failed resolution is not pinned, so a
|
|
37
|
+
* root that becomes readable later is picked up, and one unreadable root
|
|
38
|
+
* never un-pins a sibling; its lexical form never matches a real path, so it
|
|
39
|
+
* cannot widen the reads while it stays unreadable.
|
|
40
|
+
*/
|
|
41
|
+
export class ReadRoots {
|
|
42
|
+
constructor(roots) {
|
|
43
|
+
this.roots = roots;
|
|
44
|
+
this.cache = new Map();
|
|
45
|
+
}
|
|
46
|
+
real() {
|
|
47
|
+
return Promise.all(this.roots.map((root) => this.realOf(root)));
|
|
48
|
+
}
|
|
49
|
+
realOf(root) {
|
|
50
|
+
const cached = this.cache.get(root);
|
|
51
|
+
if (cached !== undefined) {
|
|
52
|
+
return cached;
|
|
53
|
+
}
|
|
54
|
+
const pending = realpath(root).catch(() => {
|
|
55
|
+
this.cache.delete(root);
|
|
56
|
+
return root;
|
|
57
|
+
});
|
|
58
|
+
this.cache.set(root, pending);
|
|
59
|
+
return pending;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** A read refused past its limit, with how far it got. */
|
|
63
|
+
export class ReadTooLarge extends CapabilityRefusal {
|
|
64
|
+
constructor(bytesRead, limit) {
|
|
65
|
+
super('file_too_large', `more than ${limit} bytes`);
|
|
66
|
+
this.bytesRead = bytesRead;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** The check made before the filesystem is touched: a path string, lexically under a root. Returns the resolved path. */
|
|
70
|
+
export function prepareRead(filePath, roots) {
|
|
71
|
+
if (typeof filePath !== 'string') {
|
|
72
|
+
throw new CapabilityRefusal('invalid_path', 'fs.readFile takes a path string');
|
|
73
|
+
}
|
|
74
|
+
const resolved = path.resolve(filePath);
|
|
75
|
+
if (!withinRoots(resolved, roots.roots)) {
|
|
76
|
+
throw new CapabilityRefusal('path_not_allowed', resolved);
|
|
77
|
+
}
|
|
78
|
+
return resolved;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The real-path check and the read. The file read is the resolved real path,
|
|
82
|
+
* not the caller's string: resolving the caller's string again would walk a
|
|
83
|
+
* link a second time, and the link can be repointed between the two walks.
|
|
84
|
+
*/
|
|
85
|
+
export async function readPrepared(resolved, roots, scope, signal) {
|
|
86
|
+
const real = await realpath(resolved);
|
|
87
|
+
if (!withinRoots(real, await roots.real())) {
|
|
88
|
+
throw new CapabilityRefusal('path_not_allowed', `${resolved} resolves outside the roots`);
|
|
89
|
+
}
|
|
90
|
+
const bounded = AbortSignal.any([signal, AbortSignal.timeout(scope.timeoutMs)]);
|
|
91
|
+
if (bounded.aborted) {
|
|
92
|
+
throw new CapabilityRefusal(signal.aborted ? 'aborted' : 'timed_out', resolved);
|
|
93
|
+
}
|
|
94
|
+
return new Promise((resolve, reject) => {
|
|
95
|
+
const chunks = [];
|
|
96
|
+
let total = 0;
|
|
97
|
+
let settled = false;
|
|
98
|
+
const stream = createReadStream(real);
|
|
99
|
+
function finish(error, result) {
|
|
100
|
+
if (settled) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
settled = true;
|
|
104
|
+
bounded.removeEventListener('abort', onAbort);
|
|
105
|
+
if (error) {
|
|
106
|
+
stream.destroy();
|
|
107
|
+
reject(error);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
resolve(result);
|
|
111
|
+
}
|
|
112
|
+
function onAbort() {
|
|
113
|
+
finish(new CapabilityRefusal(signal.aborted ? 'aborted' : 'timed_out', resolved));
|
|
114
|
+
}
|
|
115
|
+
bounded.addEventListener('abort', onAbort, { once: true });
|
|
116
|
+
stream.on('data', (chunk) => {
|
|
117
|
+
const buffer = typeof chunk === 'string' ? Buffer.from(chunk) : chunk;
|
|
118
|
+
total += buffer.byteLength;
|
|
119
|
+
if (total > scope.maxBytesPerRead) {
|
|
120
|
+
finish(new ReadTooLarge(total, scope.maxBytesPerRead));
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
chunks.push(buffer);
|
|
124
|
+
});
|
|
125
|
+
stream.on('error', (error) => finish(error));
|
|
126
|
+
stream.on('end', () => finish(null, { text: Buffer.concat(chunks).toString('utf-8'), bytes: total }));
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/** The broker's read without its records: the checks, then the read. */
|
|
130
|
+
export async function brokeredRead(filePath, roots, scope, signal) {
|
|
131
|
+
return (await readPrepared(prepareRead(filePath, roots), roots, scope, signal)).text;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=fs-read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-read.js","sourceRoot":"","sources":["../../../../src/cognition/emergent/broker/fs-read.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,SAAiB,EAAE,KAAwB;IACrE,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;QACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAChD,OAAO,CACL,QAAQ,KAAK,EAAE;YAC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,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACpD,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IACxG,CAAC,CAAC,CAAC;AACL,CAAC;AAED,wEAAwE;AACxE,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAiB,EACjB,KAAgB,EAChB,KAAqD,EACrD,MAAmB;IAEnB,OAAO,CAAC,MAAM,YAAY,CAAC,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview A capability call the broker refused or ended. The message
|
|
3
|
+
* starts with the code; forged code sees it, and an effect record keeps it.
|
|
4
|
+
* @module @framers/agentos/emergent/broker/refusal
|
|
5
|
+
*/
|
|
6
|
+
export declare class CapabilityRefusal extends Error {
|
|
7
|
+
readonly code: string;
|
|
8
|
+
constructor(code: string, detail: string);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=refusal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../../../../src/cognition/emergent/broker/refusal.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAExC,QAAQ,CAAC,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM;CAKjB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview A capability call the broker refused or ended. The message
|
|
3
|
+
* starts with the code; forged code sees it, and an effect record keeps it.
|
|
4
|
+
* @module @framers/agentos/emergent/broker/refusal
|
|
5
|
+
*/
|
|
6
|
+
export class CapabilityRefusal extends Error {
|
|
7
|
+
constructor(code, detail) {
|
|
8
|
+
super(`${code}: ${detail}`);
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.name = 'CapabilityRefusal';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=refusal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refusal.js","sourceRoot":"","sources":["../../../../src/cognition/emergent/broker/refusal.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,YACW,IAAY,EACrB,MAAc;QAEd,KAAK,CAAC,GAAG,IAAI,KAAK,MAAM,EAAE,CAAC,CAAC;QAHnB,SAAI,GAAJ,IAAI,CAAQ;QAIrB,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The host's ceiling for code-forged tools: validation into a
|
|
3
|
+
* resolved ceiling, the check of a forging agent's request against it, and
|
|
4
|
+
* the check of a host-built forge's options against it.
|
|
5
|
+
* @module @framers/agentos/emergent/ceiling
|
|
6
|
+
*/
|
|
7
|
+
import type { CapabilityName, EmergentAuditConfig, ForgedCapabilities } from './types.js';
|
|
8
|
+
/** A ceiling with every default applied and every list normalised. */
|
|
9
|
+
export interface ResolvedCeiling {
|
|
10
|
+
fetch?: {
|
|
11
|
+
domains: string[] | '*';
|
|
12
|
+
methods: Array<'GET' | 'HEAD'>;
|
|
13
|
+
maxResponseBytes: number;
|
|
14
|
+
maxRedirects: number;
|
|
15
|
+
timeoutMs: number;
|
|
16
|
+
};
|
|
17
|
+
'fs.read'?: {
|
|
18
|
+
roots: string[];
|
|
19
|
+
maxBytesPerRead: number;
|
|
20
|
+
timeoutMs: number;
|
|
21
|
+
};
|
|
22
|
+
crypto?: true;
|
|
23
|
+
audit: {
|
|
24
|
+
store: 'storage' | 'none';
|
|
25
|
+
content: 'digest' | 'full';
|
|
26
|
+
retainDays?: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export type CeilingErrorCode = 'unknown_capability' | 'root_not_absolute' | 'method_not_allowed' | 'invalid_domain' | 'invalid_bound' | 'audit_needs_storage' | 'forge_wider_than_ceiling';
|
|
30
|
+
/** A ceiling the engine cannot build; the message starts with the code and the key. */
|
|
31
|
+
export declare class CeilingError extends Error {
|
|
32
|
+
readonly code: CeilingErrorCode;
|
|
33
|
+
readonly key: string;
|
|
34
|
+
constructor(code: CeilingErrorCode, key: string, detail: string);
|
|
35
|
+
}
|
|
36
|
+
export declare const CEILING_DEFAULTS: {
|
|
37
|
+
readonly methods: Array<"GET" | "HEAD">;
|
|
38
|
+
readonly maxResponseBytes: number;
|
|
39
|
+
readonly maxRedirects: 5;
|
|
40
|
+
readonly maxBytesPerRead: number;
|
|
41
|
+
readonly timeoutMs: 30000;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Validates a host's ceiling and applies its defaults. An empty `domains` or
|
|
45
|
+
* `roots` list removes its capability (an empty list grants nothing).
|
|
46
|
+
*
|
|
47
|
+
* @throws CeilingError naming the code and the key of the first failure.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveCeiling(capabilities: ForgedCapabilities, audit: EmergentAuditConfig | undefined, options: {
|
|
50
|
+
hasStorage: boolean;
|
|
51
|
+
}): ResolvedCeiling;
|
|
52
|
+
/** The capabilities a resolved ceiling grants, in catalogue order. */
|
|
53
|
+
export declare function grantedCapabilities(ceiling: ResolvedCeiling): CapabilityName[];
|
|
54
|
+
/** Whether a request (catalogue names) fits the ceiling; a refusal names the rest and what is allowed. */
|
|
55
|
+
export declare function checkRequest(request: readonly CapabilityName[], ceiling: ResolvedCeiling): {
|
|
56
|
+
ok: true;
|
|
57
|
+
} | {
|
|
58
|
+
ok: false;
|
|
59
|
+
refused: CapabilityName[];
|
|
60
|
+
allowed: CapabilityName[];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* A host-built forge under a ceiling: its options may be narrower than the
|
|
64
|
+
* ceiling, and then they narrow it; they may never be wider. Only the
|
|
65
|
+
* capabilities the ceiling grants are compared, since the broker injects no
|
|
66
|
+
* other. An intersection is taken in the ceiling's terms and never widens:
|
|
67
|
+
* disjoint lists are wider, not empty.
|
|
68
|
+
*
|
|
69
|
+
* @throws CeilingError (`forge_wider_than_ceiling`) naming the forge option.
|
|
70
|
+
*/
|
|
71
|
+
export declare function narrowToForge(ceiling: ResolvedCeiling, forge: {
|
|
72
|
+
fetchDomainAllowlist: string[];
|
|
73
|
+
fsReadRoots: string[];
|
|
74
|
+
}): ResolvedCeiling;
|
|
75
|
+
//# sourceMappingURL=ceiling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ceiling.d.ts","sourceRoot":"","sources":["../../../src/cognition/emergent/ceiling.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE1F,sEAAsE;AACtE,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE;QACN,OAAO,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;QACxB,OAAO,EAAE,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;QAC/B,gBAAgB,EAAE,MAAM,CAAC;QACzB,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,SAAS,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QAAC,eAAe,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAA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oBAAoB,EAAE,MAAM,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAA;CAAE,GAC/D,eAAe,CAkCjB"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The host's ceiling for code-forged tools: validation into a
|
|
3
|
+
* resolved ceiling, the check of a forging agent's request against it, and
|
|
4
|
+
* the check of a host-built forge's options against it.
|
|
5
|
+
* @module @framers/agentos/emergent/ceiling
|
|
6
|
+
*/
|
|
7
|
+
import * as path from 'node:path';
|
|
8
|
+
import { CAPABILITY_NAMES } from './capabilities.js';
|
|
9
|
+
/** A ceiling the engine cannot build; the message starts with the code and the key. */
|
|
10
|
+
export class CeilingError extends Error {
|
|
11
|
+
constructor(code, key, detail) {
|
|
12
|
+
super(`${code}: ${key}: ${detail}`);
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.key = key;
|
|
15
|
+
this.name = 'CeilingError';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export const CEILING_DEFAULTS = {
|
|
19
|
+
methods: ['GET', 'HEAD'],
|
|
20
|
+
maxResponseBytes: 5 * 1024 * 1024,
|
|
21
|
+
maxRedirects: 5,
|
|
22
|
+
maxBytesPerRead: 1024 * 1024,
|
|
23
|
+
timeoutMs: 30000,
|
|
24
|
+
};
|
|
25
|
+
const HOSTNAME = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$|^\d{1,3}(\.\d{1,3}){3}$/;
|
|
26
|
+
function bound(value, fallback, key, min) {
|
|
27
|
+
if (value === undefined) {
|
|
28
|
+
return fallback;
|
|
29
|
+
}
|
|
30
|
+
if (!Number.isInteger(value) || value < min) {
|
|
31
|
+
throw new CeilingError('invalid_bound', key, `expected an integer of at least ${min}, got ${String(value)}`);
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Validates a host's ceiling and applies its defaults. An empty `domains` or
|
|
37
|
+
* `roots` list removes its capability (an empty list grants nothing).
|
|
38
|
+
*
|
|
39
|
+
* @throws CeilingError naming the code and the key of the first failure.
|
|
40
|
+
*/
|
|
41
|
+
export function resolveCeiling(capabilities, audit, options) {
|
|
42
|
+
for (const key of Object.keys(capabilities)) {
|
|
43
|
+
if (!CAPABILITY_NAMES.includes(key)) {
|
|
44
|
+
throw new CeilingError('unknown_capability', `capabilities.${key}`, `not in the catalogue (${CAPABILITY_NAMES.join(', ')})`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const resolved = {
|
|
48
|
+
audit: {
|
|
49
|
+
store: audit?.store ?? 'storage',
|
|
50
|
+
content: audit?.content ?? 'digest',
|
|
51
|
+
...(audit?.retainDays !== undefined
|
|
52
|
+
? { retainDays: bound(audit.retainDays, 0, 'audit.retainDays', 1) }
|
|
53
|
+
: {}),
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
const fetch = capabilities.fetch;
|
|
57
|
+
if (fetch) {
|
|
58
|
+
const methods = fetch.methods ?? [...CEILING_DEFAULTS.methods];
|
|
59
|
+
for (const method of methods) {
|
|
60
|
+
if (method !== 'GET' && method !== 'HEAD') {
|
|
61
|
+
throw new CeilingError('method_not_allowed', 'capabilities.fetch.methods', `${String(method)}: stage 1 allows GET and HEAD`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
let domains = '*';
|
|
65
|
+
if (fetch.domains !== '*') {
|
|
66
|
+
domains = fetch.domains.map((domain) => domain.toLowerCase());
|
|
67
|
+
for (const domain of domains) {
|
|
68
|
+
if (!HOSTNAME.test(domain)) {
|
|
69
|
+
throw new CeilingError('invalid_domain', 'capabilities.fetch.domains', `"${domain}" is not a host name (no scheme, port or path)`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (domains === '*' || domains.length > 0) {
|
|
74
|
+
resolved.fetch = {
|
|
75
|
+
domains,
|
|
76
|
+
methods,
|
|
77
|
+
maxResponseBytes: bound(fetch.maxResponseBytes, CEILING_DEFAULTS.maxResponseBytes, 'capabilities.fetch.maxResponseBytes', 1),
|
|
78
|
+
maxRedirects: bound(fetch.maxRedirects, CEILING_DEFAULTS.maxRedirects, 'capabilities.fetch.maxRedirects', 0),
|
|
79
|
+
timeoutMs: bound(fetch.timeoutMs, CEILING_DEFAULTS.timeoutMs, 'capabilities.fetch.timeoutMs', 1),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const read = capabilities['fs.read'];
|
|
84
|
+
if (read) {
|
|
85
|
+
for (const root of read.roots) {
|
|
86
|
+
if (!path.isAbsolute(root)) {
|
|
87
|
+
throw new CeilingError('root_not_absolute', 'capabilities.fs.read.roots', `"${root}" is not an absolute path`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (read.roots.length > 0) {
|
|
91
|
+
resolved['fs.read'] = {
|
|
92
|
+
roots: read.roots.map((root) => path.resolve(root)),
|
|
93
|
+
maxBytesPerRead: bound(read.maxBytesPerRead, CEILING_DEFAULTS.maxBytesPerRead, 'capabilities.fs.read.maxBytesPerRead', 1),
|
|
94
|
+
timeoutMs: bound(read.timeoutMs, CEILING_DEFAULTS.timeoutMs, 'capabilities.fs.read.timeoutMs', 1),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (capabilities.crypto) {
|
|
99
|
+
resolved.crypto = true;
|
|
100
|
+
}
|
|
101
|
+
if (resolved.audit.store === 'storage' && !options.hasStorage) {
|
|
102
|
+
throw new CeilingError('audit_needs_storage', 'audit.store', "a ceiling records every capability call; pass a storage adapter, or set audit.store: 'none' (then no effect records are kept)");
|
|
103
|
+
}
|
|
104
|
+
return resolved;
|
|
105
|
+
}
|
|
106
|
+
/** The capabilities a resolved ceiling grants, in catalogue order. */
|
|
107
|
+
export function grantedCapabilities(ceiling) {
|
|
108
|
+
return CAPABILITY_NAMES.filter((name) => ceiling[name] !== undefined);
|
|
109
|
+
}
|
|
110
|
+
/** Whether a request (catalogue names) fits the ceiling; a refusal names the rest and what is allowed. */
|
|
111
|
+
export function checkRequest(request, ceiling) {
|
|
112
|
+
const allowed = grantedCapabilities(ceiling);
|
|
113
|
+
const refused = request.filter((name) => !allowed.includes(name));
|
|
114
|
+
return refused.length === 0 ? { ok: true } : { ok: false, refused, allowed };
|
|
115
|
+
}
|
|
116
|
+
function within(candidate, root) {
|
|
117
|
+
const relative = path.relative(root, candidate);
|
|
118
|
+
return relative === '' || (relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative));
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* A host-built forge under a ceiling: its options may be narrower than the
|
|
122
|
+
* ceiling, and then they narrow it; they may never be wider. Only the
|
|
123
|
+
* capabilities the ceiling grants are compared, since the broker injects no
|
|
124
|
+
* other. An intersection is taken in the ceiling's terms and never widens:
|
|
125
|
+
* disjoint lists are wider, not empty.
|
|
126
|
+
*
|
|
127
|
+
* @throws CeilingError (`forge_wider_than_ceiling`) naming the forge option.
|
|
128
|
+
*/
|
|
129
|
+
export function narrowToForge(ceiling, forge) {
|
|
130
|
+
const narrowed = { ...ceiling };
|
|
131
|
+
if (ceiling.fetch) {
|
|
132
|
+
const forgeDomains = forge.fetchDomainAllowlist.map((domain) => domain.toLowerCase());
|
|
133
|
+
if (forgeDomains.length === 0) {
|
|
134
|
+
// The forge's empty list means every domain.
|
|
135
|
+
if (ceiling.fetch.domains !== '*') {
|
|
136
|
+
throw new CeilingError('forge_wider_than_ceiling', 'sandboxForge.fetchDomainAllowlist', 'the forge allows every domain');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
const ceilingDomains = ceiling.fetch.domains;
|
|
141
|
+
const wider = ceilingDomains === '*' ? [] : forgeDomains.filter((domain) => !ceilingDomains.includes(domain));
|
|
142
|
+
if (wider.length > 0) {
|
|
143
|
+
throw new CeilingError('forge_wider_than_ceiling', 'sandboxForge.fetchDomainAllowlist', `outside the ceiling: ${wider.join(', ')}`);
|
|
144
|
+
}
|
|
145
|
+
narrowed.fetch = { ...ceiling.fetch, domains: forgeDomains };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (ceiling['fs.read']) {
|
|
149
|
+
const ceilingRoots = ceiling['fs.read'].roots;
|
|
150
|
+
const forgeRoots = forge.fsReadRoots.map((root) => path.resolve(root));
|
|
151
|
+
const wider = forgeRoots.filter((root) => !ceilingRoots.some((ceilingRoot) => within(root, ceilingRoot)));
|
|
152
|
+
if (wider.length > 0) {
|
|
153
|
+
throw new CeilingError('forge_wider_than_ceiling', 'sandboxForge.fsReadRoots', `outside the ceiling: ${wider.join(', ')}`);
|
|
154
|
+
}
|
|
155
|
+
if (forgeRoots.length === 0) {
|
|
156
|
+
// A forge that reads nowhere: the intersection is empty, and an empty
|
|
157
|
+
// intersection removes the capability rather than granting an empty list.
|
|
158
|
+
delete narrowed['fs.read'];
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
narrowed['fs.read'] = { ...ceiling['fs.read'], roots: forgeRoots };
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return narrowed;
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=ceiling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ceiling.js","sourceRoot":"","sources":["../../../src/cognition/emergent/ceiling.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AA0BrD,uFAAuF;AACvF,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,YACW,IAAsB,EACtB,GAAW,EACpB,MAAc;QAEd,KAAK,CAAC,GAAG,IAAI,KAAK,GAAG,KAAK,MAAM,EAAE,CAAC,CAAC;QAJ3B,SAAI,GAAJ,IAAI,CAAkB;QACtB,QA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,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC;QAC9C,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACvE,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;QAC1G,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,YAAY,CAAC,0BAA0B,EAAE,0BAA0B,EAAE,wBAAwB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC7H,CAAC;QACD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,sEAAsE;YACtE,0EAA0E;YAC1E,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC7B,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;QACrE,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -18,6 +18,8 @@ export type { StepGate, StepGateOptions, Chainability, ChainRefusalCode } from '
|
|
|
18
18
|
export { SandboxedToolForge } from './SandboxedToolForge.js';
|
|
19
19
|
export type { SandboxedToolForgeConfig } from './SandboxedToolForge.js';
|
|
20
20
|
export { CAPABILITY_NAMES, CAPABILITY_ALIASES, normalizeAllowlist, toSandboxApis } from './capabilities.js';
|
|
21
|
+
export { CeilingError, checkRequest, grantedCapabilities, narrowToForge, resolveCeiling, CEILING_DEFAULTS } from './ceiling.js';
|
|
22
|
+
export type { CeilingErrorCode, ResolvedCeiling } from './ceiling.js';
|
|
21
23
|
export { parsePersistedSource, inferRequestFromCode, requestFromImplementation, parseStoredRequest, } from './persisted-source.js';
|
|
22
24
|
export type { PersistedSource } from './persisted-source.js';
|
|
23
25
|
export { EmergentToolRegistry } from './EmergentToolRegistry.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cognition/emergent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,KAAK,qBAAqB,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AACzG,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAClH,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,YAAY,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC5G,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,YAAY,EACV,eAAe,IAAI,8BAA8B,EACjD,UAAU,GACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,oCAAoC,EACpC,wBAAwB,EACxB,4BAA4B,EAC5B,wBAAwB,EACxB,kCAAkC,GACnC,MAAM,kBAAkB,CA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AC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC3G,YAAY,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAM7E,OAAO,EACL,sBAAsB,EACtB,KAAK,sBAAsB,GAC5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,kBAAkB,EAClB,KAAK,iBAAiB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,EACxB,KAAK,2BAA2B,GACjC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,oBAAoB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,KAAK,UAAU,GAChB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,YAAY,EACV,SAAS,EACT,aAAa,EACb,WAAW,GACZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,YAAY,EACV,wBAAwB,EACxB,YAAY,EACZ,iBAAiB,GAClB,MAAM,yBAAyB,CAAC"}
|
|
@@ -16,6 +16,7 @@ export { ComposableToolBuilder } from './ComposableToolBuilder.js';
|
|
|
16
16
|
export { createStepGate, checkChainable, COMPOSE_NEEDS_GATE_MESSAGE, MAX_COMPOSITION_DEPTH } from './StepGate.js';
|
|
17
17
|
export { SandboxedToolForge } from './SandboxedToolForge.js';
|
|
18
18
|
export { CAPABILITY_NAMES, CAPABILITY_ALIASES, normalizeAllowlist, toSandboxApis } from './capabilities.js';
|
|
19
|
+
export { CeilingError, checkRequest, grantedCapabilities, narrowToForge, resolveCeiling, CEILING_DEFAULTS } from './ceiling.js';
|
|
19
20
|
export { parsePersistedSource, inferRequestFromCode, requestFromImplementation, parseStoredRequest, } from './persisted-source.js';
|
|
20
21
|
export { EmergentToolRegistry } from './EmergentToolRegistry.js';
|
|
21
22
|
export { EMERGENT_TOOL_PACKAGE_SCHEMA_VERSION, buildEmergentToolPackage, serializeEmergentToolPackage, parseEmergentToolPackage, materializeEmergentToolFromPackage, } from './ToolPackage.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cognition/emergent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,YAAY,CAAC;AAC3B,OAAO,EAA8B,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AACzG,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAElH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC5G,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAKjE,OAAO,EACL,oCAAoC,EACpC,wBAAwB,EACxB,4BAA4B,EAC5B,wBAAwB,EACxB,kCAAkC,GACnC,MAAM,kBAAkB,CAAC;AAQ1B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AASzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,qBAAqB,GACtB,MAA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