Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 50 additions & 31 deletions architecture.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/acp/embedded-adapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* earn that, so it lives here and goes away with the thing it exists for.
*
* The CLI's three Agent profiles β€” the workflow attachment, `xmd run` and the
* `xmd plan` authorship ceiling β€” are the callers.
* `xmd plan` Plan writer ceiling β€” are the callers.
*/

export {
Expand Down
22 changes: 11 additions & 11 deletions packages/cli/src/agent-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* whole of it and installs the registered provider into the Agent Api so a
* document may reach it. `xmd plan` writes a program and runs none, so it
* settles only who writes β€” the provider name, the default agent and the
* adapters this build carries β€” and hands that to the authorship profile.
* adapters this build carries β€” and hands that to the Plan writer profile.
* Resolving it once, here, is what keeps `DEFAULT_AGENT_NAME` from being read
* twice and answered differently.
*
Expand Down Expand Up @@ -54,11 +54,11 @@ export const DEFAULT_ADAPTER_ROOT: string = join(homedir(), ".xmd", "adapters");
* Who writes, and what this host launches them with.
*
* The whole of what Plan authorship settles. There is no permission mode here
* because the authorship frame installs its own fixed one, and no command line
* because the Plan writer frame installs its own fixed one, and no command line
* selects it: the flags that choose a permission mode configure a document
* execution, and `xmd plan` starts none.
*/
export interface AuthorshipStack {
export interface PlanWriterStack {
/** The provider name the caller selected, already known to be registered. */
provider: string;
/** The agent every consumer defaults to, environment fallback applied. */
Expand All @@ -70,7 +70,7 @@ export interface AuthorshipStack {
}

/** Everything one `xmd run` invocation settled about agents, resolved once. */
export interface AgentStack extends AuthorshipStack {
export interface AgentStack extends PlanWriterStack {
permissionMode: PermissionMode;
}

Expand All @@ -82,10 +82,10 @@ export interface AgentStack extends AuthorshipStack {
* so the same resolution serves a command that runs a document and one that
* only writes one.
*/
export function* resolveAuthorshipStack(
export function* resolvePlanWriterStack(
flags: AuthorshipFlags,
sessions: MachineSessionAssembly | undefined,
): Operation<Result<AuthorshipStack>> {
): Operation<Result<PlanWriterStack>> {
if (flags.agentProvider !== "acpx") {
return Err(new Error(`Unknown agent provider "${flags.agentProvider}"`));
}
Expand All @@ -111,14 +111,14 @@ export function* resolveAgentStack(
if ("error" in config) {
return Err(new Error(config.error));
}
const authorship = yield* resolveAuthorshipStack(
const planWriter = yield* resolvePlanWriterStack(
{ agentProvider: flags.agentProvider, defaultAgent: config.defaultAgent },
sessions,
);
if (!authorship.ok) {
return authorship;
if (!planWriter.ok) {
return planWriter;
}
return Ok({ ...authorship.value, permissionMode: config.permissionMode });
return Ok({ ...planWriter.value, permissionMode: config.permissionMode });
}

/**
Expand All @@ -134,7 +134,7 @@ export function* resolveAgentStack(
* ones a document could replace are not ones. The two advertised sets are stated
* by the host, not inherited.
*/
export function hostAcpDependencies(stack: AuthorshipStack): AcpxProviderDependencies {
export function hostAcpDependencies(stack: PlanWriterStack): AcpxProviderDependencies {
const { sessions } = stack;
const adapters = embeddedAdapterDependencies(stack.adapters);
if (sessions === undefined) {
Expand Down
28 changes: 14 additions & 14 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ import {
import { installWebComponents, installWebElicitation } from "@executablemd/web";
import { timebox } from "@effectionx/timebox";
import { timeout as runTimeout } from "@executablemd/runtime";
import { installRunAgentStack, resolveAgentStack, resolveAuthorshipStack } from "./agent-stack.ts";
import { installRunAgentStack, resolveAgentStack, resolvePlanWriterStack } from "./agent-stack.ts";
import { planComponentDeclaration } from "./plan-component.ts";
import { planAgentContext } from "./authorship-profile.ts";
import { planAgentContext } from "./plan-writer-profile.ts";
import { useVerboseComponent } from "./verbose-component.ts";
import type { AgentStack } from "./agent-stack.ts";
import { reportFailure } from "./report.ts";
Expand Down Expand Up @@ -888,7 +888,7 @@ export interface DocumentMode {
* a harness that owns a temporary tree names that tree, so a test never reads,
* creates or removes anything under a real one.
*/
planAuthorshipRoot?: string;
planWriterRoot?: string;
/**
* What a trusted host attaches to this one execution.
*
Expand Down Expand Up @@ -1015,7 +1015,7 @@ function* runDocument(
// learns what Agent context it has only after its own configuration has
// been read β€” and a declaration built out here would have closed over the
// absence of one before that child existed. Each caller supplies the context
// it settled, the authorship root it owns and the scope its host acts run in;
// it settled, the Plan writer root it owns and the scope its host acts run in;
// everything else about the Component is this entrypoint's and identical for
// all of them.
const planDeclaration = (request: ChildPlanDeclaration): Operation<DeclaredMarkdownComponent> =>
Expand All @@ -1024,18 +1024,18 @@ function* runDocument(
includes: include,
context: request.context,
...(mode.machineSessions === undefined ? {} : { sessions: mode.machineSessions }),
...(request.authorshipRoot !== undefined
? { authorshipRoot: request.authorshipRoot }
: mode.planAuthorshipRoot === undefined
...(request.planWriterRoot !== undefined
? { planWriterRoot: request.planWriterRoot }
: mode.planWriterRoot === undefined
? {}
: { authorshipRoot: mode.planAuthorshipRoot }),
: { planWriterRoot: mode.planWriterRoot }),
// Captured before the document exists, so the two acts that are this
// host's β€” putting this build's adapter on disk, and opening the review
// form β€” run outside the frame the Component installs around itself.
host: request.host,
...(request.observeAuthorship === undefined
...(request.observePlanWriter === undefined
? {}
: { observeAuthorship: request.observeAuthorship }),
: { observePlanWriter: request.observePlanWriter }),
installElicitation: request.installElicitation,
});

Expand Down Expand Up @@ -2503,12 +2503,12 @@ function* dispatch(
// Who writes, and nothing else. There is no permission mode to settle:
// this command starts no program, and the ceiling authorship runs under
// is the host's rather than the command line's.
const authorship = yield* resolveAuthorshipStack(
const planWriter = yield* resolvePlanWriterStack(
{ agentProvider: config.agentProvider, defaultAgent: config.defaultAgent },
sessions,
);
if (!authorship.ok) {
console.error(authorship.error.message);
if (!planWriter.ok) {
console.error(planWriter.error.message);
yield* exit(1);
break;
}
Expand All @@ -2520,7 +2520,7 @@ function* dispatch(
...(config.session === undefined ? {} : { session: config.session }),
verbose: config.verbose,
...(config.journal === undefined ? {} : { journal: config.journal }),
stack: authorship.value,
stack: planWriter.value,
},
{
...(sessions === undefined ? {} : { sessions }),
Expand Down
Loading
Loading