UNPKG

@inworld/web-core

Version:
20 lines (19 loc) 1.03 kB
import { StateSerialization } from '../../../proto/ai/inworld/engine/v1/state_serialization.pb.js'; import { SCENE_PATTERN } from '../../common/constants.js'; import { PbService } from './pb.service.js'; export class StateSerializationService extends PbService { async getSessionState(props) { var _a, _b, _c; const { config, session, scene } = props; const workspace = SCENE_PATTERN.exec(scene)[1]; const name = `workspaces/${workspace}/sessions/${session.sessionId}`; const res = await this.request(config, session, StateSerialization.GetSessionState, { name, }); return Object.assign({ state: (_a = res.state) === null || _a === void 0 ? void 0 : _a.toString(), creationTime: (_b = res.creationTime) === null || _b === void 0 ? void 0 : _b.toString() }, (((_c = res.version) === null || _c === void 0 ? void 0 : _c.interactionId) && { version: { interactionId: res.version.interactionId, }, })); } }