@openai/agents-core
Version:
The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows.
45 lines • 1.47 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.InMemoryRemoteSnapshotStore = exports.NoopSnapshotSpec = void 0;
exports.isNoopSnapshotSpec = isNoopSnapshotSpec;
const _shims_1 = require("@openai/agents-core/_shims");
class NoopSnapshotSpec {
type = 'noop';
}
exports.NoopSnapshotSpec = NoopSnapshotSpec;
function isNoopSnapshotSpec(spec) {
return spec?.type === 'noop';
}
class InMemoryRemoteSnapshotStore {
snapshots = new Map();
async save(args) {
const id = args.id ?? (0, _shims_1.randomUUID)();
const metadata = args.metadata ? { ...args.metadata } : undefined;
this.snapshots.set(id, {
data: new Uint8Array(args.data),
...(metadata ? { metadata } : {}),
});
return {
id,
...(metadata ? { metadata } : {}),
};
}
async load(args) {
const snapshot = this.snapshots.get(args.id);
if (!snapshot) {
throw new Error(`Remote snapshot not found: ${args.id}`);
}
return {
data: new Uint8Array(snapshot.data),
...(snapshot.metadata ? { metadata: { ...snapshot.metadata } } : {}),
};
}
async delete(args) {
this.snapshots.delete(args.id);
}
async exists(args) {
return this.snapshots.has(args.id);
}
}
exports.InMemoryRemoteSnapshotStore = InMemoryRemoteSnapshotStore;
//# sourceMappingURL=snapshot.js.map