Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 64 additions & 28 deletions .claude/skills/objectstack-ai/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ license: Apache-2.0
compatibility: Requires @objectstack/spec 19.x (Zod v4 schemas)
metadata:
author: objectstack-ai
version: "19.0.0-next.2"
version: "19.0.0-next.3"
domain: ai
tags: agent, tool, skill, knowledge, context-pack, llm, embedding, mcp
---
Expand Down Expand Up @@ -239,10 +239,10 @@ in `@objectstack/spec/ai`). Ship it in a package (`knowledgeSources`,
`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), and a code registration and an environment
item of one name are one slot, the second refused. A shipped item mounts the
knowledge service and its store; an app that ships none and authors sources at
run time needs `requires: ['knowledge']`, or its items are never indexed.
(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
Expand All @@ -252,15 +252,16 @@ object or field, when you may not search that object or query a field it reads.

| Key | Purpose |
|:----|:--------|
| `name` | Snake_case source name; with the package, its identity |
| `name` | Snake_case source name |
| `label` / `description` | Display metadata |
| `adapter` | Optional 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 |
| `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: embedding is egress, and a wildcard also sent fields added later. Meaningful text only, never ids or system fields; credential-class and `internal` fields are never 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`) |

Expand All @@ -269,17 +270,33 @@ Retired in 19, each refused with its fix: `id` (use `name`), `contentFields`
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` (no form in 19). `os migrate meta
`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.

<!-- os:check -->
```typescript
import { KnowledgeSourceSchema, type KnowledgeSource } from '@objectstack/spec/ai';

export const supportKb: KnowledgeSource = KnowledgeSourceSchema.parse({
name: 'support_kb',
label: 'Support Knowledge Base',
source: { // no adapter: the deployment's store
source: {
kind: 'object',
object: 'kb_article',
content: ['title', 'body'],
Expand All @@ -289,31 +306,49 @@ export const supportKb: KnowledgeSource = KnowledgeSourceSchema.parse({
});
```

**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
once `split` is written; an omitted `split` means `recursive`:
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. For documents with headings.
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, never
truncated.
the embedder's input budget is removed from the index and reported.

`maxChars`, the longest passage in characters (`whole` ignores it), overrides
the **Target chunk size** setting (`knowledge.chunk_target`, else 800); the
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. Changing `split` re-splits a document only when it
next changes.
(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 and refused: the `knowledge.chunk_overlap` setting (`400 UNKNOWN_KEY`;
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 hybrid weighting are no
source key, and no shipped store has a setting for either.
`topK` is a `search_knowledge` argument; rerank and leg weights are no source
key.

---

Expand Down Expand Up @@ -346,15 +381,16 @@ 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:87-95`).
The block names a model, never a provider: the deployment's AI settings choose
the provider and resolve the model name among the providers turned on.
`provider` is retired (protocol 19): writing it is a parse error. Delete it.
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 model name; absent = the host's default model for the environment |
| `temperature` | `min(0).max(2)`, default `0.7`. **Outside 0–2 is a parse error** |
| `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 |

---
Expand Down Expand Up @@ -443,7 +479,7 @@ 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`); describe intended grounding in `instructions` |
| `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) |

---

Expand Down
32 changes: 27 additions & 5 deletions .claude/skills/objectstack-ai/evals/skills-tools-knowledge.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,21 @@
{
"id": 2,
"prompt": "Our copilot should use Anthropic with a low temperature (0.3) and cap responses at 2000 tokens. Where do these settings go in the metadata?",
"expected_output": "Places sampling under the agent's `model` block (`AIModelConfigSchema`): `temperature: 0.3` (0–2, outside is a parse error) and `maxTokens: 2000`, and states that there is no top-level `temperature` / `maxTokens` on an agent. Writes no provider key: `provider` is retired in protocol 19 and a parse error, because the deployment's AI settings choose the provider, not the agent. To run on an Anthropic model, names that model in the free-string `model` (the deployment resolves the name among the providers turned on) or omits it to run on the host's default model; turning Anthropic on is done in the deployment's AI settings, not in metadata.",
"expected_output": "Places sampling under the agent's `model` block (`AIModelConfigSchema`): `temperature: 0.3` (0–2, outside is a parse error) and `maxTokens: 2000`, and states that there is no top-level `temperature` / `maxTokens` on an agent. Writes no provider key: `provider` is retired in protocol 19 and refused, because the deployment's AI settings choose the provider, not the agent. To run on an Anthropic model, names that model in the free-string `model` (the deployment resolves the name among the providers turned on) or omits it to run on the host's default model; turning Anthropic on is done in the deployment's AI settings, not in metadata.",
"files": [],
"assertions": {
"must_contain": ["temperature", "maxTokens", "deployment"],
"must_not_contain": ["provider: 'anthropic',"]
"must_not_contain": [
"provider: 'anthropic',",
"provider: \"anthropic\",",
"provider: 'anthropic'\n",
"provider: \"anthropic\"\n",
"provider: 'anthropic' }",
"provider: \"anthropic\" }",
"provider: 'anthropic'}",
"provider: \"anthropic\"}",
"\"provider\": \"anthropic\""
]
}
},
{
Expand Down Expand Up @@ -58,7 +68,7 @@
"expected_output": "Does not decide on the token: the script may list the queue (`client.ai.pendingActions.list({ status: 'pending' })`), but approving or rejecting an item is the person's own act, done in the app on their signed-in session by the person the assistant call ran as. An API key or token is refused on the decide door, even the person's own, and so is an AI identity; another user's `ai:approve` does not decide the item, and the model's own confirmation does not count. The script reports or notifies the stale items instead; where a second person must approve the write, that is the approvals engine's `held` outcome.",
"files": [],
"assertions": {
"must_contain_any": [["ai:approve", "signed-in session", "refused", "never decides"]],
"must_contain_any": [["ai:approve", "signed-in session", "refused", "refuses", "never decides"]],
"must_not_contain": ["pendingActions.approve("]
}
},
Expand All @@ -68,7 +78,8 @@
"expected_output": "Stop sending `confirm`: `run_action` and `resume_run` refuse any call that carries the member, on every action, because the agent cannot confirm for the person. Call `run_action({ actionName: 'crm_close_deal', recordId })` without it. Where the host registers a pending-confirmation service, the answer is `status: 'pending_confirmation'` with a `pendingId` and a message: that is a success, not an error, and nothing has run. Relay the message, tell the user to approve it in the app, and do not retry. On a host with no such service (the open-source build ships none) the call is refused 428 `ACTION_CONFIRMATION_REQUIRED` with `details.reason: 'no_confirmation_service'`, and the person performs the action in the app. The two delete tools still take the member.",
"files": [],
"assertions": {
"must_contain": ["pending_confirmation", "pendingId", "no_confirmation_service", "do not retry"],
"must_contain": ["pending_confirmation", "pendingId", "no_confirmation_service"],
"must_contain_any": [["do not retry", "Do not retry", "don't retry", "Don't retry"]],
"must_not_contain": ["recordId, confirm: true", "then retry with"]
}
},
Expand Down Expand Up @@ -136,12 +147,23 @@
{
"id": 14,
"prompt": "Our app ships no knowledge source in its package: admins will create them at run time in Studio, and an agent of ours saves them over MCP. What does `objectstack.config.ts` need so those sources are indexed and searchable? Answer from what is stated here.",
"expected_output": "Adds `requires: ['knowledge']` to the stack: a source the app ships in `knowledgeSources` mounts the knowledge service and its store by itself, but an app that ships none and authors its sources at run time must list the token, or a saved source is never indexed and no search tool serves it. Names no `adapter` requirement (the deployment's store is used) and adds no `knowledgeSources` entry the prompt did not ask for. Says that creating or changing a source at run time needs `manage_knowledge_sources` beside `manage_metadata`.",
"expected_output": "Adds `requires: ['knowledge']` to the stack: a source the app ships in `knowledgeSources` mounts the knowledge service and its store by itself, but an app that ships none and authors its sources at run time must list the token, or a run-time save is refused (`503 SERVICE_UNAVAILABLE`, nothing written) until the stack declares it and the server restarts. Names no `adapter` requirement (the deployment's store is used) and adds no `knowledgeSources` entry the prompt did not ask for. Says that creating or changing a source at run time needs `manage_knowledge_sources` beside `manage_metadata`.",
"files": [],
"assertions": {
"must_contain_any": [["requires: ['knowledge']", "requires: [\"knowledge\"]"]],
"must_not_contain": ["contentFields:"]
}
},
{
"id": 15,
"prompt": "Our support app has `kb_article` (`title`, `body`) and `support_ticket` (`subject`, `description` as a textarea, `priority`, `status`, `amount`, and a `contract_pdf` file field holding a signed PDF). The assistant should answer from article bodies, from ticket descriptions and from what the PDFs say, and also tell us how many open tickets there are per priority. Design the knowledge sources and say how a skill should search them. None of the project's files are in this directory: write the files in your answer.",
"expected_output": "Writes two `knowledge_source` items, one per corpus (articles, tickets), each `source: { kind: 'object', … }` with an explicit `content` list of long free-text fields only: `title` / `body` for articles, `subject` / `description` for tickets. `priority`, `status` and `amount` are not in `content` (at most `metadataFields`), and the count of open tickets per priority is answered by a record tool (`aggregate_records` / `query_records`), not by `search_knowledge`. The PDF is not indexed from the `contract_pdf` file field and no `kind: 'file'` or `'http'` source is written (both retired): the extracted text is first written to a text field on the record (a `textarea`, filled by a flow, hook or import) and that field is listed in `content`. The skill's `instructions` tell the model which source to search by passing `sourceIds` to `search_knowledge`, so a question does not scan every source; no second argument shape and no `knowledge` key on the skill is invented.",
"files": [],
"assertions": {
"must_contain": ["sourceIds", "content:", "textarea"],
"must_contain_any": [["aggregate_records", "query_records", "aggregate_data"]],
"must_not_contain": ["kind: 'file',", "kind: \"file\",", "kind: 'http',", "kind: \"http\",", "contentFields:", "content: ['priority'", "content: ['status'", "content: ['amount'", "content: ['contract_pdf'", "'description', 'priority'", "'description', 'status'", "'description', 'amount'", "'description', 'contract_pdf'"]
}
}
]
}
Loading