From 903c5718187ab9fb5f201d00e9f58a10fbc1f573 Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Sat, 23 Mar 2024 07:55:36 -0700 Subject: [PATCH] refactor(daemon): Handles have agents, rename --- packages/daemon/src/daemon.js | 14 +++++++------- packages/daemon/src/types.d.ts | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/daemon/src/daemon.js b/packages/daemon/src/daemon.js index 1b793cd9f8..bfb660e226 100644 --- a/packages/daemon/src/daemon.js +++ b/packages/daemon/src/daemon.js @@ -558,11 +558,11 @@ const makeDaemonCore = async ( context, ); } else if (formula.type === 'handle') { - context.thisDiesIfThatDies(formula.target); + context.thisDiesIfThatDies(formula.agent); return { external: {}, internal: { - targetId: formula.target, + agentId: formula.agent, }, }; } else if (formula.type === 'endo') { @@ -885,13 +885,13 @@ const makeDaemonCore = async ( return controller; } // @ts-expect-error We can't know the type of the internal facet. - if (internalFacet.targetId === undefined) { + if (internalFacet.agentId === undefined) { return controller; } const handle = /** @type {import('./types.js').InternalHandle} */ ( internalFacet ); - currentId = handle.targetId; + currentId = handle.agentId; } }; @@ -931,14 +931,14 @@ const makeDaemonCore = async ( * The returned promise is resolved after the formula is persisted. * * @param {string} formulaNumber - The formula number of the handle to formulate. - * @param {string} targetId - The formula identifier of the handle's target. + * @param {string} agentId - The formula identifier of the handle's agent. * @returns {import('./types.js').FormulateResult} The formulated handle. */ - const formulateNumberedHandle = (formulaNumber, targetId) => { + const formulateNumberedHandle = (formulaNumber, agentId) => { /** @type {import('./types.js').HandleFormula} */ const formula = { type: 'handle', - target: targetId, + agent: agentId, }; return /** @type {import('./types').FormulateResult} */ ( formulate(formulaNumber, formula) diff --git a/packages/daemon/src/types.d.ts b/packages/daemon/src/types.d.ts index 7b5e17ffaf..56df30c203 100644 --- a/packages/daemon/src/types.d.ts +++ b/packages/daemon/src/types.d.ts @@ -178,7 +178,7 @@ type WebBundleFormula = { type HandleFormula = { type: 'handle'; - target: string; + agent: string; }; type KnownPeersStoreFormula = { @@ -353,7 +353,7 @@ export interface Controller * provide an EndoGuest with a reference to its creator EndoHost. By using a handle * that points to the host instead of giving a direct reference to the host, the * guest does not get access to the functions of the host. This is the external - * facet of a handle. It directly exposes nothing. The handle's target is only + * facet of a handle. It directly exposes nothing. The handle's agent is only * exposed on the internal facet. */ export interface ExternalHandle {} @@ -362,7 +362,7 @@ export interface ExternalHandle {} * handle points to. This should not be exposed outside of the endo daemon. */ export interface InternalHandle { - targetId: string; + agentId: string; } export type MakeSha512 = () => Sha512;