@ai-sdk/harness 1.0.75 → 1.0.77
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/CHANGELOG.md +20 -0
- package/README.md +6 -6
- package/dist/agent/index.d.ts +93 -105
- package/dist/agent/index.js +126 -166
- package/dist/agent/index.js.map +1 -1
- package/dist/index.d.ts +0 -11
- package/package.json +4 -4
- package/src/agent/harness-agent-session.ts +18 -44
- package/src/agent/harness-agent-settings.ts +4 -5
- package/src/agent/harness-agent.ts +127 -149
- package/src/agent/prepare-harness-sandbox-template.ts +15 -7
- package/src/v1/harness-v1-sandbox-provider.ts +0 -12
- package/src/agent/internal/bridge-port-registry.ts +0 -52
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Process-wide registry for bridge-port leases. Used when a sandbox provider
|
|
3
|
-
* wraps a caller-provided sandbox with a pre-declared port pool — each
|
|
4
|
-
* concurrent harness session leases one port from the pool, releases on
|
|
5
|
-
* session stop or destroy. Multiple sessions on the same provider instance
|
|
6
|
-
* share the same pool; different provider instances (even wrapping the same
|
|
7
|
-
* underlying sandbox) get independent registries.
|
|
8
|
-
*
|
|
9
|
-
* Sized to the typical case: one provider object passed to N HarnessAgents.
|
|
10
|
-
* Callers that need cross-process coordination must layer that on top.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
type RegistryEntry = {
|
|
14
|
-
readonly pool: ReadonlyArray<number>;
|
|
15
|
-
readonly leases: Map<string, number>;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const registries = new WeakMap<object, RegistryEntry>();
|
|
19
|
-
|
|
20
|
-
export function acquireBridgePort(options: {
|
|
21
|
-
poolKey: object;
|
|
22
|
-
pool: ReadonlyArray<number>;
|
|
23
|
-
sessionId: string;
|
|
24
|
-
}): number {
|
|
25
|
-
let entry = registries.get(options.poolKey);
|
|
26
|
-
if (entry == null) {
|
|
27
|
-
entry = { pool: options.pool, leases: new Map() };
|
|
28
|
-
registries.set(options.poolKey, entry);
|
|
29
|
-
}
|
|
30
|
-
const existing = entry.leases.get(options.sessionId);
|
|
31
|
-
if (existing != null) return existing;
|
|
32
|
-
|
|
33
|
-
const leased = new Set(entry.leases.values());
|
|
34
|
-
for (const port of entry.pool) {
|
|
35
|
-
if (!leased.has(port)) {
|
|
36
|
-
entry.leases.set(options.sessionId, port);
|
|
37
|
-
return port;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
throw new Error(
|
|
41
|
-
`No available bridge port — pool of ${entry.pool.length} ports is fully leased.`,
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function releaseBridgePort(options: {
|
|
46
|
-
poolKey: object;
|
|
47
|
-
sessionId: string;
|
|
48
|
-
}): void {
|
|
49
|
-
const entry = registries.get(options.poolKey);
|
|
50
|
-
if (entry == null) return;
|
|
51
|
-
entry.leases.delete(options.sessionId);
|
|
52
|
-
}
|