Skip to content

feat(agent-harness): define commands tools and permission policy - #5639

Open
iscekic wants to merge 1 commit into
shared-agent-harness-3bb0-s2from
shared-agent-harness-3bb0-s3
Open

feat(agent-harness): define commands tools and permission policy#5639
iscekic wants to merge 1 commit into
shared-agent-harness-3bb0-s2from
shared-agent-harness-3bb0-s3

Conversation

@iscekic

@iscekic iscekic commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

No new behavior — this change defines actions but does not make them available in the product.


Summary

commandAdmission rejects agent permission changes and stale sends or mode changes; callers must supply the origin from command ingress.
evaluateDispatch uses DispatchPolicy and stored approval state; identity changes require a new call, and executing or settled calls cannot dispatch again.
ask requires approval except for trusted reads; yolo skips only approval, preserving denials, access, revision, availability, question, and client checks.

Files
  • packages/agent-harness/src/policy.ts — Added (A), source: 69 lines (+69/-0). Adds admission and dispatch decisions without executing actions. Compares the call identifier, run, name, definition version, arguments, context, effect, and execution target. Uses stored approval and execution state instead of proposed replacements. Keeps approval across mode or revision updates for an unchanged call when the current checks pass. Callers must derive trustedRead from a local definition, not remote annotations.

CommandSchema and ReadInputSchema, with inferred Command and ReadInput types, define nine mutations and five reads with strict identity and pagination contracts.
canonicalizeValidatedInput and fingerprintCommand normalize validated commands and authenticated scope with injected hashing; commandReplayDecision returns new, replay, or command_conflict.
setPermissionMode requires acknowledgePendingActions for yolo, while client registration retains older advertised versions; these definitions do not store or execute commands.

Files
  • packages/agent-harness/src/commands.ts — Added (A), source: 121 lines (+121/-0). Defines getOrCreateConversation, sendMessage, setPermissionMode, resolveInteraction, cancelRun, claimClientTool, completeClientTool, registerClient, and revokeClient. Mutations require protocolVersion, clientId, and commandId; conversation actions also require conversationId. Messages require nonblank text, a model, and a permission revision, with an optional variant. Mode changes require an expected revision; pending-action acknowledgement defaults to false. Interaction resolutions support approval, denial, question answers, and dismissal. Client completions require a grant, generation, and outcome; registration accepts only client tools with nonblank versions. Defines getConversation, getSnapshot, getCommand, getEvents, and getHistory; page limits run from 1 through 200. Events require an after cursor and default to 200 results; history defaults to 50 results with a nullable before cursor. Fingerprinting sorts nested object keys, preserves array order, and normalizes defaults. The caller supplies authenticated actor and conversation scope plus the platform's sha256 function. Conversation mismatches fail; extra authority fields, including transport credentials and timestamps, do not enter the hash. Reusing a stored command identity with a changed fingerprint returns a conflict rather than a replay.

toolDefinitions, ToolNameSchema, and ToolRequestSchema define 21 version-1 tools with strict input and output schemas, effects, and executor kinds, rejecting unnamed tools.
ScreenSchema restricts navigation; QuestionSchema, QuestionResponseSchema, and validQuestionResponse enforce stable identifiers, selection bounds, optional free text, and explicit cancellation.
The backend must install an executor before advertising a tool; ToolName and ToolRequest expose inferred types without enabling runtime actions.

