Skip to content

Commit

Permalink
refactor(daemon,cli): A handle for every agent
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Mar 26, 2024
1 parent 00b3d7f commit 9526387
Show file tree
Hide file tree
Showing 11 changed files with 292 additions and 155 deletions.
12 changes: 10 additions & 2 deletions packages/cli/src/commands/mkguest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ import os from 'os';
import { E } from '@endo/far';
import { withEndoAgent } from '../context.js';

export const mkguest = async ({ name, agentNames, introducedNames }) =>
export const mkguest = async ({
handleName,
agentName,
agentNames,
introducedNames,
}) =>
withEndoAgent(agentNames, { os, process }, async ({ agent }) => {
const newGuest = await E(agent).provideGuest(name, { introducedNames });
const newGuest = await E(agent).provideGuest(handleName, {
introducedNames,
agentName,
});
console.log(newGuest);
});
12 changes: 10 additions & 2 deletions packages/cli/src/commands/mkhost.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ import os from 'os';
import { E } from '@endo/far';
import { withEndoAgent } from '../context.js';

export const mkhost = async ({ name, agentNames, introducedNames }) =>
export const mkhost = async ({
handleName,
agentName,
agentNames,
introducedNames,
}) =>
withEndoAgent(agentNames, { os, process }, async ({ agent }) => {
const newHost = await E(agent).provideHost(name, { introducedNames });
const newHost = await E(agent).provideHost(handleName, {
introducedNames,
agentName,
});
console.log(newHost);
});
12 changes: 6 additions & 6 deletions packages/cli/src/endo.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export const main = async rawArgs => {
});

program
.command('mkhost <name>')
.command('mkhost <handle-name> [agent-name]')
.option(...commonOptions.as)
.option(
'--introduce <name>',
Expand All @@ -424,14 +424,14 @@ export const main = async rawArgs => {
{},
)
.description('makes a separate mailbox and storage for you')
.action(async (name, cmd) => {
.action(async (handleName, agentName, cmd) => {
const { as: agentNames, introduce: introducedNames } = cmd.opts();
const { mkhost } = await import('./commands/mkhost.js');
return mkhost({ name, agentNames, introducedNames });
return mkhost({ handleName, agentName, agentNames, introducedNames });
});

program
.command('mkguest <name>')
.command('mkguest <handle-name> [agent-name]')
.option(...commonOptions.as)
.option(
'--introduce <name>',
Expand All @@ -440,10 +440,10 @@ export const main = async rawArgs => {
{},
)
.description('makes a mailbox and storage for a guest (peer or program)')
.action(async (name, cmd) => {
.action(async (handleName, agentName, cmd) => {
const { as: agentNames, introduce: introducedNames } = cmd.opts();
const { mkguest } = await import('./commands/mkguest.js');
return mkguest({ name, agentNames, introducedNames });
return mkguest({ agentName, handleName, agentNames, introducedNames });
});

program
Expand Down
Loading

0 comments on commit 9526387

Please sign in to comment.