From 3535c42ba601cffcb89a7f1285709a5a8b93cc91 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 07:16:59 +0000 Subject: [PATCH 1/5] docs(skills): the objectstack-ai entry file becomes a router The entry keeps four first checks, one skill and one knowledge-source example, the confirmation rule of every AI door, two pitfalls and a routing list. Key tables and option lists go behind the contract, the door's own tool list or the published AI pages. Claude-Session: https://claude.ai/code/session_01ADHkmSM46qymk97AyqPzoS Co-authored-by: Claude --- skills/objectstack-ai/SKILL.md | 555 +++++++-------------------------- 1 file changed, 116 insertions(+), 439 deletions(-) diff --git a/skills/objectstack-ai/SKILL.md b/skills/objectstack-ai/SKILL.md index 68c6a062cd8..1728863efbf 100644 --- a/skills/objectstack-ai/SKILL.md +++ b/skills/objectstack-ai/SKILL.md @@ -20,63 +20,22 @@ metadata: # AI Agent Design — ObjectStack AI Protocol -> **Edition boundary. ☁️ marks a cloud / Enterprise surface, and is not restated -> below.** The in-UI AI **runtime** — the `ask` / `build` agents, in-product -> chat, `/api/v1/ai/*` (`@objectstack/service-ai`) — ships cloud / EE, not in the -> open framework. The **schemas** in `@objectstack/spec/ai` stay open, so you -> author `*.skill.ts` / `*.tool.ts` as source either way, but they only execute -> in a cloud / EE host. On the **open edition** there is no in-product agent: -> expose the app to your own AI over **MCP** (below), and author metadata in -> **source mode** with an AI coding agent (Claude Code, Cursor). +> **☁️ marks a cloud / Enterprise surface**: the in-product `ask` / `build` +> agents, chat, `/api/v1/ai/*`. The schemas are open, and the open edition's AI +> path is **MCP**. ---- - -## Skill Configuration - -| Required | Type | Description | -|:---------|:-----|:------------| -| `name` | `snake_case` | Unique skill id (`/^[a-z_][a-z0-9_]*$/`) | -| `label` | string | Display name | -| `tools` | `string[]` | Tool names this skill grants (trailing wildcard allowed, e.g. `action_*`) — every name must resolve; see the ladder below | - -| Optional | Purpose | -|:---------|:--------| -| `surface` | `'ask' \| 'build' \| 'both'` — which platform agent may bind this skill (default `'ask'`). Enforced in `resolveActiveSkills` at load: an incompatible binding is a **fast load error** (ADR-0063 §3) | -| `description` | What the skill does — the agent reads it to decide when to use the skill | -| `instructions` | Prompt guidance. On the open edition `@objectstack/mcp` projects it onto the MCP `prompts` primitive, so a skill with blank `instructions` — or `active: false` — is not listed | -| `triggerConditions` | Programmatic activation rules (below) | -| `active` | Enabled (default `true`) | -| `context` | Bare name of the context pack the skill works from (**Context packs** below), resolved in the skill's package, then its dependency closure. Unless `tools` binds `get_record_context`, by name or wildcard, the parse refuses it | - -> A skill has **no `permissions` key** — removed in 17.0.0 because it gated -> nothing. Gate at the **agent** (`access` / `permissions` on `defineAgent`, -> enforced at the chat route) or on the actions the tools call (ADR-0066). +## First checks -### Naming the tools: the resolution ladder +1. **Version.** The installed `@objectstack/spec` wins over the `compatibility` + line; a retired key is refused with its fix (objectstack-upgrade). +2. **Read what exists**: the stack's `skills`, `knowledgeSources`, `aiContexts`, + `requires` and its objects' `actions`. Invent no tool name. +3. **Read the contract, never recall a key**: + [references/_index.md](./references/_index.md) lists the `ai/*.zod.ts` + schemas; their docblocks say which edition reads a key. +4. **`os validate`** before reporting done. -A `skill.tools[]` entry resolves against the union of four sources -(`packages/lint/src/validate-ai-tool-references.ts`): - -1. **`stack.tools[].name`** — records your own stack declares (none by - default: *Tool metadata* below). -2. **`PLATFORM_PROVIDED_TOOL_NAMES`** — the statically-registered platform - tools, flattened from `PLATFORM_TOOLS_BY_PACKAGE` in - `packages/spec/src/system/constants/platform-tool-names.ts`: data / - knowledge tools from `service-ai`, schema / metadata / package tools from - `service-ai-studio`. -3. **`action_`** — one tool per AI-exposed Action of your own stack - (`PLATFORM_TOOL_FAMILY_PREFIXES`). **The default path** for anything your app - does. -4. **`MCP_DOOR_TOOL_NAMES`** (same file) — every tool the MCP door registers - (`query_records`, `run_action`, the `MCP_FILE_TOOL_NAMES` file pair, …), - resolved only for a skill MCP can offer (`mcpPrompt` not `false`). On a - `mcpPrompt: false` skill a name only the door serves still warns, with its - own hint: no in-product turn registers it. - -A name none of them resolves raises **`ai-skill-tool-unresolved`** (warning, -ADR-0078 advisory-first). - -### Skill Example +## Skills ```typescript @@ -85,423 +44,141 @@ import { defineSkill } from '@objectstack/spec'; export default defineSkill({ name: 'crm_case_management', label: 'Case Management', - description: 'Triage, query, and escalate support cases.', - instructions: ` - When managing cases: - - Always check for duplicate cases before creating a new one. - - Set priority by customer tier: Enterprise → High, Pro → Medium, Free → Low. - `, - // Two platform tools (rung 2) and this stack's own Action (rung 3). - tools: ['query_records', 'get_record', 'action_crm_escalate_case'], - triggerConditions: [ - { field: 'objectName', operator: 'eq', value: 'support_case' }, - ], - active: true, + instructions: 'Check for a duplicate case first.', + tools: ['query_records', 'action_crm_escalate_case'], + triggerConditions: [{ field: 'objectName', operator: 'eq', value: 'support_case' }], }); ``` -### Trigger Conditions - -Each condition is `{ field, operator, value }`, ANDed with its siblings. The -shape of `value` is **coupled to `operator`** — a mismatch is a parse error, not -a coercion (`packages/spec/src/ai/skill.zod.ts:38-52, 140-203`): - -| Operator | Meaning | `value` must be | -|:---------|:--------|:----------------| -| `eq` | Equals | a **string** — an array is reference identity, so it never matches | -| `neq` | Not equals | a **string** — an array would always fire | -| `in` | In list | an **array** (empty `[]` is allowed and is a real predicate) | -| `not_in` | Not in list | an **array** | -| `contains` | Substring, or array subset | **either** — both spellings execute | - -Nothing matches phrases: write routing as `triggerConditions` and -natural-language intent in `description` / `instructions`, where the model reads it. - -**In-app `ask` assistant ☁️:** a package skill with `surface` `ask` or `both` -loads for the app the user is in (the `build` side is not served while in-app -build is closed), and a tool it names outside the allow-set is dropped with a -diagnostic. A condition can read `appName`, `objectName`, `recordId`, -`selectionKind` and `userRole`. The client sends all five, so a condition on -any, `userRole` included, is routing, never access control: the turn's tools -still run under the caller's own permissions. - ---- +- **Skills are the one extension.** The `agent` type is closed: a stack-authored + `*.agent.ts` is filtered out ☁️ (`os validate` warns), and `agent.tools` / + `agent.knowledge` are refused. Declare the tools in a `defineSkill` under the + stack's `skills`; its `surface` ☁️ (`'ask'`, the default, `'build'` or + `'both'`) names the platform agent that takes them. Scope retrieval on the + knowledge source (`aiExposed`, `source.where`). +- **Every `tools` name resolves** to a platform tool + (`PLATFORM_PROVIDED_TOOL_NAMES` in `@objectstack/spec/system`; also + `MCP_DOOR_TOOL_NAMES` unless `mcpPrompt: false`), an `action_` this + stack exposes (or `action_*`) or a `stack.tools` record, or `os validate` + warns (`ai-skill-tool-unresolved`). Over MCP a skill is its `instructions`, + as a prompt: the HTTP door offers it only when the server lists every tool it + binds. +- **`triggerConditions`** ☁️ route on context the client reports (`appName`, + `objectName`, `recordId`, `selectionKind`, `userRole`): never access control, + and a skill has no `permissions` key. ## Actions as AI Tools — the default path ☁️ -An -`Action` attached to an object via `defineObject({ actions: [...] })` becomes a -tool named `action_` **only when it opts in** — `ai.exposed: true` -(default `false`) plus an `ai.description` of ≥ 40 chars, refused by the parse -without it (ADR-0011). `registerActionsAsTools()` walks the opted-in ones; -there is no opt-out key. - -Three action types dispatch headlessly: +An Action reaches AI only when it opts in, `ai: { exposed: true, description }` +(≥ 40 chars): as the tool `action_` ☁️, and over MCP in +`list_actions` for `run_action`. Name it in a skill's `tools`. -| `action.type` | Dispatch | Wiring | -|:---|:---|:---| -| `script` | `IDataEngine.executeAction(object, target, ctx)` — same as Studio's row toolbar | none | -| `api` | HTTP call to `action.target` (`fetch`-based by default) | `AIServicePlugin({ apiActionBaseUrl, apiActionHeaders })` or a custom `apiClient` | -| `flow` | `IAutomationService.execute(target, { triggerData })` | `automation` service registered with the kernel | - -**Skipped even when opted in:** UI-only types (`url`, `modal`, `form`); and -dangerous variants — the declared `mode: 'delete'` / `variant: 'danger'` only -(`confirmText` is dialog copy, *not* a destructive signal; `ai.requiresConfirmation` -overrides either way) — **unless** the plugin runs with `enableActionApproval: true`, -which routes them through the approval queue instead. - -**`type:'api'` body assembly** (last wins): user params → `recordIdParam` (using -`recordIdField`, default `'id'`) → `bodyExtra`. `bodyShape: { wrap: 'data' }` -nests user params under `data` while keeping `recordIdParam` flat. - -**Human-in-the-loop.** `AIServicePlugin({ enableActionApproval: true })` (default -`false`) persists an `ai_pending_actions` row instead of running a dangerous -action and returns `{ status: 'pending_approval', pendingActionId }`. The queue -is listed in Studio's **AI Pending Actions** inbox (or via -`GET /api/v1/ai/pending-actions`), but deciding is the person's own act: only the -person the call ran as approves or rejects the item, in the app on their -signed-in session. Another user's `ai:approve` does not decide it; an API key -or token (even the person's own) is refused, and so is an AI identity and any -call that arrives through an AI door. The model's own confirmation does not -decide the item, and neither does a `confirm` on the call: the item waits for -the person. So an operator script lists items and never decides them; a second approver goes through the approvals engine (the `held` -outcome). Whether *your* action is queued is -decided entirely by the skip rule above — `actionSkipReason(action, ctx)` and -`actionRequiresApproval(action)` (from `@objectstack/service-ai`) answer both -questions, and Studio's "AI exposure" diagnostics use the same predicates. - -**No page declares an AI button of its own**, so there is no action to write -for one: the shell's 「问 AI」 entry opens the in-app assistant and carries the -current record automatically. - ---- +- **Write no tool record.** `defineTool` (`*.tool.ts`) only refines how an + existing capability is presented: `ToolSchema` has no `handler` / + `implementation` field, and nothing executes one. +- **An opted-in action can still be no tool**: `url`, `modal` and `form` are + UI-only, and in-app ☁️ a destructive one (`mode: 'delete'`, + `variant: 'danger'`, unless `ai.requiresConfirmation` says otherwise) is + skipped unless the host runs `enableActionApproval: true`. +- **No page declares an AI button**: the shell's 「问 AI」 entry opens the + assistant on the current record. Write no action. ## MCP — the open-edition AI path -`@objectstack/mcp` publishes your app over the Model Context Protocol, so an -external agent (Claude, Cursor, Codex, …) can read it and act on it with **no -cloud licence**. (Consuming *external* MCP servers is the inbound sibling, -`@objectstack/connector-mcp`.) Answering a question through those tools, as -the connected agent, is **objectstack-ask**. - -```ts -import { MCPServerPlugin } from '@objectstack/mcp'; - -kernel.use(new MCPServerPlugin()); -``` - -The HTTP surface is **default-on**, served per-request by the runtime dispatcher -at **`POST /api/v1/mcp`** — nothing to start (`OS_MCP_SERVER_ENABLED=false` opts -out). The long-lived **stdio** transport has its own switch and defaults off: -`autoStart: true`, or `OS_MCP_STDIO_ENABLED=true`. (`OS_MCP_SERVER_ENABLED=true` -still starts it — deprecated, and it warns at boot.) - -The tools a client then sees — from `registerObjectTools` / `registerActionTools`, -each family gated by the caller's OAuth scopes, every call under the caller's -permissions and row-level security: - -| Tools | What they do | -|:--|:--| -| `list_objects`, `describe_object` | schema introspection (system objects filtered out by default) | -| `query_records`, `get_record` | reads — filter, field selection, sorting, pagination | -| `get_record_context` | one record through its context pack (**Context packs** below) | -| `aggregate_records` | GROUP BY totals; registered only when the data bridge implements `aggregate` | -| `validate_expression` | build-accurate CEL check before a formula is authored into metadata | -| `create_record`, `update_record`, `delete_record` | writes; `delete_record` is refused with `ACTION_CONFIRMATION_REQUIRED` (428) unless it sends `confirm: true`. A request in which the human names the record to delete, with exactly one record matching, is their approval: send `confirm: true` on that call without asking again. When the name matches more than one record, or the request does not identify one, list the candidates, ask which one, and send `confirm: true` only after the answer | -| `delete_records` | up to 200 records of one object per call (fewer under a smaller `OS_DATA_MAX_PAGE_SIZE` or `OS_DATA_QUERY_ROW_BUDGET`), by `where` or `recordIds`, not both; a call without `confirm: true` is the preview (match count, sample ids) and deletes nothing — show it to the human, and send `confirm: true` only once they approve; over OAuth it needs `data:read` and `data:write` | -| `list_actions`, `run_action`, `resume_run` | your AI-exposed business Actions — the same `ai.exposed` opt-in as above; registered only when the bridge implements `listActions` and `runAction` (the stdio bridge does not, so it serves none), `resume_run` only when it also implements `resumeRun`. An action declaring `ai.requiresConfirmation: true` (`list_actions` reports it) never runs on the call: the host's pending-confirmation service hands it to the person the call runs as, who approves or rejects it in the app, and the answer is `status: 'pending_confirmation'` with a `pendingId` — a success, so relay its message and do not retry. Under an AI service account's own key (an agent acting for itself, for no person) the call is refused with the same 428, `details.reason: 'service_account'`, at every action door, and nothing runs: hand the action to a person, or its author declares `ai.requiresConfirmation: false` when it is safe unattended. `resume_run` submits a paused screen flow's form under the same gates; a handed-off run stays paused | - -**Never send `confirm` to `run_action` or `resume_run`:** a call carrying it is -refused, on every action. A host with no such service (the open build ships -none) refuses a gated call 428, `details.reason: 'no_confirmation_service'`: the -person performs it in the app. On a long-lived (stdio) server whose bridge serves -these tools, a client advertising form-mode `elicitation` is asked instead: -`accept` runs it once; decline, dismissal or five minutes unanswered refuse it -(`declined` / `cancelled` / `timed_out`). Over Streamable HTTP nobody is asked. - ---- +`@objectstack/mcp` serves the app at `POST /api/v1/mcp` under the caller's +permissions; each tool describes itself in `tools/list`. + +An action declaring `ai.requiresConfirmation: true` runs only once the person +the agent acts for confirms: + +- **Never send `confirm` to `run_action` or `resume_run`**: such a call is + refused, on every action. (The two delete tools take `confirm: true`.) +- The call is handed to the person, who decides in the app: + `status: 'pending_confirmation'` with a `pendingId` is a success, so relay + its message and do not retry. A host with no pending-confirmation service + (the open build ships none) refuses 428, + `details.reason: 'no_confirmation_service'`: the person performs it in the app. +- On a stdio server whose bridge serves these tools, a client advertising + form-mode `elicitation` is asked instead: `accept` runs the call once; a + decline, a dismissal or five minutes unanswered refuse it (`declined` / + `cancelled` / `timed_out`). Over Streamable HTTP nobody is asked. +- An AI service account's own key is refused at every action door + (`details.reason: 'service_account'`): a person runs the action, or its + author declares `ai.requiresConfirmation: false`. +- **Deciding is the person's own act**, on their signed-in session in the app: + an API key or token (even their own), an AI identity and another user's + `ai:approve` are refused. A script lists the queue and never decides. ## Context packs — one record's material -A context pack (`aiContexts`, `*.ai-context.ts`) lists the fields, related -lists and body of one record that `get_record_context` hands a model, read as -the caller; `requires: ['record-context']` serves the tool. Keys, bounds, pack -names, a skill's `context` over MCP, `os validate` rules: +A context pack (`aiContexts`, `*.ai-context.ts`) is the material of one record +that `get_record_context` hands a model, read as the caller; +`requires: ['record-context']` serves the tool. A skill names its pack in +`context` and binds that tool. All of it: [references/context-packs.md](./references/context-packs.md). ---- - ## Knowledge Sources (RAG) -A RAG source is a **`knowledge_source`** metadata item (`KnowledgeSourceSchema` -in `@objectstack/spec/ai`). Ship it in a package (`knowledgeSources`, -`*.knowledge-source.ts` / `.yml`) or author it in Studio or over MCP; -`KnowledgeServicePlugin({ sources })` and `registerSource` are a second door for -the same schema. A source is identified by its package and `name`; the ☁️ -`search_knowledge` tool lists a package's source to agents as `NAMESPACE-NAME` -(bare for one no package holds). A shipped item mounts the -knowledge service and its store; where an app ships none, a run-time save is -refused (`503 SERVICE_UNAVAILABLE`, nothing written) until you add -`requires: ['knowledge']` to the stack and restart the server. - -**A source is an egress and cost decision.** Its first build sends every listed -field of every matching record to the embedding provider and keeps the text (and -the object's display field, as each title) in an index. A run-time save needs -`manage_knowledge_sources` beside `manage_metadata`, and is refused, naming the -object or field, when you may not search that object or query a field it reads. - -| Key | Purpose | -|:----|:--------| -| `name` | Snake_case source name | -| `label` / `description` | Display metadata | -| `adapter` | Store id (`pgvector`, `turso`, `memory`). Omitted: the deployment's store (`pgvector` on PostgreSQL, `turso` otherwise), else the only one registered; several and none the deployment's is refused, naming them. A run-time save naming a store not mounted is refused (`400`), naming the mounted ones | -| `source.kind` | `'object'`, the one kind | -| `source.object` | The object whose records are indexed | -| `source.content` | Non-empty list of the fields whose text is indexed, in order. `'*'` is refused: it would also send fields added later. Never ids or system fields | -| `source.metadataFields` | Fields kept for search-time filtering (`status`, `owner_id`, `tags`) | -| `source.where` | ObjectQL `where`: keeps drafts and archived rows out | -| `source.split` | How documents are cut into passages (below) | -| `source.retrieval.mode` | `'vector'` (by meaning), `'keyword'` (by words: codes, clause numbers) or `'hybrid'`; omitted: the store's default (`hybrid` on `turso`, `pgvector`). A mode the store lacks fails a run-time save; shipped, every search (503). `memory` runs none | -| `refresh.onRecordChange` | Sync from record events (default `true`); `false` leaves the index to an external indexer | -| `aiExposed` | May `search_knowledge` expose it (default `true`) | - -Retired in 19, each refused with its fix: `id` (use `name`), `contentFields` -(use `content`, listing the fields a `'*'` stood for), `embedding` (the -deployment configures one embedder), `vectorStore` (the store is `adapter`), -`adapterConfig` (an adapter takes plugin options), `refresh.cron` (call -`reindexSource` from a flow or job), and `source.kind: 'file'` / `'http'` with -`prefix`, `mimeTypes`, `urls`, `userAgent` (attachment text: below). `os migrate meta ---from 18` lists a stack's edits; edit a registration in code by hand. - -`os validate` and publish check each source; an error refuses the publish: - -- `knowledge-source-object-unknown`: `source.object` is no object of the stack - or its packages (on the CLI a warning while the manifest declares a - dependency `packages[]` lacks). Name one, or declare and install its package. -- `knowledge-source-field-unknown`: a `content` / `metadataFields` member is no - field of it (`id` and the injected system columns resolve). Fix the - spelling, or remove it. -- `knowledge-source-object-not-searchable`: the API does not serve the object - for `search`. Leave `enable.apiEnabled` on; an `enable.apiMethods` list - must grant `list`, with `enable.searchable` not false. -- `knowledge-source-system-object-not-ai-readable`: a `sys_` object without - `enable.aiReadable: true`. Index a business object. -- `knowledge-source-field-never-indexed` (warning): a credential-class or - `internal: true` member, which the index never carries. Remove it. - ```typescript import { KnowledgeSourceSchema, type KnowledgeSource } from '@objectstack/spec/ai'; export const supportKb: KnowledgeSource = KnowledgeSourceSchema.parse({ name: 'support_kb', - label: 'Support Knowledge Base', + label: 'Support KB', + // adapter: omitted = the deployment's store source: { - kind: 'object', + kind: 'object', // the one kind object: 'kb_article', + // Egress: sent to the embedding provider. Named fields only, never '*'. content: ['title', 'body'], - metadataFields: ['category', 'owner_id'], + metadataFields: ['category'], // search filters where: { published: true }, }, }); ``` -**Sources over business objects**, not only a document library: - -- **Long free text only.** `content` lists prose: an article body, a ticket's - `description`, a note, with its title or subject line. Numbers, dates, - statuses and the names of people or accounts stay out; counts and filters - go to the record tools. "Which customers reported login loops?" is - `search_knowledge`; "how many tickets are open per priority?" is - `aggregate_records` (in-app `ask`: `aggregate_data`). -- **One source per corpus**, and a skill's `instructions` say which to pass in - `sourceIds`: `search_knowledge({ query, sourceIds: ['ticket_bodies'] })` - searches the tickets and not `support_kb`. Omitted, every exposed source is - scanned. -- **Attachment text goes through a field.** A `file` field in `content` adds - no file text. Have the flow, hook or import that extracts the text write it - to a `textarea` field (`contract.attachment_text`), and list that field. - -**Splitting (`split`).** The knowledge service cuts each document into passages -for a store declaring `capabilities.chunks`; any other store receives whole -documents. `split: { strategy, maxChars?, minChars? }` — `strategy` is -required; an omitted `split` means `recursive`: - -- `recursive`: cuts at blank lines, then line breaks, then sentence ends. For - prose. -- `markdown`: one section per heading, each passage embedded with its heading - path. A section that fits `maxChars` with that path is one passage; one that - does not is cut as `recursive` cuts. -- `whole`: one passage per document. For short records only: a document over - the embedder's input budget is removed from the index and reported. - -`maxChars`, the longest passage in characters (`whole` ignores it), overrides -the **Longest passage** setting (`knowledge.chunk_target`, else 800); the -embedder's input limit can lower it. Adjacent pieces shorter than `minChars` -(default 200) are merged in `recursive` text and in a `markdown` section that -does not fit; a section that fits stays whole whatever `minChars` is. Changing -`split` rebuilds the source's whole index, and its searches are refused until -the rebuild finishes. - -Retired: the `knowledge.chunk_overlap` setting (`400 UNKNOWN_KEY`; -passages never overlap) and `KnowledgeChunk.metadata` (parse error; a passage -takes its document's `metadata`). - -`topK` is a `search_knowledge` argument; rerank and leg weights are no source -key. - ---- - -## Tool metadata (`defineTool`) — not the default path - -**Default: declare no tool records.** ADR-0109: a `stack.tools` record "exists only for -AI-presentation refinement (Phase 2: LLM description, parameter narrowing, flow -exposure) and has no runtime reader until that lands" -(`packages/spec/src/stack.zod.ts:595-602`). Author one only to refine how an -existing capability is *presented* — never to add one, and never to make -something executable: `ToolSchema` has no `handler` / `implementation` field, and -no framework executor loads a metadata-authored tool. - -`ToolSchema` is **strict** — an unknown key (a typo, or a retired one) is a parse -error, not a silent strip. Required `name` / `label` / `description` and a JSON -Schema `parameters` object; optional `objectName` and `outputSchema` (⚠️ -experimental — nothing reads it on a tool record; declare the schema as -`ai.outputSchema` on the **action** instead, which the AI runtime ☁️ enforces -by withholding a result that does not conform). Retired in protocol 17: -`category`, `permissions`, `active`, `builtIn` — all authorable and inert — -joining `requiresConfirmation`; each rejection carries its replacement. - -Gate what a tool can do on the underlying action (`action.requiredPermissions`, -ADR-0066) or the objects it touches; to withdraw one, remove it from the skills -referencing it. Categorization belongs on the action (`action.ai.category` — -live, but listing-only: carried onto the tool, never sent to the model). - ---- - -## Model Configuration - -Sampling lives under an agent's `model` (`AIModelConfigSchema`), **never a -top-level `temperature` / `maxTokens`** (`packages/spec/src/ai/agent.zod.ts:89-97`). -The block names a model: the deployment's AI settings choose the provider and -resolve the model name among the ones turned on. `provider` is retired -(protocol 19) and refused, except the `'openai'` an 18.x toolchain wrote out, -which parses and is stripped. Delete it. - -| Key | Contract | -|:--|:--| -| `model` | Optional free-string name; absent = the host's default model | -| `temperature` | Default `0.7`. **Outside 0–2 is a parse error** | -| `maxTokens` / `topP` | Optional, schema-unbounded numbers | - ---- +- **Shipping**: under `knowledgeSources`, or saved in Studio or over MCP. A + shipped source mounts the knowledge service; an app that ships none declares + `requires: ['knowledge']`, or a run-time save is refused (`503`). That save + needs `manage_knowledge_sources` beside `manage_metadata`. +- **`content` is long free text**: a body, a `description`, with its title. + Numbers, dates, statuses and names stay out (counts and filters go to the + record tools, `aggregate_records`), and a `file` field adds no file text: + have the flow, hook or import that extracts it write a `textarea` field, and + list that. +- **One source per corpus**; a skill's `instructions` say which to pass: + `search_knowledge({ query, sourceIds: ['support_kb'] })`. `topK` is that + tool's argument. +- **`split: { strategy: 'markdown', maxChars: 600 }`** cuts the passages: + `recursive` (the default), `markdown` (per heading section) or `whole`. They + never overlap. ## Common Pitfalls -1. **Mistaking `guardrails` for a gate.** `guardrails` is enforced per user turn - by the AI runtime ☁️ — token and time limits, blocked tool names and categories - refused — but it is a limit, not an approval; `memory` is enforced by the AI - runtime ☁️ too (`maxEntries` and `reflectionInterval` are required once - `longTerm.enabled` is true; there is no storage backend to choose), and is - no gate either. For a gate - that is **enforced**, use - `enableActionApproval: true` (approval queue ☁️), `ai.requiresConfirmation` on - the **action** (its door only, pitfall 2), or `approval: 'always'` on an MCP - tool binding. AI metadata edits are already gated: they land as drafts a - human must publish (ADR-0033). There is no `requireApprovalFor` field. +1. **Naming a provider.** Sampling sits under an agent's `model` (`temperature` + 0–2, `maxTokens`); the deployment's AI settings choose the provider, so + delete a `provider` key. `guardrails` ☁️ are limits, no gate. 2. **Gating the action, not the state.** `ai.requiresConfirmation` guards the - action's own door only: an agent can still write the field it changes with - `update_record` or any data write, and the write lands. An irreversible - transition is a gated action **plus a lock on that field**: a `script` - action, whose body writes elevated (`isSystem`), over a field a non-system - write cannot set. `readonly: true` binds every non-system caller (the value - is stripped, **objectstack-data** → `readonly`); a field permission without - `editable` (refused `403`) binds only a caller none of whose sets grants it - with an `editable: true` row; Modify All is no such grant. The body - skips the caller's edit right: declare who may run the action in its - `requiredPermissions` (ADR-0066). A declarative - `operation: 'update'` action, and a `flow` action under `runAs: 'user'`, - write as the caller, so the lock stops them too. `readonlyWhen` and a - `state_machine` rule bind the elevated body as well, so neither is the - door; a `state_machine` dead-end (`closed: []`) still makes the reached - state final for every writer (**objectstack-automation** - `references/state-machines-and-approvals.md`). - ---- - -## Platform agents — reference only ☁️ - -The `agent` type is **closed** to third parties (`allowRuntimeCreate:false`, -`allowEnvironmentOverlay:false`; ADR-0063 §2) and `os g agent` is retired: a -stack-authored agent is filtered out of `listAgents()`, refused outright by -`loadAgent()`, and 404s on chat. - -The runtime ships **exactly two** agents, bound by *surface*. **`ask`** is the -data product: conversational read / query / explore over records -plus running the business actions the app exposes, end-user audience, -RLS-bounded, canonical id `ask` (`ASK_AGENT_NAME`), and the implicit copilot for -any app that does not pin `app.defaultAgent`. **`build`** is the authoring -product: agentic authoring of *metadata* through plan → draft → -verify → publish, builder audience, governance-gated, pinned by Studio via -`app.defaultAgent`. There is **no per-turn intent classifier** — a `build`-shaped -request arriving at `ask` is declined and redirected, never silently re-routed -into authoring (ADR-0063 §1/§5). - -An agent's tool set is the **union of its surface-compatible skills' tools** — -there is no global fall-through (ADR-0064), so `ask` cannot author by -construction; deactivating a skill (`active: false`) revokes that capability for -every agent referencing it. The built-in skills: - -| Skill | `surface` | Owns | -|---|---|---| -| `schema_reader` | `both` | `list_objects`, `describe_object`, `query_data` | -| `data_explorer` | `ask` | `query_records`, `get_record`, `aggregate_data`, `visualize_data` | -| `actions_executor` | `ask` | `action_*` (the business actions an object exposes) | -| `metadata_authoring` + `solution_design` | `build` | metadata draft / verify / publish + blueprint propose / apply | - -None of the four resolves on the open edition, where `surface` / -`triggerConditions` on your own skills are inert and `tools` binds nothing but -is read: `registerSkillPrompts` offers a skill on `prompts/list` / -`prompts/get` only when its server lists every tool the skill binds — a plain -name by that tool, a wildcard by any match, an `action_*` entry also by -`run_action`. That covers the HTTP door and any host server that calls it; the -plugin's own stdio transport lists every skill except one with -`mcpPrompt: false`. That optional key is the owner's opt-out: `false` = written -for the in-product agents only, never offered over MCP on any connection; -absent or `true` = the binding rule above. -`visualize_data` is the only built-in that draws a chart (an inline `data-chart` -part), auto-registered **only** when an analytics service (`IAnalyticsService`) -is wired — `query_data` / `aggregate_data` return numbers, not charts. - -Two `AgentSchema` keys are retired, not legacy options: the strict schema -refuses each as an unknown key, naming -https://objectstack.ai/docs/protocol-upgrade: - -| Retired key | Removed in 17, tombstone gone in 18 — why, and what replaces it | -|:--|:--| -| `agent.tools` | The inline slot resolved names against the *full* registry with no surface check. Not a rename: the strict schema refuses the key as unknown; re-declare each tool in a `defineSkill` under the stack's `skills` (ADR-0064) | -| `agent.knowledge` | Declaring sources/indexes on an agent never scoped retrieval — `search_knowledge` takes `sourceIds` from the model's tool-call arguments. Restrict on the knowledge source (`aiExposed`, `source.where`); name the `sourceIds` to pass in `instructions` (§ Knowledge Sources) | - ---- - -## Verify your work - -After authoring a `*.skill.ts` / `*.tool.ts`, run the -author-time gate before reporting done: - -```bash -os validate # Zod schema + CEL predicate validation + bindings (no artifact) -``` - -This domain has no CEL site — a model-registry `promptTemplate.system` / `.user` is -the `template` dialect (`{{var}}`); `ToolSchema` carries no expression field of -any kind. In a scaffolded project the gate is `npm run validate`. See -objectstack-platform → **Verify your work**. - ---- - -## References - -See [references/_index.md](./references/_index.md) for the full list of Zod -schemas (with one-line descriptions) — pointers into -`node_modules/@objectstack/spec/src/`. Always `Read` the source for exact field -shapes; do not rely on memory of property names. + action's own door: an agent can still write the field with `update_record`, + and it lands. An irreversible transition is the gated action **plus a lock + on its field**: a `script` action (its body writes elevated, `isSystem`) + over a field no non-system write can set. `readonly: true` binds + every non-system caller (**objectstack-data**); a field permission without + `editable` binds only a caller none of whose sets grants `editable: true`, + and Modify All is no such grant. The body skips the caller's edit right: + declare who may run it in `requiredPermissions`. An `operation: 'update'` + action and a `flow` action under `runAs: 'user'` write as the caller, so the + lock stops them too. `readonlyWhen` and a `state_machine` rule bind the + elevated body as well, so neither is the door; a dead-end (`closed: []`) + still makes the state final for every writer (**objectstack-automation**). + +## Where to go + +- The confirmation rule, door by door: `ActionConfirmationRefusalReason` in + `@objectstack/spec/contracts`. +- https://objectstack.ai/docs/ai/ pages: `actions-as-tools` (dispatch, + approval ☁️), `connect-mcp` (clients, stdio, scopes, prompts), + `knowledge-rag` (stores, embedder, retrieval, rebuilds), `agents`. +- The action itself, `app.defaultAgent`: objectstack-ui. Answering as the + connected agent: objectstack-ask. From 6676cb8c34fa20fbef849175c7096a2af0ae6a03 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 07:30:35 +0000 Subject: [PATCH 2/5] docs(skills): the objectstack-ai row is pinned at the router's measurement, with its changeset The entry is 8,998 bytes (185 lines). Its ratchet row moves 7247 -> 2243, pinned at the measurement with no headroom; the sum of all ceilings falls by the same 5,004. The changeset names what the entry keeps, what left it and what answers each cut part now, and the anchors that no longer exist. The "Where to go" list now routes the two platform agents to the published agents page and names objectstack-ask for answering as the connected agent. Claude-Session: https://claude.ai/code/session_01ADHkmSM46qymk97AyqPzoS Co-authored-by: Claude --- .changeset/34770-ai-skill-router.md | 38 ++++++++++++++++++++++++++ scripts/check-skills-token-ratchet.mjs | 21 +++++++++++++- skills/objectstack-ai/SKILL.md | 7 +++-- 3 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 .changeset/34770-ai-skill-router.md diff --git a/.changeset/34770-ai-skill-router.md b/.changeset/34770-ai-skill-router.md new file mode 100644 index 00000000000..0033479cb33 --- /dev/null +++ b/.changeset/34770-ai-skill-router.md @@ -0,0 +1,38 @@ +--- +'@objectstack/skills': patch +--- + +docs(skills): the objectstack-ai entry file becomes a router + +Clause-②: no +Metadata-protocol: none + +`skills/objectstack-ai/SKILL.md` goes from 29.0 KB to 9.0 KB (507 lines to 185). It now holds: four first checks (the installed version wins over the `compatibility` line; read the stack's skills, knowledge sources, context packs, `requires` and its objects' actions, and invent no tool name; read the contract and never recall a key; `os validate` before reporting done), one type-checked skill, the opt-in that makes an Action an AI tool, the confirmation rule of every AI door, the context-pack pointer, one type-checked knowledge source with four rules, two pitfalls, and a list that says where to go for the rest. No rule's teaching changes. No text moved between files: what left the entry was cut, and this entry says what now answers it. `references/context-packs.md` is untouched. + +**What the entry keeps.** Each of these parses, or is accepted, and then does nothing or the wrong thing: + +- A tool record (`defineTool`, `*.tool.ts`) makes nothing executable: the default path is the Action's own opt-in, `ai: { exposed: true, description }`, named in a skill's `tools` as `action_`. +- An opted-in action can still be no tool: `url`, `modal` and `form` are UI-only, and the in-app assistant skips a destructive one (`mode: 'delete'`, `variant: 'danger'`, unless `ai.requiresConfirmation` says otherwise) unless the host runs `enableActionApproval: true`. +- A stack-authored agent is never served: skills are the one extension, `agent.tools` and `agent.knowledge` are refused, and retrieval is scoped on the knowledge source (`aiExposed`, `source.where`). +- A skill's `triggerConditions` route on context the client reports, so they are never access control; over MCP the HTTP door offers a skill's prompt only when the server lists every tool the skill binds. +- An action declaring `ai.requiresConfirmation: true` runs only once the person the agent acts for confirms: `run_action` and `resume_run` refuse a call that carries `confirm`; `status: 'pending_confirmation'` with a `pendingId` is a success that is relayed and not retried; a host with no pending-confirmation service refuses 428 with `details.reason: 'no_confirmation_service'`; a stdio client advertising form-mode `elicitation` is asked in place (`declined` / `cancelled` / `timed_out`); an AI service account's own key is refused `service_account`; and only the person, on their signed-in session in the app, decides a pending item, so a script lists the queue and never decides. +- No page declares an AI button: the shell's 「问 AI」 entry opens the assistant on the current record. +- A knowledge source is an egress decision with named fields only; `content` is long free text, and a `file` field in it adds no file text; one source per corpus, named to `search_knowledge` in `sourceIds`; `split` cuts passages that never overlap; an app that ships no source declares `requires: ['knowledge']`, or a run-time save is refused. +- Sampling sits under an agent's `model`, and the deployment's AI settings choose the provider. +- `ai.requiresConfirmation` guards the action's own door and not the state: the whole of the old pitfall "Gating the action, not the state" stays, under the same title. + +**What left, and what answers it now.** + +- The skill key tables (`name`, `label`, `tools`, `surface`, `description`, `instructions`, `triggerConditions`, `active`, `context`) and the trigger-operator table: the contract, `node_modules/@objectstack/spec/src/ai/skill.zod.ts`. Its docblocks say which edition reads each key, that an incompatible `surface` binding is a load error, that a skill with blank `instructions`, `active: false` or `mcpPrompt: false` is not offered as an MCP prompt, and that the plugin's own stdio server applies no tool-binding filter; `SkillTriggerConditionSchema` refuses a `value` whose shape does not match its `operator`; the strict schema refuses a `permissions` key and a phrase-matching `trigger` key, each with what to write. The entry keeps the five context fields a condition can read. +- The four-rung tool-resolution ladder: `os validate`, whose `ai-skill-tool-unresolved` warning names the unresolved entry and suggests the `action_` spelling. The name lists are `PLATFORM_TOOLS_BY_PACKAGE`, `PLATFORM_PROVIDED_TOOL_NAMES`, `MCP_DOOR_TOOL_NAMES`, `MCP_FILE_TOOL_NAMES` and `PLATFORM_TOOL_FAMILY_PREFIXES`, exported from `@objectstack/spec/system`. +- The in-app `ask` paragraph (a package skill with `surface` `ask` or `both` loads for the app the user is in; a tool it names outside the allow-set is dropped with a diagnostic): cut, with no other home in this repository. It describes the cloud runtime. +- The action dispatch table (`script`, `api`, `flow`) and the Human-in-the-loop paragraph: https://objectstack.ai/docs/ai/actions-as-tools (§ What gets exposed, § Human-in-the-loop approval). The request-body assembly of a `type: 'api'` action (`recordIdParam`, `recordIdField`, `bodyShape`, `bodyExtra`): the contract, `node_modules/@objectstack/spec/src/ui/action.zod.ts`, whose docblocks are the one home of those four keys. That `confirmText` is dialog copy and no destructive signal: objectstack-ui, `rules/actions.md`. The cloud host's plugin options (`apiActionBaseUrl`, `apiActionHeaders`, a custom `apiClient`) and its two predicates (`actionSkipReason`, `actionRequiresApproval`): cut, with no other home in this repository; they belong to the cloud package that exports them. The old text said a queued call answers `{ status: 'pending_approval', pendingActionId }` from an `ai_pending_actions` row: from 19.0.0 every AI door answers `pending_confirmation` with a `pendingId`, and the entry now says that once, for every door. +- The MCP plugin snippet, the two environment switches (`OS_MCP_SERVER_ENABLED`, `OS_MCP_STDIO_ENABLED`) and the tool table: https://objectstack.ai/docs/ai/connect-mcp (§ What the agent gets, § Local stdio transport) and each tool's own description in `tools/list`, which carries the delete-confirmation rule, the `delete_records` preview and cap, and the `run_action` confirmation rule as the server enforces them. The confirmation contract, door by door and reason by reason: `ActionConfirmationRefusalReason` and the docblock above it, in `@objectstack/spec/contracts`. The plugin's `autoStart` option is a typed, documented option of `MCPServerPlugin` in `@objectstack/mcp`; the published page teaches the environment switch. Consuming an external MCP server (`@objectstack/connector-mcp`): objectstack-automation, `references/integration-recipes.md`. +- The knowledge-source key table (`adapter`, `source.metadataFields`, `source.where`, `source.retrieval.mode`, `refresh.onRecordChange`, `aiExposed`), the store-resolution rule, the `NAMESPACE-NAME` spelling of a package's source, and the code door (`KnowledgeServicePlugin({ sources })`, `registerSource`): the contract, `node_modules/@objectstack/spec/src/ai/knowledge-source.zod.ts`, and https://objectstack.ai/docs/ai/knowledge-rag. The keys retired in 19 (`id`, `contentFields`, `embedding`, `vectorStore`, `adapterConfig`, `refresh.cron`, `source.kind: 'file'` / `'http'`): each is refused with its fix, the published page lists them under "Upgrading from 18", and `os migrate meta --from 18` lists a stack's edits. The five `knowledge-source-*` rules: `os validate` and publish, which print each with its fix. The splitting detail (what each strategy cuts at, `maxChars` against the Longest passage setting and the embedder's limit, the `minChars` merge, that a changed `split` rebuilds the index and refuses searches meanwhile): the `KnowledgeSplitSchema` docblock in the same contract file and the published page, § Splitting documents into passages. The retired `knowledge.chunk_overlap` setting and `KnowledgeChunk.metadata`: their refusals; the entry keeps "passages never overlap". That a run-time save is refused when the author may not search the object or query a field: the published page, § Writing a source. +- The tool-record section: the contract, `node_modules/@objectstack/spec/src/ai/tool.zod.ts` (strict; required `name`, `label`, `description`, `parameters`; `outputSchema` marked experimental; the keys retired in 17, each refused with its replacement) and https://objectstack.ai/docs/ai/tools. `ai.outputSchema` and `ai.category` on the action: `ui/action.zod.ts`. +- The model-configuration table: `AIModelConfigSchema` in `node_modules/@objectstack/spec/src/ai/agent.zod.ts` (the `temperature` range and default, the retired `provider` key and the one residue value that still parses). +- From the pitfall on `guardrails`: the `memory` rules (the two numbers required once long-term memory is enabled), which `agent.zod.ts` refuses with a prescription; that there is no `requireApprovalFor` key, which the strict schema refuses. Cut, with no other home in the published skills: that `approval: 'always'` on an MCP tool binding is an enforced gate (the value itself is `MCPApprovalPolicySchema` in `ai/mcp.zod.ts`), and that AI metadata edits land as drafts a person publishes. +- The platform-agents section: https://objectstack.ai/docs/ai/agents (the two agents and the surface each is bound to, that a skill reaches an agent only when their surfaces match, the MCP prompt rule and `mcpPrompt`, `visualize_data`). The table of the built-in skills (`schema_reader`, `data_explorer`, `actions_executor`, `metadata_authoring`, `solution_design`): cut, with no other home in this repository; they are the cloud runtime's. The retired-keys table of `AgentSchema`: the entry keeps that `agent.tools` and `agent.knowledge` are refused; the refusal names the upgrade guide. +- "Verify your work" and "References": first checks 4 and 3. That this domain has no CEL site and that a model-registry prompt template is the `template` dialect: cut from this entry; objectstack-formula teaches the three dialects and that a `template` is not CEL, and the keys that take an expression are typed in the contract. A scaffolded project's `npm run validate` alias is in that project's own `package.json`. + +**Anchors that no longer exist in `SKILL.md`.** `#skill-configuration`, `#naming-the-tools-the-resolution-ladder`, `#skill-example`, `#trigger-conditions`, `#tool-metadata-definetool--not-the-default-path`, `#model-configuration`, `#verify-your-work`, `#references`, and the anchor of the "Platform agents — reference only" heading. The new ones are `#first-checks`, `#skills` and `#where-to-go`. The title's anchor and the anchors of "Actions as AI Tools", "MCP", "Context packs", "Knowledge Sources (RAG)" and "Common Pitfalls" are unchanged: other bundle files send the reader to three of those headings by name. No file in this repository linked an anchor of the old entry. diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index 16a3b73ca8e..516a5aeccf7 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -570,7 +570,26 @@ export const CEILINGS = new Map([ // (the registry's 409 names both doors), and "Rerank and hybrid weighting" // became one clause. Banked at the measurement. // ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) / 4) == ceil(28987 / 4) - ['skills/objectstack-ai/SKILL.md', 7247], + // 7247 -> 2243 (#34770): the entry becomes a router. It keeps four first checks, one + // type-checked skill and one type-checked knowledge source, the traps that parse and then do + // nothing or the wrong thing (a tool record that runs nothing, an opted-in action that is no + // tool, `confirm` sent to `run_action`, a pending answer retried, a script deciding a pending + // item, a `file` field indexed for its text, a gate on the action with no lock on the state) + // and a routing list. The headings three other bundle files point at by name stay: Actions as + // AI Tools, MCP (the elicitation outcomes), Common Pitfalls. Nothing MOVED: + // `references/context-packs.md` takes context-pack text only and already held all of it (row + // below, untouched), so the rest is CUT behind what already says it: the contract + // (`ai/skill.zod.ts`, `ai/tool.zod.ts`, `ai/knowledge-source.zod.ts`, `ai/agent.zod.ts`, whose + // strict shapes refuse a wrong or retired key with the key to write, and the confirmation + // contract in `contracts/ai-service.ts`), `os validate` (`ai-skill-tool-unresolved`, + // `agent-authoring-withdrawn`, the `knowledge-source-*` rules), the MCP door's own tool + // descriptions, or the published AI pages. No row rises and no row is added. The file is + // 29014 bytes (28987 priced) -> 8998 (8971 priced) -> 2243 tokens, pinned AT the + // measurement; the sum of all ceilings falls by the same 5004. + // Authority: the ruling of record that orders the entry file down to router size, decision + // record #34691 S3 = A. + // ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) / 4) == ceil(8971 / 4) + ['skills/objectstack-ai/SKILL.md', 2243], // -12 (was 6331): the `http.server` decision-table row dropped a trailing // clause that taught `contributes.routes` as a key that "parses but serves // nothing". The key is retired — an authored entry is now REFUSED, carrying diff --git a/skills/objectstack-ai/SKILL.md b/skills/objectstack-ai/SKILL.md index 1728863efbf..f922170d8b3 100644 --- a/skills/objectstack-ai/SKILL.md +++ b/skills/objectstack-ai/SKILL.md @@ -179,6 +179,7 @@ export const supportKb: KnowledgeSource = KnowledgeSourceSchema.parse({ `@objectstack/spec/contracts`. - https://objectstack.ai/docs/ai/ pages: `actions-as-tools` (dispatch, approval ☁️), `connect-mcp` (clients, stdio, scopes, prompts), - `knowledge-rag` (stores, embedder, retrieval, rebuilds), `agents`. -- The action itself, `app.defaultAgent`: objectstack-ui. Answering as the - connected agent: objectstack-ask. + `knowledge-rag` (stores, embedder, retrieval, rebuilds), `agents` (`ask`, + `build`). +- The action itself: objectstack-ui. Answering as the connected agent: + objectstack-ask. From 9d96b2841a9dba1f264be59c20c501c36a85bd2e Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 09:12:46 +0000 Subject: [PATCH 3/5] docs(skills): the objectstack-ai changeset names the two facts main added and where the rest of each lives Claude-Session: https://claude.ai/code/session_01ADHkmSM46qymk97AyqPzoS Co-authored-by: Claude --- .changeset/34770-ai-skill-router.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.changeset/34770-ai-skill-router.md b/.changeset/34770-ai-skill-router.md index 0033479cb33..5ce7ed57dca 100644 --- a/.changeset/34770-ai-skill-router.md +++ b/.changeset/34770-ai-skill-router.md @@ -7,7 +7,7 @@ docs(skills): the objectstack-ai entry file becomes a router Clause-②: no Metadata-protocol: none -`skills/objectstack-ai/SKILL.md` goes from 29.0 KB to 9.0 KB (507 lines to 185). It now holds: four first checks (the installed version wins over the `compatibility` line; read the stack's skills, knowledge sources, context packs, `requires` and its objects' actions, and invent no tool name; read the contract and never recall a key; `os validate` before reporting done), one type-checked skill, the opt-in that makes an Action an AI tool, the confirmation rule of every AI door, the context-pack pointer, one type-checked knowledge source with four rules, two pitfalls, and a list that says where to go for the rest. No rule's teaching changes. No text moved between files: what left the entry was cut, and this entry says what now answers it. `references/context-packs.md` is untouched. +`skills/objectstack-ai/SKILL.md` goes from 30.0 KB to 9.0 KB (518 lines to 186). It now holds: four first checks (the installed version wins over the `compatibility` line; read the stack's skills, knowledge sources, context packs, `requires` and its objects' actions; read the contract and never recall a key; `os validate` before reporting done), one type-checked skill, the opt-in that makes an Action an AI tool, the confirmation rule of every AI door, the context-pack pointer, one type-checked knowledge source with four rules, two pitfalls, and a list that says where to go for the rest. No rule's teaching changes. No text moved between files: what left the entry was cut, and this entry says what now answers it. `references/context-packs.md` is untouched. **What the entry keeps.** Each of these parses, or is accepted, and then does nothing or the wrong thing: @@ -15,9 +15,9 @@ Metadata-protocol: none - An opted-in action can still be no tool: `url`, `modal` and `form` are UI-only, and the in-app assistant skips a destructive one (`mode: 'delete'`, `variant: 'danger'`, unless `ai.requiresConfirmation` says otherwise) unless the host runs `enableActionApproval: true`. - A stack-authored agent is never served: skills are the one extension, `agent.tools` and `agent.knowledge` are refused, and retrieval is scoped on the knowledge source (`aiExposed`, `source.where`). - A skill's `triggerConditions` route on context the client reports, so they are never access control; over MCP the HTTP door offers a skill's prompt only when the server lists every tool the skill binds. -- An action declaring `ai.requiresConfirmation: true` runs only once the person the agent acts for confirms: `run_action` and `resume_run` refuse a call that carries `confirm`; `status: 'pending_confirmation'` with a `pendingId` is a success that is relayed and not retried; a host with no pending-confirmation service refuses 428 with `details.reason: 'no_confirmation_service'`; a stdio client advertising form-mode `elicitation` is asked in place (`declined` / `cancelled` / `timed_out`); an AI service account's own key is refused `service_account`; and only the person, on their signed-in session in the app, decides a pending item, so a script lists the queue and never decides. +- An action declaring `ai.requiresConfirmation: true` runs only once the person the agent acts for confirms: `run_action` and `resume_run` refuse a call that carries `confirm` (the delete tools' own `confirm: true` is in their descriptions in `tools/list`); `status: 'pending_confirmation'` with a `pendingId` is a success that is relayed and not retried; a host with no pending-confirmation service refuses 428 with `details.reason: 'no_confirmation_service'`; a stdio client advertising form-mode `elicitation` is asked in place (`declined` / `cancelled` / `timed_out`); an AI service account's own key is refused `service_account`; and only the person, on their signed-in session in the app, decides a pending item, so a script lists the queue and never decides. - No page declares an AI button: the shell's 「问 AI」 entry opens the assistant on the current record. -- A knowledge source is an egress decision with named fields only; `content` is long free text, and a `file` field in it adds no file text; one source per corpus, named to `search_knowledge` in `sourceIds`; `split` cuts passages that never overlap; an app that ships no source declares `requires: ['knowledge']`, or a run-time save is refused. +- A knowledge source is an egress decision with named fields only; `content` is long free text, and a `file` field in it adds no file text; one source per corpus, named to `search_knowledge` in `sourceIds`; `split` cuts passages that never overlap, and an app that cuts its own passages indexes the child records with `strategy: 'whole'` and `documentBy`; an app that ships no source declares `requires: ['knowledge']`; mounted is not enabled, so with no embedder at boot the sources are held (listed, never searched, `search_knowledge` not offered) and `os knowledge status` says why; unmounted or held, a run-time save is refused. - Sampling sits under an agent's `model`, and the deployment's AI settings choose the provider. - `ai.requiresConfirmation` guards the action's own door and not the state: the whole of the old pitfall "Gating the action, not the state" stays, under the same title. @@ -28,10 +28,10 @@ Metadata-protocol: none - The in-app `ask` paragraph (a package skill with `surface` `ask` or `both` loads for the app the user is in; a tool it names outside the allow-set is dropped with a diagnostic): cut, with no other home in this repository. It describes the cloud runtime. - The action dispatch table (`script`, `api`, `flow`) and the Human-in-the-loop paragraph: https://objectstack.ai/docs/ai/actions-as-tools (§ What gets exposed, § Human-in-the-loop approval). The request-body assembly of a `type: 'api'` action (`recordIdParam`, `recordIdField`, `bodyShape`, `bodyExtra`): the contract, `node_modules/@objectstack/spec/src/ui/action.zod.ts`, whose docblocks are the one home of those four keys. That `confirmText` is dialog copy and no destructive signal: objectstack-ui, `rules/actions.md`. The cloud host's plugin options (`apiActionBaseUrl`, `apiActionHeaders`, a custom `apiClient`) and its two predicates (`actionSkipReason`, `actionRequiresApproval`): cut, with no other home in this repository; they belong to the cloud package that exports them. The old text said a queued call answers `{ status: 'pending_approval', pendingActionId }` from an `ai_pending_actions` row: from 19.0.0 every AI door answers `pending_confirmation` with a `pendingId`, and the entry now says that once, for every door. - The MCP plugin snippet, the two environment switches (`OS_MCP_SERVER_ENABLED`, `OS_MCP_STDIO_ENABLED`) and the tool table: https://objectstack.ai/docs/ai/connect-mcp (§ What the agent gets, § Local stdio transport) and each tool's own description in `tools/list`, which carries the delete-confirmation rule, the `delete_records` preview and cap, and the `run_action` confirmation rule as the server enforces them. The confirmation contract, door by door and reason by reason: `ActionConfirmationRefusalReason` and the docblock above it, in `@objectstack/spec/contracts`. The plugin's `autoStart` option is a typed, documented option of `MCPServerPlugin` in `@objectstack/mcp`; the published page teaches the environment switch. Consuming an external MCP server (`@objectstack/connector-mcp`): objectstack-automation, `references/integration-recipes.md`. -- The knowledge-source key table (`adapter`, `source.metadataFields`, `source.where`, `source.retrieval.mode`, `refresh.onRecordChange`, `aiExposed`), the store-resolution rule, the `NAMESPACE-NAME` spelling of a package's source, and the code door (`KnowledgeServicePlugin({ sources })`, `registerSource`): the contract, `node_modules/@objectstack/spec/src/ai/knowledge-source.zod.ts`, and https://objectstack.ai/docs/ai/knowledge-rag. The keys retired in 19 (`id`, `contentFields`, `embedding`, `vectorStore`, `adapterConfig`, `refresh.cron`, `source.kind: 'file'` / `'http'`): each is refused with its fix, the published page lists them under "Upgrading from 18", and `os migrate meta --from 18` lists a stack's edits. The five `knowledge-source-*` rules: `os validate` and publish, which print each with its fix. The splitting detail (what each strategy cuts at, `maxChars` against the Longest passage setting and the embedder's limit, the `minChars` merge, that a changed `split` rebuilds the index and refuses searches meanwhile): the `KnowledgeSplitSchema` docblock in the same contract file and the published page, § Splitting documents into passages. The retired `knowledge.chunk_overlap` setting and `KnowledgeChunk.metadata`: their refusals; the entry keeps "passages never overlap". That a run-time save is refused when the author may not search the object or query a field: the published page, § Writing a source. +- The knowledge-source key table (`adapter`, `source.metadataFields`, `source.documentBy`, `source.where`, `source.retrieval.mode`, `refresh.onRecordChange`, `aiExposed`), the store-resolution rule, that a run-time save needs `manage_knowledge_sources` beside `manage_metadata`, the `NAMESPACE-NAME` spelling of a package's source, and the code door (`KnowledgeServicePlugin({ sources })`, `registerSource`): the contract, `node_modules/@objectstack/spec/src/ai/knowledge-source.zod.ts`, and https://objectstack.ai/docs/ai/knowledge-rag. The keys retired in 19 (`id`, `contentFields`, `embedding`, `vectorStore`, `adapterConfig`, `refresh.cron`, `source.kind: 'file'` / `'http'`): each is refused with its fix, the published page lists them under "Upgrading from 18", and `os migrate meta --from 18` lists a stack's edits. The five `knowledge-source-*` rules: `os validate` and publish, which print each with its fix. The splitting detail (what each strategy cuts at, `maxChars` against the Longest passage setting and the embedder's limit, the `minChars` merge, that a changed `split` rebuilds the index and refuses searches meanwhile): the `KnowledgeSplitSchema` docblock in the same contract file and the published page, § Splitting documents into passages. The retired `knowledge.chunk_overlap` setting and `KnowledgeChunk.metadata`: their refusals; the entry keeps "passages never overlap". That a run-time save is refused when the author may not search the object or query a field: the published page, § Writing a source. The rest of the document-unit rule (which field `documentBy` may name, that setting it rebuilds nothing and newly listing the parent field rebuilds the source in place, that `topK` then counts parents and the parent is the hit's `groupValue`): the `documentBy` docblock in the same contract file and the published page, § An app that cuts its own passages. The rest of the held state (the store half, what a held search and `os knowledge rebuild` answer, the two restarts of the remedy): the published page, § Turning it on, and the refusal itself, which names what is missing. - The tool-record section: the contract, `node_modules/@objectstack/spec/src/ai/tool.zod.ts` (strict; required `name`, `label`, `description`, `parameters`; `outputSchema` marked experimental; the keys retired in 17, each refused with its replacement) and https://objectstack.ai/docs/ai/tools. `ai.outputSchema` and `ai.category` on the action: `ui/action.zod.ts`. - The model-configuration table: `AIModelConfigSchema` in `node_modules/@objectstack/spec/src/ai/agent.zod.ts` (the `temperature` range and default, the retired `provider` key and the one residue value that still parses). -- From the pitfall on `guardrails`: the `memory` rules (the two numbers required once long-term memory is enabled), which `agent.zod.ts` refuses with a prescription; that there is no `requireApprovalFor` key, which the strict schema refuses. Cut, with no other home in the published skills: that `approval: 'always'` on an MCP tool binding is an enforced gate (the value itself is `MCPApprovalPolicySchema` in `ai/mcp.zod.ts`), and that AI metadata edits land as drafts a person publishes. +- The pitfall on `guardrails`: that an agent's `guardrails` and `memory` are limits and no gate is cut from this entry, since a stack does not author an agent; the keys and their prescriptions are in `ai/agent.zod.ts` (the two numbers required once long-term memory is enabled, and no `requireApprovalFor` key, which the strict schema refuses). Cut, with no other home in the published skills: that `approval: 'always'` on an MCP tool binding is an enforced gate (the value itself is `MCPApprovalPolicySchema` in `ai/mcp.zod.ts`), and that AI metadata edits land as drafts a person publishes. - The platform-agents section: https://objectstack.ai/docs/ai/agents (the two agents and the surface each is bound to, that a skill reaches an agent only when their surfaces match, the MCP prompt rule and `mcpPrompt`, `visualize_data`). The table of the built-in skills (`schema_reader`, `data_explorer`, `actions_executor`, `metadata_authoring`, `solution_design`): cut, with no other home in this repository; they are the cloud runtime's. The retired-keys table of `AgentSchema`: the entry keeps that `agent.tools` and `agent.knowledge` are refused; the refusal names the upgrade guide. - "Verify your work" and "References": first checks 4 and 3. That this domain has no CEL site and that a model-registry prompt template is the `template` dialect: cut from this entry; objectstack-formula teaches the three dialects and that a `template` is not CEL, and the keys that take an expression are typed in the contract. A scaffolded project's `npm run validate` alias is in that project's own `package.json`. From 66c16628f1349aace43f6356d501a933ad7a9a94 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 09:26:20 +0000 Subject: [PATCH 4/5] docs(skills): the objectstack-ai entry says no key adds a passage overlap The split rule said only that passages never overlap; an agent asked for a 100-character overlap declined it while saying it could not tell whether a key exists. `KnowledgeSplitSchema` is strict over `strategy`, `maxChars` and `minChars`, so the entry now says no key adds one. Paid for in the same file; 8,997 bytes, row re-pinned at the measurement (2243). Claude-Session: https://claude.ai/code/session_01ADHkmSM46qymk97AyqPzoS Co-authored-by: Claude --- .changeset/34770-ai-skill-router.md | 2 +- scripts/check-skills-token-ratchet.mjs | 12 ++++++------ skills/objectstack-ai/SKILL.md | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.changeset/34770-ai-skill-router.md b/.changeset/34770-ai-skill-router.md index 5ce7ed57dca..7062574d254 100644 --- a/.changeset/34770-ai-skill-router.md +++ b/.changeset/34770-ai-skill-router.md @@ -17,7 +17,7 @@ Metadata-protocol: none - A skill's `triggerConditions` route on context the client reports, so they are never access control; over MCP the HTTP door offers a skill's prompt only when the server lists every tool the skill binds. - An action declaring `ai.requiresConfirmation: true` runs only once the person the agent acts for confirms: `run_action` and `resume_run` refuse a call that carries `confirm` (the delete tools' own `confirm: true` is in their descriptions in `tools/list`); `status: 'pending_confirmation'` with a `pendingId` is a success that is relayed and not retried; a host with no pending-confirmation service refuses 428 with `details.reason: 'no_confirmation_service'`; a stdio client advertising form-mode `elicitation` is asked in place (`declined` / `cancelled` / `timed_out`); an AI service account's own key is refused `service_account`; and only the person, on their signed-in session in the app, decides a pending item, so a script lists the queue and never decides. - No page declares an AI button: the shell's 「问 AI」 entry opens the assistant on the current record. -- A knowledge source is an egress decision with named fields only; `content` is long free text, and a `file` field in it adds no file text; one source per corpus, named to `search_knowledge` in `sourceIds`; `split` cuts passages that never overlap, and an app that cuts its own passages indexes the child records with `strategy: 'whole'` and `documentBy`; an app that ships no source declares `requires: ['knowledge']`; mounted is not enabled, so with no embedder at boot the sources are held (listed, never searched, `search_knowledge` not offered) and `os knowledge status` says why; unmounted or held, a run-time save is refused. +- A knowledge source is an egress decision with named fields only; `content` is long free text, and a `file` field in it adds no file text; one source per corpus, named to `search_knowledge` in `sourceIds`; `split` cuts passages that never overlap (no key adds an overlap), and an app that cuts its own passages indexes the child records with `strategy: 'whole'` and `documentBy`; an app that ships no source declares `requires: ['knowledge']`; mounted is not enabled, so with no embedder at boot the sources are held (listed, never searched, `search_knowledge` not offered) and `os knowledge status` says why; unmounted or held, a run-time save is refused. - Sampling sits under an agent's `model`, and the deployment's AI settings choose the provider. - `ai.requiresConfirmation` guards the action's own door and not the state: the whole of the old pitfall "Gating the action, not the state" stays, under the same title. diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index 222dcc8a6c9..46c7b0f994c 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -620,7 +620,7 @@ export const CEILINGS = new Map([ // 30020 bytes, so the LANDED priced text is 29993 -> ceil(29993 / 4) = 7499; // the row moves +10, the measured remainder only. Pinned AT the measurement. // ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) / 4) == ceil(29993 / 4) - // 7499 -> 2242 (#34770): the entry becomes a router. It keeps four first checks, one + // 7499 -> 2243 (#34770): the entry becomes a router. It keeps four first checks, one // type-checked skill and one type-checked knowledge source, the traps that parse and then do // nothing or the wrong thing (a tool record that runs nothing, an opted-in action that is no // tool, `confirm` sent to `run_action`, a pending answer retried, a script deciding a pending @@ -637,13 +637,13 @@ export const CEILINGS = new Map([ // clause each: mounted is not enabled (held sources, `os knowledge status`), and an app that // cuts its own passages indexes the child records with `documentBy`; the `documentBy` row and // the rest of the held paragraph are the contract's docblock and the published knowledge - // page's. No row rises and no row is added. The file is 30020 bytes (29993 priced) -> 8993 - // (8966 priced) -> 2242 tokens, pinned AT the measurement; the sum of all ceilings falls by - // the same 5257. + // page's. No row rises and no row is added. The file is 30020 bytes (29993 priced) -> 8997 + // (8970 priced) -> 2243 tokens, pinned AT the measurement; the sum of all ceilings falls by + // the same 5256. // Authority: the ruling of record that orders the entry file down to router size, decision // record #34691 S3 = A. - // ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) / 4) == ceil(8966 / 4) - ['skills/objectstack-ai/SKILL.md', 2242], + // ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) / 4) == ceil(8970 / 4) + ['skills/objectstack-ai/SKILL.md', 2243], // -12 (was 6331): the `http.server` decision-table row dropped a trailing // clause that taught `contributes.routes` as a key that "parses but serves // nothing". The key is retired — an authored entry is now REFUSED, carrying diff --git a/skills/objectstack-ai/SKILL.md b/skills/objectstack-ai/SKILL.md index 1520f6e4eeb..82a5016580a 100644 --- a/skills/objectstack-ai/SKILL.md +++ b/skills/objectstack-ai/SKILL.md @@ -128,7 +128,7 @@ export const supportKb: KnowledgeSource = KnowledgeSourceSchema.parse({ source: { kind: 'object', // the one kind object: 'kb_article', - // Egress: sent to the embedding provider. Named fields only, never '*'. + // Egress: sent to the embedding provider. Named fields, never '*'. content: ['title', 'body'], metadataFields: ['category'], where: { published: true }, @@ -151,9 +151,9 @@ export const supportKb: KnowledgeSource = KnowledgeSourceSchema.parse({ `search_knowledge({ query, sourceIds: ['support_kb'] })`. `topK` is that tool's argument. - **`split: { strategy: 'markdown', maxChars: 600 }`**: `recursive` (the - default), `markdown` (per heading section) or `whole`; passages never - overlap. An app cutting its own passages indexes those child records with - `strategy: 'whole'` and `documentBy` (the parent link): + default), `markdown` (per heading) or `whole`. Passages never overlap: no + key adds one. An app cutting its own passages indexes those child records + with `strategy: 'whole'` and `documentBy` (the parent link): `granularity: 'record'` without `groupBy` then answers one hit per parent. ## Common Pitfalls From ef824b4ac5562a9257658e1fa50d5f8ffa86bae1 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 13:01:35 +0000 Subject: [PATCH 5/5] docs(skills): the objectstack-ai entry says confirmText gates no AI call and the pending answer is every AI door's The router listed the two destructive signals and dropped the sentence that `confirmText` is not one, while its routing list named the published actions-as-tools page for approval; that page still lists `confirmText` as a signal and still gives the retired pending answer. `confirmText` on an exposed action parses, no validate rule reads it, and the AI call runs unasked (`actionLooksDestructive` reads `ai.requiresConfirmation`, `mode: 'delete'` and `variant: 'danger'` only). The entry now carries the trap inline, says the pending answer holds at every AI door, and names that page for dispatch only. Paid by wording cuts in the same file: 8,997 -> 8,995 bytes, row re-pinned at the measurement (2243 -> 2242). The changeset no longer says no rule's teaching changes. Claude-Session: https://claude.ai/code/session_01ADHkmSM46qymk97AyqPzoS Co-authored-by: Claude --- .changeset/34770-ai-skill-router.md | 7 ++++--- scripts/check-skills-token-ratchet.mjs | 15 +++++++------- skills/objectstack-ai/SKILL.md | 28 ++++++++++++-------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.changeset/34770-ai-skill-router.md b/.changeset/34770-ai-skill-router.md index 7062574d254..25da9e6017e 100644 --- a/.changeset/34770-ai-skill-router.md +++ b/.changeset/34770-ai-skill-router.md @@ -7,15 +7,16 @@ docs(skills): the objectstack-ai entry file becomes a router Clause-②: no Metadata-protocol: none -`skills/objectstack-ai/SKILL.md` goes from 30.0 KB to 9.0 KB (518 lines to 186). It now holds: four first checks (the installed version wins over the `compatibility` line; read the stack's skills, knowledge sources, context packs, `requires` and its objects' actions; read the contract and never recall a key; `os validate` before reporting done), one type-checked skill, the opt-in that makes an Action an AI tool, the confirmation rule of every AI door, the context-pack pointer, one type-checked knowledge source with four rules, two pitfalls, and a list that says where to go for the rest. No rule's teaching changes. No text moved between files: what left the entry was cut, and this entry says what now answers it. `references/context-packs.md` is untouched. +`skills/objectstack-ai/SKILL.md` goes from 30.0 KB to 9.0 KB (518 lines to 184). It now holds: four first checks (the installed version wins over the `compatibility` line; read the stack's skills, knowledge sources, context packs, `requires` and its objects' actions; read the contract and never recall a key; `os validate` before reporting done), one type-checked skill, the opt-in that makes an Action an AI tool, the confirmation rule of every AI door, the context-pack pointer, one type-checked knowledge source with four rules, two pitfalls, and a list that says where to go for the rest. One sentence of the old entry is corrected (the pending answer, below); no other rule's teaching changes. No text moved between files: what left the entry was cut, and this entry says what now answers it. `references/context-packs.md` is untouched. **What the entry keeps.** Each of these parses, or is accepted, and then does nothing or the wrong thing: - A tool record (`defineTool`, `*.tool.ts`) makes nothing executable: the default path is the Action's own opt-in, `ai: { exposed: true, description }`, named in a skill's `tools` as `action_`. - An opted-in action can still be no tool: `url`, `modal` and `form` are UI-only, and the in-app assistant skips a destructive one (`mode: 'delete'`, `variant: 'danger'`, unless `ai.requiresConfirmation` says otherwise) unless the host runs `enableActionApproval: true`. +- `confirmText` is dialog copy and gates no AI call; `ai.requiresConfirmation: true` does. - A stack-authored agent is never served: skills are the one extension, `agent.tools` and `agent.knowledge` are refused, and retrieval is scoped on the knowledge source (`aiExposed`, `source.where`). - A skill's `triggerConditions` route on context the client reports, so they are never access control; over MCP the HTTP door offers a skill's prompt only when the server lists every tool the skill binds. -- An action declaring `ai.requiresConfirmation: true` runs only once the person the agent acts for confirms: `run_action` and `resume_run` refuse a call that carries `confirm` (the delete tools' own `confirm: true` is in their descriptions in `tools/list`); `status: 'pending_confirmation'` with a `pendingId` is a success that is relayed and not retried; a host with no pending-confirmation service refuses 428 with `details.reason: 'no_confirmation_service'`; a stdio client advertising form-mode `elicitation` is asked in place (`declined` / `cancelled` / `timed_out`); an AI service account's own key is refused `service_account`; and only the person, on their signed-in session in the app, decides a pending item, so a script lists the queue and never decides. +- An action declaring `ai.requiresConfirmation: true` runs only once the person the agent acts for confirms: `run_action` and `resume_run` refuse a call that carries `confirm` (the delete tools' own `confirm: true` is in their descriptions in `tools/list`); at every AI door, `status: 'pending_confirmation'` with a `pendingId` is a success that is relayed and not retried; a host with no pending-confirmation service refuses 428 with `details.reason: 'no_confirmation_service'`; a stdio client advertising form-mode `elicitation` is asked in place (`declined` / `cancelled` / `timed_out`); an AI service account's own key is refused `service_account`; and only the person, on their signed-in session in the app, decides a pending item, so a script lists the queue and never decides. - No page declares an AI button: the shell's 「问 AI」 entry opens the assistant on the current record. - A knowledge source is an egress decision with named fields only; `content` is long free text, and a `file` field in it adds no file text; one source per corpus, named to `search_knowledge` in `sourceIds`; `split` cuts passages that never overlap (no key adds an overlap), and an app that cuts its own passages indexes the child records with `strategy: 'whole'` and `documentBy`; an app that ships no source declares `requires: ['knowledge']`; mounted is not enabled, so with no embedder at boot the sources are held (listed, never searched, `search_knowledge` not offered) and `os knowledge status` says why; unmounted or held, a run-time save is refused. - Sampling sits under an agent's `model`, and the deployment's AI settings choose the provider. @@ -26,7 +27,7 @@ Metadata-protocol: none - The skill key tables (`name`, `label`, `tools`, `surface`, `description`, `instructions`, `triggerConditions`, `active`, `context`) and the trigger-operator table: the contract, `node_modules/@objectstack/spec/src/ai/skill.zod.ts`. Its docblocks say which edition reads each key, that an incompatible `surface` binding is a load error, that a skill with blank `instructions`, `active: false` or `mcpPrompt: false` is not offered as an MCP prompt, and that the plugin's own stdio server applies no tool-binding filter; `SkillTriggerConditionSchema` refuses a `value` whose shape does not match its `operator`; the strict schema refuses a `permissions` key and a phrase-matching `trigger` key, each with what to write. The entry keeps the five context fields a condition can read. - The four-rung tool-resolution ladder: `os validate`, whose `ai-skill-tool-unresolved` warning names the unresolved entry and suggests the `action_` spelling. The name lists are `PLATFORM_TOOLS_BY_PACKAGE`, `PLATFORM_PROVIDED_TOOL_NAMES`, `MCP_DOOR_TOOL_NAMES`, `MCP_FILE_TOOL_NAMES` and `PLATFORM_TOOL_FAMILY_PREFIXES`, exported from `@objectstack/spec/system`. - The in-app `ask` paragraph (a package skill with `surface` `ask` or `both` loads for the app the user is in; a tool it names outside the allow-set is dropped with a diagnostic): cut, with no other home in this repository. It describes the cloud runtime. -- The action dispatch table (`script`, `api`, `flow`) and the Human-in-the-loop paragraph: https://objectstack.ai/docs/ai/actions-as-tools (§ What gets exposed, § Human-in-the-loop approval). The request-body assembly of a `type: 'api'` action (`recordIdParam`, `recordIdField`, `bodyShape`, `bodyExtra`): the contract, `node_modules/@objectstack/spec/src/ui/action.zod.ts`, whose docblocks are the one home of those four keys. That `confirmText` is dialog copy and no destructive signal: objectstack-ui, `rules/actions.md`. The cloud host's plugin options (`apiActionBaseUrl`, `apiActionHeaders`, a custom `apiClient`) and its two predicates (`actionSkipReason`, `actionRequiresApproval`): cut, with no other home in this repository; they belong to the cloud package that exports them. The old text said a queued call answers `{ status: 'pending_approval', pendingActionId }` from an `ai_pending_actions` row: from 19.0.0 every AI door answers `pending_confirmation` with a `pendingId`, and the entry now says that once, for every door. +- The action dispatch table (`script`, `api`, `flow`): https://objectstack.ai/docs/ai/actions-as-tools (§ What gets exposed). The entry names that page for dispatch only: its list of destructive signals still includes `confirmText` and its approval section still gives the retired pending answer, so the entry states both rules itself. The Human-in-the-loop paragraph: the confirmation contract, `ActionConfirmationRefusalReason` and the docblock above it in `@objectstack/spec/contracts`. The request-body assembly of a `type: 'api'` action (`recordIdParam`, `recordIdField`, `bodyShape`, `bodyExtra`): the contract, `node_modules/@objectstack/spec/src/ui/action.zod.ts`, whose docblocks are the one home of those four keys. That `confirmText` is dialog copy and no destructive signal stays in the entry (objectstack-ui, `rules/actions.md`, says the same). The cloud host's plugin options (`apiActionBaseUrl`, `apiActionHeaders`, a custom `apiClient`) and its two predicates (`actionSkipReason`, `actionRequiresApproval`): cut, with no other home in this repository; they belong to the cloud package that exports them. The old text said a queued call answers `{ status: 'pending_approval', pendingActionId }` from an `ai_pending_actions` row: from 19.0.0 every AI door answers `pending_confirmation` with a `pendingId`, and the entry now says that once, for every door. - The MCP plugin snippet, the two environment switches (`OS_MCP_SERVER_ENABLED`, `OS_MCP_STDIO_ENABLED`) and the tool table: https://objectstack.ai/docs/ai/connect-mcp (§ What the agent gets, § Local stdio transport) and each tool's own description in `tools/list`, which carries the delete-confirmation rule, the `delete_records` preview and cap, and the `run_action` confirmation rule as the server enforces them. The confirmation contract, door by door and reason by reason: `ActionConfirmationRefusalReason` and the docblock above it, in `@objectstack/spec/contracts`. The plugin's `autoStart` option is a typed, documented option of `MCPServerPlugin` in `@objectstack/mcp`; the published page teaches the environment switch. Consuming an external MCP server (`@objectstack/connector-mcp`): objectstack-automation, `references/integration-recipes.md`. - The knowledge-source key table (`adapter`, `source.metadataFields`, `source.documentBy`, `source.where`, `source.retrieval.mode`, `refresh.onRecordChange`, `aiExposed`), the store-resolution rule, that a run-time save needs `manage_knowledge_sources` beside `manage_metadata`, the `NAMESPACE-NAME` spelling of a package's source, and the code door (`KnowledgeServicePlugin({ sources })`, `registerSource`): the contract, `node_modules/@objectstack/spec/src/ai/knowledge-source.zod.ts`, and https://objectstack.ai/docs/ai/knowledge-rag. The keys retired in 19 (`id`, `contentFields`, `embedding`, `vectorStore`, `adapterConfig`, `refresh.cron`, `source.kind: 'file'` / `'http'`): each is refused with its fix, the published page lists them under "Upgrading from 18", and `os migrate meta --from 18` lists a stack's edits. The five `knowledge-source-*` rules: `os validate` and publish, which print each with its fix. The splitting detail (what each strategy cuts at, `maxChars` against the Longest passage setting and the embedder's limit, the `minChars` merge, that a changed `split` rebuilds the index and refuses searches meanwhile): the `KnowledgeSplitSchema` docblock in the same contract file and the published page, § Splitting documents into passages. The retired `knowledge.chunk_overlap` setting and `KnowledgeChunk.metadata`: their refusals; the entry keeps "passages never overlap". That a run-time save is refused when the author may not search the object or query a field: the published page, § Writing a source. The rest of the document-unit rule (which field `documentBy` may name, that setting it rebuilds nothing and newly listing the parent field rebuilds the source in place, that `topK` then counts parents and the parent is the hit's `groupValue`): the `documentBy` docblock in the same contract file and the published page, § An app that cuts its own passages. The rest of the held state (the store half, what a held search and `os knowledge rebuild` answer, the two restarts of the remedy): the published page, § Turning it on, and the refusal itself, which names what is missing. - The tool-record section: the contract, `node_modules/@objectstack/spec/src/ai/tool.zod.ts` (strict; required `name`, `label`, `description`, `parameters`; `outputSchema` marked experimental; the keys retired in 17, each refused with its replacement) and https://objectstack.ai/docs/ai/tools. `ai.outputSchema` and `ai.category` on the action: `ui/action.zod.ts`. diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index 46c7b0f994c..2d96caafde5 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -620,10 +620,10 @@ export const CEILINGS = new Map([ // 30020 bytes, so the LANDED priced text is 29993 -> ceil(29993 / 4) = 7499; // the row moves +10, the measured remainder only. Pinned AT the measurement. // ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) / 4) == ceil(29993 / 4) - // 7499 -> 2243 (#34770): the entry becomes a router. It keeps four first checks, one + // 7499 -> 2242 (#34770): the entry becomes a router. It keeps four first checks, one // type-checked skill and one type-checked knowledge source, the traps that parse and then do // nothing or the wrong thing (a tool record that runs nothing, an opted-in action that is no - // tool, `confirm` sent to `run_action`, a pending answer retried, a script deciding a pending + // tool, `confirmText` taken for a gate, `confirm` sent to `run_action`, a pending answer retried, a script deciding a pending // item, a `file` field indexed for its text, a gate on the action with no lock on the state) // and a routing list. The headings three other bundle files point at by name stay: Actions as // AI Tools, MCP (the elicitation outcomes), Common Pitfalls. Nothing MOVED: @@ -637,13 +637,14 @@ export const CEILINGS = new Map([ // clause each: mounted is not enabled (held sources, `os knowledge status`), and an app that // cuts its own passages indexes the child records with `documentBy`; the `documentBy` row and // the rest of the held paragraph are the contract's docblock and the published knowledge - // page's. No row rises and no row is added. The file is 30020 bytes (29993 priced) -> 8997 - // (8970 priced) -> 2243 tokens, pinned AT the measurement; the sum of all ceilings falls by - // the same 5256. + // page's. No row rises and no row is added. The file is 30020 bytes (29993 priced) -> 8995 + // (8968 priced) -> 2242 tokens, pinned AT the measurement; the sum of all ceilings falls by + // the same 5257. (The review round put back that `confirmText` gates no AI call and that the + // pending answer is every AI door's, paid by wording cuts: 8997 -> 8995.) // Authority: the ruling of record that orders the entry file down to router size, decision // record #34691 S3 = A. - // ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) / 4) == ceil(8970 / 4) - ['skills/objectstack-ai/SKILL.md', 2243], + // ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) / 4) == ceil(8968 / 4) + ['skills/objectstack-ai/SKILL.md', 2242], // -12 (was 6331): the `http.server` decision-table row dropped a trailing // clause that taught `contributes.routes` as a key that "parses but serves // nothing". The key is retired — an authored entry is now REFUSED, carrying diff --git a/skills/objectstack-ai/SKILL.md b/skills/objectstack-ai/SKILL.md index 82a5016580a..07116c50b10 100644 --- a/skills/objectstack-ai/SKILL.md +++ b/skills/objectstack-ai/SKILL.md @@ -43,7 +43,7 @@ import { defineSkill } from '@objectstack/spec'; export default defineSkill({ name: 'crm_case_management', label: 'Case Management', - instructions: 'Check for a duplicate case first.', + instructions: 'Check for duplicates first.', tools: ['query_records', 'action_crm_escalate_case'], triggerConditions: [{ field: 'objectName', operator: 'eq', value: 'support_case' }], }); @@ -56,12 +56,11 @@ export default defineSkill({ `'both'`) names the platform agent that takes them. Scope retrieval on the knowledge source (`aiExposed`, `source.where`). - **Every `tools` name resolves** to a platform tool - (`PLATFORM_PROVIDED_TOOL_NAMES` and its siblings in - `@objectstack/spec/system`), an `action_` this stack exposes (or - `action_*`) or a `stack.tools` record, or `os validate` warns - (`ai-skill-tool-unresolved`). Over MCP a skill is its `instructions`, as a - prompt: the HTTP door offers it only when the server lists every tool it - binds. + (`PLATFORM_PROVIDED_TOOL_NAMES`, `@objectstack/spec/system`), an + `action_` this stack exposes (or `action_*`) or a `stack.tools` record, + or `os validate` warns (`ai-skill-tool-unresolved`). Over MCP a skill is its + `instructions`, as a prompt: the HTTP door offers it only when the server + lists every tool it binds. - **`triggerConditions`** ☁️ route on context the client reports (`appName`, `objectName`, `recordId`, `selectionKind`, `userRole`): never access control, and a skill has no `permissions` key. @@ -79,6 +78,8 @@ An Action reaches AI only when it opts in, `ai: { exposed: true, description }` UI-only, and in-app ☁️ a destructive one (`mode: 'delete'`, `variant: 'danger'`, unless `ai.requiresConfirmation` says otherwise) is skipped unless the host runs `enableActionApproval: true`. +- **`confirmText` is dialog copy**: it gates no AI call; + `ai.requiresConfirmation: true` does. - **No page declares an AI button**: the shell's 「问 AI」 entry opens the assistant on the current record. Write no action. @@ -92,7 +93,7 @@ the agent acts for confirms: - **Never send `confirm` to `run_action` or `resume_run`**: such a call is refused, on every action. -- The call is handed to the person, who decides in the app: +- The call is handed to the person, who decides in the app: at every AI door, `status: 'pending_confirmation'` with a `pendingId` is a success, so relay its message and do not retry. A host with no pending-confirmation service (the open build ships none) refuses 428, @@ -145,8 +146,7 @@ export const supportKb: KnowledgeSource = KnowledgeSourceSchema.parse({ - **`content` is long free text**: a body, a `description`, with its title. Numbers, dates, statuses and names stay out (counts and filters go to the record tools, `aggregate_records`), and a `file` field adds no file text: - have the flow, hook or import that extracts it write a `textarea` field, and - list that. + have whatever extracts it write a `textarea` field, and list that. - **One source per corpus**; a skill's `instructions` say which to pass: `search_knowledge({ query, sourceIds: ['support_kb'] })`. `topK` is that tool's argument. @@ -179,8 +179,6 @@ export const supportKb: KnowledgeSource = KnowledgeSourceSchema.parse({ - The confirmation rule, door by door: `ActionConfirmationRefusalReason` in `@objectstack/spec/contracts`. -- https://objectstack.ai/docs/ai/ pages: `actions-as-tools` (dispatch, - approval ☁️), `connect-mcp` (clients, stdio), `knowledge-rag` (stores, - embedder), `agents`. -- The action itself: objectstack-ui. Answering as the connected agent: - objectstack-ask. +- https://objectstack.ai/docs/ai/ pages: `actions-as-tools` (dispatch), + `connect-mcp`, `knowledge-rag`, `agents`. +- The action itself: objectstack-ui. Answering as the agent: objectstack-ask.