Repository navigation
Conversation
… the typed command layer
@agentic-kit/session and the agent CLI:
@agentic-kit/session is a new package with the sign-in that every
Constructive binary shares:
- Backend contexts with all five planes (api, auth, modules, agent and
compute), from the endpoints or from the CONSTRUCTIVE_* overrides.
- resolveSession answers who talks to which backend in one of seven
states, and pairs a credential only with the backend it was issued for.
- signIn and signOut with email and password. A sign-in mints a 30-day API
key, revokes the key of the session it replaces, and stores the session
with the backend it was issued for. verifySession asks the backend
whether it still accepts the credential, and keyEndsSoon says when to
sign in again.
- Agents: createAgent, listAgents, renewAgentKey and removeAgent manage a
principal of the person with its own key, whose lifetime is capped on
the principal at 30 days. The package uses the key only to mint short
access tokens, which it caches in a 0600 file and reuses until they
end. The backend also accepts the key itself, so whoever holds it can
act as the agent until it ends, is renewed or the agent is removed; it
stays in a 0600 file. An agent cannot change the schema unless it is
allowed to (grantSchemaChanges, revokeSchemaChanges).
- sessionToolsHost, the db-tools host on top of the resolved session.
- The store lives under ~/.constructive/, and CONSTRUCTIVE_STASH_DIR
replaces ~. Context and agent names are checked.
The agent CLI (@agentic-kit/cli) signs in and out through it and loses
its own account, backend, API key and credential code. whoami also asks
the backend whether it accepts the credential. The README names the
access tools it registers.
CI runs the session tests in the agentic batch.
@agentic-kit/mcp:
@agentic-kit/mcp is a new package. serveStdio and createMcpServerFactory
serve HarnessTools on @modelcontextprotocol/server 2.x. A tool's name,
title, description, parameters, effect, failures and follow-up calls come
from the tool object; the plan and the gate's decision come from the
harness.
- readOnly: true serves the tools whose effect is read; readOnly: false
adds the tools whose effect is write. A destructive tool is not served
in either mode.
- A write tool is annotated readOnlyHint: false, destructiveHint: true and
idempotentHint: false, with _meta "anthropic/requiresUserInteraction":
true, so a host that honors it asks the person before each call.
- A write call gets its plan from the gate. When the gate blocks it, the
failure comes back and nothing changes. When it runs, the result carries
the plan. A client with form elicitation is shown the plan once as an
optional preview: the host's prompt is the approval, so the "Apply this
change" box starts ticked and accepting the form applies the change. A
decline, a closed question or an unticked box changes nothing.
- structuredContent is an envelope: { ok: true, data, plan?, calls? }, or
{ ok: false, error, data?, plan?, calls? } with isError.
- A tool that throws returns a fixed sentence that names the tool, with
the logged error's id when there is one, and never the error's text.
- The server sends instructions on connect: the read tools to call first,
the tools that change things, and that the host asks before each of
them. The host's own instructions follow.
CI runs the MCP tests in the agentic batch.
@agentic-kit/command:
@agentic-kit/command is a new package: the command layer of the
Constructive CLI, and the binding of a HarnessTool to a command.
- A command's input is a zod object. The layer parses it once; help,
<command> --schema, --llms and --llms --json print JSON Schema made from
it. Each property is a flag; values are coerced by their JSON Schema
type; --input takes the whole input as JSON, @path or stdin. One null
rule: null for an optional key that does not take null reads as not
given.
- Five kinds of command: a read, a change ({ plan, apply }), a change
that runs at once (a write marked immediate), a server, and a
passthrough. A change is planned, and the layer itself decides its
approval: --dry-run returns the plan, --yes approves, a terminal asks,
and any other run exits 3. createCli refuses a change that defines run
without immediate, so no change skips its approval. A plan can name
the flags its apply needs without a terminal (Planned.needs, such as
--password-stdin), and the --yes step after --dry-run or exit 3 carries
them when the run has no terminal.
- One output contract: text with a Next: block on a terminal, otherwise
one JSON envelope. Exit codes: 0 done, 1 failed, 2 usage, 3 approval
required, 4 sign in first, 130 interrupted. A secret marked x-secret is
never echoed.
- Help topics are data: createCli takes topics, a built-in help command
prints the CLI's help, a command's or group's help, or a topic, and a
word it does not know is a usage error that names the nearest one.
The --llms index and manifest carry the topics, and renderReference
turns the manifest into one Markdown reference (the source of the
CLI's man page).
- toolCommand and toCliCommands bind tools: the tool's params are the
input, its effect is the command's effect, a change plans through the
gate policy (callChange), a tool failure becomes a CliError with the same
code, and the tool's suggested calls become the first next steps.
toolCallStep writes a call the same way for another host.
inquirerer stays the prompt library and parseArgv.
CI runs the command tests in the agentic batch.
BREAKING CHANGE: agent login stores a 30-day API key, in place of a
5-year key that the CLI renewed by itself; when it ends, run agent login
again. A session stored by an earlier version records no backend, so it
is not used; run agent login again. CONSTRUCTIVE_STASH_DIR replaces
AGENT_HOME. @agentic-kit/cli no longer exports HOST_ENV_VARS.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of constructive-io/constructive-planning#2588. Stack 2 of 3, on the tools PR.
After dev-utils publishes:
inquirerer^4.10.0inagentic/commandandagentic/cli,appstash^0.9.0inagentic/session, and a new lockfile; CI cannot build@agentic-kit/commandbefore that.The integration-tests PR moves its pin to this merge.
@agentic-kit/session and the agent CLI:
@agentic-kit/session is a new package with the sign-in that every
Constructive binary shares:
compute), from the endpoints or from the CONSTRUCTIVE_* overrides.
states, and pairs a credential only with the backend it was issued for.
key, revokes the key of the session it replaces, and stores the session
with the backend it was issued for. verifySession asks the backend
whether it still accepts the credential, and keyEndsSoon says when to
sign in again.
principal of the person with its own key, whose lifetime is capped on
the principal at 30 days. The package uses the key only to mint short
access tokens, which it caches in a 0600 file and reuses until they
end. The backend also accepts the key itself, so whoever holds it can
act as the agent until it ends, is renewed or the agent is removed; it
stays in a 0600 file. An agent cannot change the schema unless it is
allowed to (grantSchemaChanges, revokeSchemaChanges).
replaces ~. Context and agent names are checked.
The agent CLI (@agentic-kit/cli) signs in and out through it and loses
its own account, backend, API key and credential code. whoami also asks
the backend whether it accepts the credential. The README names the
access tools it registers.
CI runs the session tests in the agentic batch.
@agentic-kit/mcp:
@agentic-kit/mcp is a new package. serveStdio and createMcpServerFactory
serve HarnessTools on @modelcontextprotocol/server 2.x. A tool's name,
title, description, parameters, effect, failures and follow-up calls come
from the tool object; the plan and the gate's decision come from the
harness.
adds the tools whose effect is write. A destructive tool is not served
in either mode.
idempotentHint: false, with _meta "anthropic/requiresUserInteraction":
true, so a host that honors it asks the person before each call.
failure comes back and nothing changes. When it runs, the result carries
the plan. A client with form elicitation is shown the plan once as an
optional preview: the host's prompt is the approval, so the "Apply this
change" box starts ticked and accepting the form applies the change. A
decline, a closed question or an unticked box changes nothing.
{ ok: false, error, data?, plan?, calls? } with isError.
the logged error's id when there is one, and never the error's text.
the tools that change things, and that the host asks before each of
them. The host's own instructions follow.
CI runs the MCP tests in the agentic batch.
@agentic-kit/command:
@agentic-kit/command is a new package: the command layer of the
Constructive CLI, and the binding of a HarnessTool to a command.
--schema, --llms and --llms --json print JSON Schema made from
it. Each property is a flag; values are coerced by their JSON Schema
type; --input takes the whole input as JSON, @path or stdin. One null
rule: null for an optional key that does not take null reads as not
given.
that runs at once (a write marked immediate), a server, and a
passthrough. A change is planned, and the layer itself decides its
approval: --dry-run returns the plan, --yes approves, a terminal asks,
and any other run exits 3. createCli refuses a change that defines run
without immediate, so no change skips its approval. A plan can name
the flags its apply needs without a terminal (Planned.needs, such as
--password-stdin), and the --yes step after --dry-run or exit 3 carries
them when the run has no terminal.
one JSON envelope. Exit codes: 0 done, 1 failed, 2 usage, 3 approval
required, 4 sign in first, 130 interrupted. A secret marked x-secret is
never echoed.
prints the CLI's help, a command's or group's help, or a topic, and a
word it does not know is a usage error that names the nearest one.
The --llms index and manifest carry the topics, and renderReference
turns the manifest into one Markdown reference (the source of the
CLI's man page).
input, its effect is the command's effect, a change plans through the
gate policy (callChange), a tool failure becomes a CliError with the same
code, and the tool's suggested calls become the first next steps.
toolCallStep writes a call the same way for another host.
inquirerer stays the prompt library and parseArgv.
CI runs the command tests in the agentic batch.
BREAKING CHANGE: agent login stores a 30-day API key, in place of a
5-year key that the CLI renewed by itself; when it ends, run agent login
again. A session stored by an earlier version records no backend, so it
is not used; run agent login again. CONSTRUCTIVE_STASH_DIR replaces
AGENT_HOME. @agentic-kit/cli no longer exports HOST_ENV_VARS.