page-agent-sdk 2.6.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/dist/page-agent-sdk.iife.js +70 -68
- package/dist/page-agent-sdk.js +107 -106
- package/dist/page-agent-sdk.umd.cjs +18 -16
- package/package.json +1 -1
- package/skills/page-agent-sdk-integrate/SKILL.md +1 -1
- package/skills/page-agent-sdk-integrate/references/api.md +1 -1
- package/skills/page-agent-sdk-integrate/references/options.md +1 -1
- package/types/index.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "page-agent-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "框架无关的页面内 Agent JS SDK —— 以对话框形态挂载到任意网页,通过自定义 tool 读写宿主预注册的数据槽(经 schema 校验 + jsonPath 增量 patch + 快照回退;GET 抓文档),具备 planning/skills/虚拟工作区/context 管理能力。Vue 打包进库,使用者无需安装 Vue。",
|
|
6
6
|
"main": "./dist/page-agent-sdk.umd.cjs",
|
|
@@ -27,7 +27,7 @@ See `demo/plain.html` for a framework-agnostic importmap + esm.sh example.
|
|
|
27
27
|
|
|
28
28
|
Create a plain/reactive object as the main data, then declare it with a zod schema. The agent can ONLY touch schema-declared top-level fields (ZodObject auto-whitelist); `set`/`edit` are schema-validated (invalid → structured error, no write). Field `.describe()` text is auto-injected into the system prompt so the LLM knows each field's purpose.
|
|
29
29
|
|
|
30
|
-
> `systemPrompt` is optional — a built-in default is used if omitted (generic JSON-operation assistant + `systemPromptHelpers.reliableWriteRules`: read-before-write, fields per `describe`, retry on validation error, prefer incremental `edit`). Passing your own fully overrides it.
|
|
30
|
+
> `systemPrompt` is optional — a built-in default is used if omitted (generic JSON-operation assistant + `systemPromptHelpers.reliableWriteRules`: read-before-write, fields per `describe`, retry on validation error, prefer incremental `edit`). Passing your own fully overrides it. By default (`appendReliableWriteRules: true`, the default), the SDK auto-appends `reliableWriteRules` to your custom `systemPrompt` with a `---` separator (clearly distinguishing your content from the SDK-appended write rules); set `appendReliableWriteRules: false` to disable.
|
|
31
31
|
|
|
32
32
|
```ts
|
|
33
33
|
import { createChatSdk, z } from 'page-agent-sdk'
|
|
@@ -74,7 +74,7 @@ createChatSdk({
|
|
|
74
74
|
|
|
75
75
|
`reliableWriteRules` — standardized "reliable write rules": read before write (`read`), fields per `read({jsonPath})` (returns format hint), retry on schema-validation errors, prefer `write` with `patch` incremental edits. Recommended for any scenario involving data writes.
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
By default (`appendReliableWriteRules: true`), the SDK auto-appends `reliableWriteRules` to your custom `systemPrompt` with a `---` separator (clearly distinguishing your content from the SDK-appended write rules); set `appendReliableWriteRules: false` to disable. The default prompt (when `systemPrompt` omitted) already includes them.
|
|
78
78
|
|
|
79
79
|
## Built-in data tools (auto-injected when `capabilities.dataOps`)
|
|
80
80
|
|
|
@@ -8,7 +8,7 @@ Full reference for `createChatSdk(options)`. Grouped by purpose. Required: `llm`
|
|
|
8
8
|
|---|---|---|---|
|
|
9
9
|
| `llm` | `LLMConfig \| BaseChatModel` | — (required) | The model. `LLMConfig = { apiKey, baseUrl, model, temperature?, maxTokens? }` (OpenAI-compatible; DeepSeek default). Or pass any LangChain `BaseChatModel` (e.g. `ChatAnthropic`, install its peerDep). |
|
|
10
10
|
| `systemPrompt` | `string` | built-in default (JSON-operation assistant + reliable write rules) | Agent identity/instructions. Inject here, not hardcoded. Keep single-line in `.env` (`VITE_AI_SYSTEM_PROMPT`). If omitted, a built-in default is used (JSON-operation assistant + `systemPromptHelpers.reliableWriteRules`); passing your own fully overrides it. |
|
|
11
|
-
| `appendReliableWriteRules` | `boolean` | `
|
|
11
|
+
| `appendReliableWriteRules` | `boolean` | `true` | When `true` (default) and a custom `systemPrompt` is set, auto-append `systemPromptHelpers.reliableWriteRules` to it with a `---` separator (clearly distinguishes user content from SDK-appended write rules; avoids forgetting the write rules). Set `false` to disable. No effect when `systemPrompt` is omitted (default prompt already includes them). |
|
|
12
12
|
| `id` | `string` | random + warn | Stable agent id for multi-agent isolation & persistence. **Must pass a stable value** if you use `storage` or run multiple agents on one page. |
|
|
13
13
|
| `title` / `placeholder` | `string` | — | Dialog title / input placeholder (cosmetic). |
|
|
14
14
|
|
package/types/index.d.ts
CHANGED
|
@@ -340,7 +340,7 @@ export interface ChatSdkOptions {
|
|
|
340
340
|
/** 共享上下文:默认 false;true 时同 id 复用同一核心(messages/agent/工作区) */
|
|
341
341
|
shareContext?: boolean;
|
|
342
342
|
systemPrompt?: string;
|
|
343
|
-
/** 自定义 systemPrompt 时是否自动追加 reliableWriteRules(默认 false
|
|
343
|
+
/** 自定义 systemPrompt 时是否自动追加 reliableWriteRules(默认 true,用 '---' 分隔线区分;设 false 关闭;不传 systemPrompt 用默认 prompt 时已内置,此项无效) */
|
|
344
344
|
appendReliableWriteRules?: boolean;
|
|
345
345
|
tools?: any[];
|
|
346
346
|
skills?: SkillSpec[];
|