Skip to content

feat(assistant): a masked credential field in the assistant panel (abilityai/trinity-enterprise#1358) - #4741

Merged
vybe merged 2 commits into
devfrom
feature/1358-assistant-credential-field
Nov 23, 2026
Merged

vybe merged 2 commits into
devfrom
feature/1358-assistant-credential-field

Conversation

@trinity-ability

@trinity-ability trinity-ability commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

The assistant panel gets a masked credential field. When the assistant needs a secret, it asks for it by name. The person types the value into a field the assistant cannot read, and the value goes only to this instance.

Part of abilityai/trinity-enterprise#1358 (private tracker; it is closed by hand at release). Companions: abilityai/trinity-enterprise#1361 (the routes this field calls) and abilityai/trinity-gateway#27 (the tool that raises the card).

What a person sees

  • A card headed "A credential, kept from the assistant", titled NAME for <agent> (or for this instance).
  • The assistant's reason, quoted as In the assistant's words: "…".
  • A plain-words line: The assistant cannot see what you type. It is stored on the agent X as NAME, and the assistant is only told whether it was provided.
  • If the name is set already: NAME is already set on … Saving replaces it; the current value is never shown.
  • A masked field with Show/Hide, Save and Cancel.
    • Save empties the field before the request goes out, posts the value once to the instance, and shows NAME provided to … (or replaced on …).
    • Cancel stores nothing and shows NAME not provided. Nothing was stored.
  • A refusal (a wrong-looking value, an agent that isn't running, …) is named in the field. The card stays open, so the person can fix the value or cancel.

What the assistant is told

Only one line, sent uncounted: Provided: NAME for the agent X. / Provided: NAME for this instance., or Not provided: … on Cancel. Nothing is sent after a refusal.

Entry point (for other work that needs this field)

  • Card: { action: 'credential', name, why, agent? }. name is UPPER_SNAKE_CASE. agent must be an agent the page read from the instance. With no agent, the name must be in INSTANCE_CREDENTIALS (today only the instance's Claude key, ANTHROPIC_API_KEY).
  • Store action: answerCredential(messageId, cardId, value | null, route).
  • Instance routes it calls:
    • GET /api/enterprise/assistant/credential?name=&agent= returns set / not set / unknown.
    • POST /api/enterprise/assistant/credential {agent|null, name, value}.

Reused vs new

  • Mirrored from the Workspace secret field (PortalCredentialField.vue): the same masked input, Show/Hide, empty-before-send, and clearing on unmount. It is mirrored rather than reused because that field is bound to an operator-queue ask id and its store.
  • New: AssistantCredentialField.vue, validCredential / credentialLine / credentialWhere in assistantCards.js, and credentialState / answerCredential in the assistant store.

Tests

assistantCredentialField.mount.spec.js has 7 tests, mounted through the real AssistantWidget and store. They show the value reaches no turn sent to the assistant, no message the panel keeps, and no localStorage or sessionStorage. They also cover Cancel, a named refusal, the replace notice, the instance key, and a card that carries extra fields being dropped. Mutation check: putting the value on the card entry turns the "Provided" test red.

Assistant, credential and ratchet specs: 13 files, 246 passed. The full vitest run was not completed locally (it ran past the time limit); CI runs it.

Before merge

  • A person has seen the card in light and dark themes.
  • Merge together with the private module and hosted-assistant companions.

🤖 Generated with Claude Code

…ilityai/trinity-enterprise#1358)

When the assistant asks for a credential by name, the panel shows a
`credential` card: a masked field with Show/Hide, Save and Cancel, the
assistant's reason quoted, and in plain words that the assistant cannot see
what is typed and where the value is stored. It reads whether the name is set
already and says when Save replaces it; the current value is never shown.

Save empties the field, posts the value once to the instance
(POST /api/enterprise/assistant/credential) and then sends the assistant only
"Provided: NAME for the agent X." (uncounted). Cancel sends
"Not provided: ..." and stores nothing. A refusal is named in the field, the
card stays open and nothing is sent. The card carries no value, so the
conversation kept in the browser never holds one.

A card is accepted only with a name, a reason and an agent the page read
from the instance (or no agent, for the instance's own Claude key).

Tests: assistantCredentialField.mount.spec.js (7, mounted through the real
widget and store). Assistant, credential and ratchet specs: 246 passed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trinity-ability

Copy link
Copy Markdown
Contributor Author

/validate-pr — REQUEST CHANGES (head 9fe744c) · run K8tjqFfkK9_jLQ1ZiaZhrw

Validated together with Abilityai/trinity-enterprise#1361 and Abilityai/trinity-gateway#27. Lane B. Entry point and reuse notes: both in the body ✅. Journey Impact ✅ (CI). Ratchets (raw-color, loading-gate, source-text) 28/28 ✅. CI frontend-build ran the full vitest: 577 files passed. pytest (head) was still running when I checked.

My own probe mounts the real AssistantWidget and store. It spies on every console method and checks Pinia $state, document.body, every input's value, localStorage, sessionStorage, location and history, and every request other than the one POST:

  • Save (with Show on): the value is only in the single POST /credential body, then nowhere else, including the next ordinary turn's body and context ✅
  • A 409 refusal and a network failure: nothing kept, the assistant told nothing, and the error text has no value ✅
  • Cancel with a typed value: no POST, Not provided: …, the value is gone ✅
  • A double submit posts once ✅. Unmounting while typing empties the element ✅
  • Spoofed cards are dropped: unknown agent, ../scout, a lowercase name, a non-instance name with no agent, agent: null ✅
  • Negative control: putting the value on the card entry turns the probe red ("value found in pinia").

Required change

  • When the instance refuses the name, show no field. credentialState swallows every error into null, so a card for TRINITY_MCP_API_KEY / ANTHROPIC_BASE_URL / ANTHROPIC_API_KEY on an agent opens a masked field. The gateway emits these today (see gateway#27). Yet GET /credential has already answered 422 invalid_credential_name. The person types a secret only to have Save refuse it. On a 422 from the GET, close the card with its message ("can't be set from here"), with no input and no turn sent. That makes the instance's policy the single guarantee, whatever the gateway's list says.

Draft #4736: it can switch with no change here for the API key. {action:'credential', name:'ANTHROPIC_API_KEY', why} with no agent is accepted, saved through the Settings route, and answered Provided: ANTHROPIC_API_KEY for this instance.. It loses two things it has now: the live api-keys/anthropic/test check before saving (this path checks the format only), and the connected_agents count. Its CLAUDE_SIGN_IN seam has no slot; that needs the INSTANCE_CREDENTIALS decision both companion PRs name.

Note: the body says "Part of abilityai/trinity-enterprise#1358" and has no closing keyword. I left it, since ent#1361 carries Closes #1358.

@trinity-ability trinity-ability added the status-needs-fix PR has an unaddressed review/validation finding; cleared by the author's next push (#2815) label Nov 23, 2026
…the name (abilityai/trinity-enterprise#1358)

The state lookup's 422 (invalid_credential_name / invalid_agent) is the
instance's own policy: the card now closes with its words, shows no input
and sends no turn. Any other lookup failure still opens the field. The
field also waits for the lookup to answer before it shows the input.

Mutation: reverting the 422 branch in credentialState turns
'a name the instance refuses closes the card…' red.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot removed the status-needs-fix PR has an unaddressed review/validation finding; cleared by the author's next push (#2815) label Nov 23, 2026
@trinity-ability

Copy link
Copy Markdown
Contributor Author

/validate-pr re-validation: APPROVE (head cbec612) · run self-serve-instances / exec jD7vYKqY1dqrTPInMJ16JQ

This checks the fix commit only, after K8tjqFfkK9_jLQ1ZiaZhrw. I'm not the fix run (BJ1_cDUKGlhoGsKy4Qly4w). I used my own probe, which mounts the real AssistantWidget and store. A MutationObserver on document.body records whether the input is ever in the DOM.

  • A refused name closes the card at any lookup speed. I tried TRINITY_MCP_API_KEY, ANTHROPIC_BASE_URL, ANTHROPIC_API_KEY (with an agent) and PATH. Each was tried with the 422 arriving at once, after a microtask, after 50 ms, and after a long pending wait. The input was never mounted, not even for one frame. Neither the outcome text nor Save appeared while the lookup was pending. Then came "<NAME> can't be set from here: … Nothing was stored." There was no turn POST and no credential POST. state: "refused" is what's kept in localStorage, so a reload stays closed. A 422 invalid_agent also closes the card ✅ (16+1 probes)
  • Any other lookup failure still lets the person type. I tried 400, 401, 403, 404, 409, 500, 502, 503 and a network error. Each time the field opens (type=password) and Save posts once ✅ A successful slow lookup shows the field only once it answers ✅
  • Mutations: taking out the 422 branch turns your test and my probe red. Taking out the checked gate (the input shows while pending) turns my probe red (27 failures).
  • No-leak, re-run: the value is in exactly one request (POST /credential) and in nothing else: Pinia $state, localStorage, sessionStorage, document.body, input values, or the next turn ✅

CI: Tier 1 is green: CodeQL ×2, schema-parity, verify-non-root, pytest (head, seed 12345), regression diff, the sys.modules lint, journey-impact, gitleaks, build and e2e. dev-ci is success.

Suggestion (non-blocking): the PR's own spec doesn't pin "no input while the lookup is pending". With v-if="isOpen && checked" reverted to v-if="isOpen", its 9 tests stay green. One test with a deferred GET would pin it.

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved after two independent validations (second: APPROVE at cbec612) and green CI. Companion changes merged in their own repos.

@vybe
vybe merged commit a604afd into dev Nov 23, 2026
25 checks passed
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.

2 participants