Skip to main content

Module assistant

Module assistant 

Source
Expand description

The built-in assistant: Claude answers engineers’ questions about the PDM data, using the MCP tool set (mcp::tools) on the server.

Flow of one run: the question (a quick action or free text) becomes the first user message; the server sends it with the tool definitions to the model API (through the provider-neutral layer in crate::llm), runs every tool call the model asks for with the rights of the signed-in user and sends the results back, until the model answers or a limit (steps, tokens, time) is reached.

  • Enabled only when an API key (or a local server) is configured; the key never leaves the transport except in its request header.
  • Read-only by default: the write tools (create_change_draft, add_to_change, create_change_request, comment_change_request) are only offered when the request allows drafts.
  • No SDK: plain JSON over the existing reqwest client. The HTTP part sits behind llm::Transport and the tools behind Tools, so the loop is tested without network or database.

The audit record of a run (who, which action, question length, tools – no content) is written by services::assistant.

Structs§

Answer
The final answer of a run.
Assistant
The configured assistant of a server.
CheckLine
One line of teamcraft assistant check.
Limits
Limits of one run.
McpTools
The MCP tools with the rights of me. A run takes minutes, so every call uses the user’s rights as they are at that moment (a membership lost or a group restricted during the run applies to the next step).
OpenLink
A link the reply shows under the answer: “Open 3D preview”.
Question
One request to the assistant.
ToolUse
One tool call of a run, for the answer and the audit log.
Trace
What a run did so far – filled even when it fails or times out.

Enums§

Action
What the user asked for.
AssistantError
Why a run failed.

Constants§

MAX_OPEN_LINKS
Most “Open 3D preview” links under one answer.
MAX_QUESTION_CHARS
Longest free question in characters.
MAX_RUN_TOKENS
Most input + output tokens of one run, summed over all steps.
MAX_TOOL_RESULT_BYTES
Longest tool result handed to the model, in bytes.
OPEN_PREVIEW_TOOL
The tool whose results carry an open hint.
TAINTED_WRITE
The answer of a text write tool once the run has read restricted content.
TEXT_WRITE_TOOLS
Write tools that put free text into objects other users read.

Traits§

Tools
Runs one tool and returns its MCP CallToolResult.

Functions§

check
Sends one small request with one tool and reports reachability, the key, the model, tool support and token counts. Never includes the key.
open_links
The links of a run’s open hints. A hint is model-reachable data, so its URL is checked like untrusted input: only this server’s 3D viewer page of a file (relative, or under public_url) passes, as a relative path; anything else is dropped. Duplicates are shown once.
provider_for
The wire format of a configured provider.
render_markdown
Renders the model’s markdown-lite as safe HTML: headings, lists, pipe tables, code blocks, paragraphs, code and bold. All text is escaped; the only generated links point to items of this server.
run_loop
Runs the tool loop until the model answers or a limit is reached.
system_prompt
The system prompt of a run.
tool_result_text
The text of an MCP CallToolResult and whether it is an error.
tool_specs
The tools offered to the model: the MCP tool set, without the write tools unless drafts are allowed.