Skip to content

artifactr.capabilities

artifactr's artifact tools as capabilities, offered through lattice-core's registry and called only through its enforcer (ADR-0099, lattice RFC-0011). It needs no extra.

artifactr's capabilities: its artifact tools, and its catalog, offered through lattice-core.

ArtifactrProvider offers the tools every artifact-aware agent has as command capabilities, to callers outside artifactr's own threads, each called through lattice-core's enforcement path (lattice RFC-0011, artifactr ADR-0099). ArtifactrCatalogProvider offers every command of artifactr's catalog a client may call, bound to the application's workspaces and runner (lattice RFC-0014, artifactr ADR-0103). A registry holds one of them, since they share six names.

FILES module-attribute

FILES: Final = frozenset(
    {"artifactr.list_files", "artifactr.read_file"}
)

Native files' commands, which the files extra serves, not this provider.

NAMES module-attribute

NAMES: Final = (
    "artifactr.list_artifacts",
    "artifactr.read_artifact",
    "artifactr.create_artifact",
    "artifactr.edit_text",
    "artifactr.propose_text",
    "artifactr.archive_artifact",
)

The capabilities' names, in the order they're offered.

VERSION module-attribute

VERSION: Final = '1.0.0'

Each capability's version.

ActorFor

How a call's context becomes the actor its workspace is opened as.

ArtifactrCatalogProvider

ArtifactrCatalogProvider(
    workspaces: Workspaces,
    runner: Runner[Any],
    *,
    types: Sequence[type[Artifact]],
    actor: ActorFor = actor_for,
)

Bases: ArtifactrCommands

artifactr's catalog bound to its workspaces: lattice-core's Provider and Commands.

Parameters:

Name Type Description Default
workspaces Workspaces

The application's workspaces, which each call opens its own in.

required
runner Runner[Any]

Carries out each write once per command id, as every surface does, so a message reaches the thread's agent.

required
types Sequence[type[Artifact]]

The artifact types a caller may create; artifactr.create_artifact names them and describes each one's JSON Schema, as artifactr ADR-0099's provider does.

required
actor ActorFor

How a call's context becomes the actor its workspace is opened as; actor_for if omitted.

actor_for

capabilities

capabilities(_scope: Scope) -> tuple[Capability, ...]

Return the commands a client may call, the same in every workspace.

What a workspace accepts beyond them, its types and its gate, it decides as each command commits.

call async

call(
    capability: Capability,
    arguments: JsonObject,
    context: CallContext,
) -> ToolResult

Carry out a command in the call's workspace, as the call's actor, and answer text.

Raises:

Type Description
ValueError

If the capability isn't one this provider offers, or one called in a workspace names none.

ValidationError

If the arguments aren't the command's.

Rejection

If the workspace refuses the actor or the command; CommandRejected for a write it refuses.

CommandRejected

CommandRejected(rejection: dict[str, JsonValue])

Bases: Rejection

A command the workspace refused: its rejection, as artifactr's surfaces send it.

payload

payload() -> dict[str, JsonValue]

Return the rejection as the workspace gave it.

ArtifactrProvider

ArtifactrProvider(
    workspaces: Workspaces,
    *,
    types: Sequence[type[Artifact]],
    actor: ActorFor = actor_for,
)

artifactr's artifact tools, as capabilities, offered in every workspace.

Parameters:

Name Type Description Default
workspaces Workspaces

The application's workspaces, which each call opens its own in.

required
types Sequence[type[Artifact]]

The artifact types a caller may create; their JSON Schemas are described once, in artifactr.create_artifact's description.

required
actor ActorFor

How a call's context becomes the actor its workspace is opened as; actor_for if omitted.

actor_for

capabilities

capabilities(_scope: Scope) -> tuple[Capability, ...]

Return the capabilities, which are the same in every workspace.

What a workspace accepts beyond them, its types and its gate, it decides as each command commits.

call async

call(
    capability: Capability,
    arguments: JsonObject,
    context: CallContext,
) -> ToolResult

Call one of the capabilities in the call's workspace, as the call's actor.

Raises:

Type Description
ValueError

If the capability isn't one of artifactr's, or the call names no workspace.

ValidationError

If the arguments aren't the capability's.

Rejection

If the workspace refuses the call or its command.

actor_for

actor_for(
    context: CallContext,
) -> UserActor | ExternalAgentActor

Return the actor a call acts as: the outside client it came through, or else its caller.

  • A call through an outside client (via) is that client's ExternalAgentActor, by its connection's id and name, for the person the caller is or acts for (lattice RFC-0014).
  • A person's own call is their UserActor.
  • An agent's run is an outside agent's, agent:<agent>, and a code session's is session:<id>, each for the person it acts for, if it acts for one. Neither is artifactr's own thread agent.

Parameters:

Name Type Description Default
context CallContext

The call's context.

required