@rivet-dev/agentos-browser 0.0.0-agentos-dylib-plugin.f065be7 → 0.0.0-integrate-dylib-into-main.815fcda
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/README.md +1 -1
- package/dist/driver.d.ts +5 -1
- package/dist/driver.js +41 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/driver.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export interface BrowserRuntimeSystemOptions {
|
|
|
4
4
|
filesystem: "opfs" | "memory";
|
|
5
5
|
networkEnabled: boolean;
|
|
6
6
|
}
|
|
7
|
+
export declare function releaseOpfsNamespace(namespace: string): Promise<void>;
|
|
8
|
+
export declare function listOpfsNamespaces(): Promise<string[]>;
|
|
7
9
|
/**
|
|
8
10
|
* VFS backed by the Origin Private File System (OPFS) API. Falls back to
|
|
9
11
|
* InMemoryFileSystem when OPFS is unavailable. Rename is not supported
|
|
@@ -88,7 +90,9 @@ export interface BrowserDriverOptions {
|
|
|
88
90
|
/**
|
|
89
91
|
* Per-runtime/tenant OPFS namespace. Defaults to a freshly generated id so
|
|
90
92
|
* co-resident runtimes never share storage (F-015). Pass a stable id to
|
|
91
|
-
* persist a runtime's data across driver instances.
|
|
93
|
+
* persist a runtime's data across driver instances. Generated default
|
|
94
|
+
* namespaces are not garbage-collected automatically; long-lived embedders
|
|
95
|
+
* should either pass a stable namespace or call `releaseOpfsNamespace`.
|
|
92
96
|
*/
|
|
93
97
|
opfsNamespace?: string;
|
|
94
98
|
}
|
package/dist/driver.js
CHANGED
|
@@ -39,7 +39,7 @@ function dirname(path) {
|
|
|
39
39
|
* co-resident runtimes read each other's data (F-015). Each runtime instead
|
|
40
40
|
* gets its own subdirectory under this prefix.
|
|
41
41
|
*/
|
|
42
|
-
const OPFS_RUNTIME_NAMESPACE_ROOT = ".
|
|
42
|
+
const OPFS_RUNTIME_NAMESPACE_ROOT = ".agentos-runtimes";
|
|
43
43
|
/**
|
|
44
44
|
* Translate an OPFS "not found" error into a Node-style ENOENT error so missing
|
|
45
45
|
* paths report consistently with the in-memory filesystem (and so callers see
|
|
@@ -81,6 +81,45 @@ async function getRootHandle(namespace) {
|
|
|
81
81
|
const namespaceContainer = await originRoot.getDirectoryHandle(OPFS_RUNTIME_NAMESPACE_ROOT, { create: true });
|
|
82
82
|
return namespaceContainer.getDirectoryHandle(namespace, { create: true });
|
|
83
83
|
}
|
|
84
|
+
async function getNamespaceContainerHandle(create = false) {
|
|
85
|
+
const originRoot = await getOriginRootHandle();
|
|
86
|
+
return originRoot.getDirectoryHandle(OPFS_RUNTIME_NAMESPACE_ROOT, {
|
|
87
|
+
create,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function isNotFoundError(error) {
|
|
91
|
+
return error?.name === "NotFoundError";
|
|
92
|
+
}
|
|
93
|
+
export async function releaseOpfsNamespace(namespace) {
|
|
94
|
+
try {
|
|
95
|
+
const namespaceContainer = await getNamespaceContainerHandle(false);
|
|
96
|
+
await namespaceContainer.removeEntry(namespace, { recursive: true });
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
if (isNotFoundError(error)) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export async function listOpfsNamespaces() {
|
|
106
|
+
try {
|
|
107
|
+
const namespaceContainer = await getNamespaceContainerHandle(false);
|
|
108
|
+
const namespaces = [];
|
|
109
|
+
for await (const [name, handle] of namespaceContainer.entries()) {
|
|
110
|
+
if (handle.kind === "directory") {
|
|
111
|
+
namespaces.push(name);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return namespaces.sort();
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
if (isNotFoundError(error)) {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
84
123
|
/**
|
|
85
124
|
* VFS backed by the Origin Private File System (OPFS) API. Falls back to
|
|
86
125
|
* InMemoryFileSystem when OPFS is unavailable. Rename is not supported
|
|
@@ -329,8 +368,7 @@ export function createBrowserNetworkAdapter() {
|
|
|
329
368
|
// Use the reference captured at module load (platformFetch) so the gated
|
|
330
369
|
// adapter keeps working after worker.ts shadows the guest-visible `fetch`
|
|
331
370
|
// global (F-012). Fall back to the current global only if none was captured.
|
|
332
|
-
const fetchImpl = platformFetch ??
|
|
333
|
-
((...args) => fetch(...args));
|
|
371
|
+
const fetchImpl = platformFetch ?? ((...args) => fetch(...args));
|
|
334
372
|
return {
|
|
335
373
|
async fetch(url, options) {
|
|
336
374
|
const response = await fetchImpl(url, {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { BrowserDriverOptions, BrowserRuntimeSystemOptions, } from "./driver.js";
|
|
2
|
-
export { createBrowserDriver, createBrowserNetworkAdapter, createOpfsFileSystem, } from "./driver.js";
|
|
2
|
+
export { createBrowserDriver, createBrowserNetworkAdapter, createOpfsFileSystem, listOpfsNamespaces, releaseOpfsNamespace, } from "./driver.js";
|
|
3
3
|
export { InMemoryFileSystem } from "./os-filesystem.js";
|
|
4
4
|
export type { ExecOptions, ExecResult, NodeRuntimeDriver, StdioChannel, StdioEvent, TimingMitigation, } from "./runtime.js";
|
|
5
5
|
export { allowAll, allowAllChildProcess, allowAllEnv, allowAllFs, allowAllNetwork, createInMemoryFileSystem, } from "./runtime.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createBrowserDriver, createBrowserNetworkAdapter, createOpfsFileSystem, } from "./driver.js";
|
|
1
|
+
export { createBrowserDriver, createBrowserNetworkAdapter, createOpfsFileSystem, listOpfsNamespaces, releaseOpfsNamespace, } from "./driver.js";
|
|
2
2
|
export { InMemoryFileSystem } from "./os-filesystem.js";
|
|
3
3
|
export { allowAll, allowAllChildProcess, allowAllEnv, allowAllFs, allowAllNetwork, createInMemoryFileSystem, } from "./runtime.js";
|
|
4
4
|
export { createBrowserRuntimeDriverFactory } from "./runtime-driver.js";
|