Files
  • packages/agent-harness/src/tools.ts — Added (A), source: 202 lines (+202/-0). Adds backend definitions for organizations, members, usage, repositories, invitations, session search, attachment, start, continuation, stop, and progress. Adds Model Context Protocol (MCP) discovery and calls, plus web search and retrieval. App tools use the client executor: app.currentScreen is a read, while navigation, preferences, notifications, and settings declare side effects. Questions use the interaction executor. Invitations and session mutations have side effects. MCP calls use the unknown effect and require a server identifier, tool name, configuration version, and definition version. MCP discovery includes input and output schemas; calls return content with optional structured content. Web search requests allow one through five results and default to five; page addresses permit only http or https. Pages and attached session messages require untrusted: true. Screens allow quick chat, organization members, preferences, or an identified session; preferences allow only showToolDetails and reasoningDefaultExpanded. Notification results report granted, denied, undetermined, or unavailable permission; settings results report whether settings opened. Questions require unique choice identifiers, matching response identifiers, and valid selection bounds; free text cannot replace required selections. allowFreeText defaults to false; explicit allowCancellation controls dismissal, including questions that permit only cancellation. Answers reject duplicate or unknown choices and blank text; cancellation-only questions cannot return an empty answer.

Tests: 1 test file added (A): packages/agent-harness/src/policy.test.ts (622 lines; +622/-0). Covers replay, schema validation, questions, all 21 tools, and 54 effect/executor/mode/revision combinations. The implementer reports 172 targeted tests; the reviewer reports 158 policy tests and passing scoped checks.
Generated: 0 files changed.


Visual Changes

Visual Changes: N/A

Verification

Manual verification: not run for this level because it adds inert portable commands, tool definitions, and policy only.
Full runtime verification runs on the completed stack tip.

Reviewer Notes

Human steps

No human steps apply before merge or after merge.

Worktrees

  • Repository: Kilo-Org/cloud.
  • Worktree: /Users/igor/Projects/.worktrees/shared-agent-harness-3bb0.
  • Branch: shared-agent-harness-3bb0-s3; base: origin/shared-agent-harness-3bb0-s2.

Notes

E2E: This level adds inert portable commands, tool definitions, and policy only. Full runtime verification runs on the completed stack tip.

Stacked PRs — merge bottom to top. Each level shows only its own diff.

Runtime verification (E2E, user advocacy, simplify) runs on the tip PR over every level.
Every level keeps its own checks, its own bot review, and its own threads; each one is answered on its own PR.
Each level is its own deliverable: it builds and passes its own checks alone.
A finding on a level is repaired on that level, then carried upward with stack.sh forward.

  1. shared-agent-harness-3bb0chore(agent-harness): register workspaces and enforce CI boundaries #5632
  2. shared-agent-harness-3bb0-s2feat(agent-harness): define portable domain and snapshots #5637
  3. shared-agent-harness-3bb0-s3feat(agent-harness): define commands tools and permission policy #5639 ← this PR
  4. shared-agent-harness-3bb0-s4feat(agent-harness): share client state and cursor recovery #5643
  5. shared-agent-harness-3bb0-s5feat(agent-harness): persist command intents and execution receipts #5647
  6. shared-agent-harness-3bb0-s6feat(db): add harness ingress grants and retirement fences #5655
  7. shared-agent-harness-3bb0-s7feat(agent-harness): deliver legacy history and project durable text #5659
  8. shared-agent-harness-3bb0-s8feat(agent-harness): authorize durable grants and registered clients #5662
  9. shared-agent-harness-3bb0-s9feat(agent-harness): fence retirement and retry payload cleanup #5667
  10. shared-agent-harness-3bb0-s10feat(agent-harness): persist authoritative state in SQLite #5675 (tip)

@kilo-code-bot

kilo-code-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Reviewed the new agent-harness command, tool, and permission-policy definitions (inert, not wired to runtime) with high confidence; admission, dispatch, fingerprinting, and schema gates match the stated contracts.

Files Reviewed (4 files)
  • packages/agent-harness/src/commands.ts
  • packages/agent-harness/src/policy.ts
  • packages/agent-harness/src/tools.ts
  • packages/agent-harness/src/policy.test.ts

Reviewed by grok-4.6 · Input: 144.7K · Output: 20.3K · Cached: 348.9K

Review guidance: REVIEW.md from base branch shared-agent-harness-3bb0-s2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant