36 lines
2.2 KiB
JavaScript
36 lines
2.2 KiB
JavaScript
/* node:coverage disable */
|
|
(function (root, factory) {
|
|
'use strict';
|
|
const foundation = typeof module === 'object' && module.exports ? require('../foundation.js') : root.HermesHuxFoundation;
|
|
const shell = typeof module === 'object' && module.exports ? require('../shell.js') : root.HermesHuxShell;
|
|
const waveA = typeof module === 'object' && module.exports ? require('./wave_a_contract.js') : root.HermesHuxWaveAContract;
|
|
const projects = typeof module === 'object' && module.exports ? require('./wave_b_projects_modes.js') : root.HermesHuxWaveBProjectsModes;
|
|
const workspace = typeof module === 'object' && module.exports ? require('./wave_b_artifacts_research.js') : root.HermesHuxWaveBArtifactsResearch;
|
|
const api = factory(foundation, shell, waveA, projects, workspace);
|
|
if (typeof module === 'object' && module.exports) module.exports = api;
|
|
else root.HermesHuxWaveBRuntime = api;
|
|
}(typeof globalThis === 'object' ? globalThis : this, function (foundation, shell, waveA, projects, workspace) {
|
|
/* node:coverage enable */
|
|
'use strict';
|
|
|
|
function createWaveBRuntime(options) {
|
|
const settings = options || {};
|
|
const client = waveA.createCanonicalClient(settings);
|
|
const host = shell.createShell({client, document: settings.document});
|
|
const extensionOptions = {document: settings.document, projectId: settings.projectId,
|
|
conversationId: settings.conversationId, branchPointMessageId: settings.branchPointMessageId,
|
|
messageId: settings.messageId, notebookId: settings.notebookId};
|
|
[projects.createProjectsExtension(extensionOptions), workspace.createArtifactsExtension(extensionOptions),
|
|
projects.createModesExtension(extensionOptions), workspace.createResearchExtension(extensionOptions)]
|
|
.forEach((extension) => host.register(extension));
|
|
let mounted = false;
|
|
async function mount(target) {
|
|
if (mounted) throw new Error('HUX Wave B runtime is already mounted');
|
|
mounted = true; const node = host.mount(target); await client.negotiate(); return node;
|
|
}
|
|
return Object.freeze({apiVersion: foundation.API_VERSION, client, destroy: host.destroy, mount});
|
|
}
|
|
|
|
return Object.freeze({createWaveBRuntime});
|
|
}));
|