@proveanything/smartlinks 2.0.9 → 2.0.11
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/dist/ai-tools.d.ts +35 -0
- package/dist/ai-tools.js +69 -0
- package/dist/api/ai.d.ts +7 -12
- package/dist/api/ai.js +2 -10
- package/dist/docs/API_SUMMARY.md +343 -1
- package/dist/docs/agent-tools.md +26 -14
- package/dist/docs/ai.md +79 -0
- package/dist/docs/app-manifest.md +4 -2
- package/dist/docs/host-dependency-contract.md +10 -6
- package/dist/docs/overview.md +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/openapi.yaml +484 -6
- package/dist/shared-dependencies.d.ts +3 -3
- package/dist/shared-dependencies.js +8 -6
- package/dist/types/ai.d.ts +323 -0
- package/dist/types/appManifest.d.ts +1 -1
- package/docs/API_SUMMARY.md +343 -1
- package/docs/agent-tools.md +26 -14
- package/docs/ai.md +79 -0
- package/docs/app-manifest.md +4 -2
- package/docs/host-dependency-contract.md +10 -6
- package/docs/overview.md +1 -1
- package/openapi.yaml +484 -6
- package/package.json +1 -1
package/dist/docs/ai.md
CHANGED
|
@@ -257,6 +257,85 @@ const response = await ai.chat.responses.create('my-collection', {
|
|
|
257
257
|
console.log(response.output);
|
|
258
258
|
```
|
|
259
259
|
|
|
260
|
+
### Server-side tools (built-in agent loop)
|
|
261
|
+
|
|
262
|
+
The example above is **client-relayed** tool calling: you define the tools, the model returns
|
|
263
|
+
`tool_call` requests, and *your app* executes them and sends results back. For the common tools —
|
|
264
|
+
reading and searching the web, vision, reading documents, generating images — the platform ships a
|
|
265
|
+
curated, tested **built-in toolset it runs itself**. Opt in with `server_tools` and the server
|
|
266
|
+
executes each tool and feeds the result back automatically, looping until the model has its answer.
|
|
267
|
+
You get one final response; no relay code.
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
// Enable the whole built-in toolset:
|
|
271
|
+
const res = await ai.chat.responses.create('my-collection', {
|
|
272
|
+
model: 'balanced',
|
|
273
|
+
input: 'Research acme.com and summarise what they sell, with their brand colours.',
|
|
274
|
+
server_tools: true
|
|
275
|
+
});
|
|
276
|
+
console.log(res.output_text);
|
|
277
|
+
console.log(res._agent.toolResults); // trace: which tools ran, with what result
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Scope it to specific tools (recommended — smaller blast radius, faster), by name or capability:
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
import { AI_TOOL_NAMES } from '@proveanything/smartlinks';
|
|
284
|
+
|
|
285
|
+
const res = await ai.chat.responses.create('my-collection', {
|
|
286
|
+
input: 'Find the current price of this product and return it as JSON.',
|
|
287
|
+
server_tools: [AI_TOOL_NAMES.WEB_SEARCH, AI_TOOL_NAMES.DATA_EXTRACT],
|
|
288
|
+
// or: allowCapabilities: ['web:read'], exclude: ['image.generate'],
|
|
289
|
+
maxSteps: 6 // cap model round-trips (1–12, default 8)
|
|
290
|
+
});
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
**Streaming** surfaces tool progress as it happens — ideal for a "thinking…" UI. You get
|
|
294
|
+
`agent.tool_call` / `agent.tool_result` events, then a final `response.completed`:
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
const stream = await ai.chat.responses.create('my-collection', {
|
|
298
|
+
input: 'Research acme.com', server_tools: true, stream: true
|
|
299
|
+
});
|
|
300
|
+
for await (const ev of stream) {
|
|
301
|
+
if (ev.type === 'agent.tool_call') showStep(`Running ${ev.name}…`);
|
|
302
|
+
if (ev.type === 'agent.tool_result') showStep(`${ev.name} done`);
|
|
303
|
+
if (ev.type === 'response.completed') render(ev.response.output_text);
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
`server_tools` can't be combined with `previous_response_id`/`conversation` yet — pass prior turns
|
|
308
|
+
in `input`.
|
|
309
|
+
|
|
310
|
+
#### Built-in tools
|
|
311
|
+
|
|
312
|
+
| Tool | Does |
|
|
313
|
+
|------|------|
|
|
314
|
+
| `web.search` | Live web search → candidate results (url/title/description). |
|
|
315
|
+
| `web.fetchPage` | Fetch a page → clean markdown + metadata + schema.org JSON-LD. |
|
|
316
|
+
| `web.extractSchema` | Return only a page's schema.org data of a given `@type` (deterministic). |
|
|
317
|
+
| `document.read` | Read a document at a URL — **PDF, deck, doc**, or article — into markdown. |
|
|
318
|
+
| `data.extract` | Page + JSON-schema/prompt → **typed JSON** (turn a page into UI data). |
|
|
319
|
+
| `brand.assets` | Extract a site's logo, colours, and design. |
|
|
320
|
+
| `web.screenshot` | Screenshot a page → hosted image URL (feed to `image.describe`). |
|
|
321
|
+
| `image.describe` | Vision: describe an image / read its text. |
|
|
322
|
+
| `image.generate` | Generate an image from a prompt → hosted URL. |
|
|
323
|
+
| `image.fromReference` | Image-to-image: generate guided by reference image(s). |
|
|
324
|
+
| `image.searchStock` | Search real stock photos (Unsplash). |
|
|
325
|
+
| `image.transform` | Resize / crop / rotate / grayscale / format-convert / compress → hosted URL. |
|
|
326
|
+
| `pdf.create` | Render HTML → PDF → hosted URL. |
|
|
327
|
+
| `pdf.fill` | Fill an AcroForm PDF's fields → hosted URL. |
|
|
328
|
+
| `pdf.merge` | Merge several PDFs into one → hosted URL. |
|
|
329
|
+
| `http.request` | SSRF-guarded outbound HTTP(S) to a public URL (call a REST API). |
|
|
330
|
+
| `translate` | Translate text into one or more languages (generic, model-based). |
|
|
331
|
+
|
|
332
|
+
Discover tools two ways:
|
|
333
|
+
- **Design time (typed):** import `BUILTIN_AI_TOOLS`, `AI_TOOL_NAMES`, and the per-tool arg types
|
|
334
|
+
(`WebSearchArgs`, `DataExtractArgs`, …) from the SDK. This is the core set — stable, versioned,
|
|
335
|
+
documented here.
|
|
336
|
+
- **Runtime (live):** `await ai.catalog(collectionId)` returns the registry as the server sees it,
|
|
337
|
+
including any future app-contributed tools. The built-in set above is always present.
|
|
338
|
+
|
|
260
339
|
### Recommended Models
|
|
261
340
|
|
|
262
341
|
For agentic workflows on `v1/responses`, GPT-5.6 ships in three tiers. Pass either the full model
|
|
@@ -42,7 +42,7 @@ The manifest is loaded automatically by the platform for every collection page.
|
|
|
42
42
|
"version": "1.2.0",
|
|
43
43
|
"platformRevision": "R5",
|
|
44
44
|
"moduleFormat": "dual",
|
|
45
|
-
"sharedDependencies": "
|
|
45
|
+
"sharedDependencies": "v6"
|
|
46
46
|
},
|
|
47
47
|
|
|
48
48
|
"admin": "app.admin.json",
|
|
@@ -148,7 +148,7 @@ The manifest is loaded automatically by the platform for every collection page.
|
|
|
148
148
|
| `version` | string | ✅ | SemVer string, e.g. `"1.2.0"` |
|
|
149
149
|
| `platformRevision` | string | ❌ | Platform revision tag this build targets, e.g. `"R5"` (see [host-dependency-contract.md](host-dependency-contract.md)) |
|
|
150
150
|
| `moduleFormat` | `"umd"` \| `"esm"` \| `"dual"` | ❌ | How the host loads this app's bundles. Absent = `"umd"`. See [Module format](#module-format-umd-vs-esm) below. |
|
|
151
|
-
| `sharedDependencies` | string | ❌ | Shared-dependency contract version the bundle was built against, e.g. `"
|
|
151
|
+
| `sharedDependencies` | string | ❌ | Shared-dependency contract version the bundle was built against, e.g. `"v6"`. Used by the host to pick a compatible ESM import map. |
|
|
152
152
|
| `globals` | object | ❌ | Per-app namespaced UMD globals (R4.7+), e.g. `{ "widgets": "MyAppWidgets" }`. UMD-only; ESM bundles don't need it. |
|
|
153
153
|
| `seo.priority` | number | ❌ | Controls which app's `title`/`description`/`ogImage` wins when multiple apps are on the same page. Default `0`; higher wins. See the [Executor guide](executor.md). |
|
|
154
154
|
|
|
@@ -646,6 +646,8 @@ SmartLinks manifests are **AI-discoverable, -configurable, and -importable**: th
|
|
|
646
646
|
|
|
647
647
|
When you change your config shape, keep all three in sync: `app.manifest.json` (widget `settings`, containers, executor, linkable), `app.admin.json` (setup / import / tunable), and `ai-guide.md` (prose guidance).
|
|
648
648
|
|
|
649
|
+
This declarative model is canonical and works today. An app may **optionally** layer agent tools on top — a function that reads the declaration and returns a *context-adapted* result (e.g. "which setup questions for this collection?") — without changing the schema. That's additive and opt-in; see [agent-tools.md](agent-tools.md).
|
|
650
|
+
|
|
649
651
|
## Reading the Files at Runtime
|
|
650
652
|
|
|
651
653
|
### Manifest — available from the widgets endpoint
|
|
@@ -32,7 +32,7 @@ export default defineConfig({
|
|
|
32
32
|
'react', 'react-dom', 'react/jsx-runtime',
|
|
33
33
|
'@proveanything/smartlinks',
|
|
34
34
|
'react-router-dom', '@tanstack/react-query',
|
|
35
|
-
'lucide-react', 'date-fns', 'liquidjs', 'class-variance-authority',
|
|
35
|
+
'lucide-react', 'date-fns', 'liquidjs', 'marked', 'class-variance-authority',
|
|
36
36
|
'@radix-ui/react-slot', '@radix-ui/react-dialog', '@radix-ui/react-popover',
|
|
37
37
|
'@radix-ui/react-tooltip', '@radix-ui/react-tabs', '@radix-ui/react-accordion',
|
|
38
38
|
'@radix-ui/react-select', '@radix-ui/react-scroll-area', '@radix-ui/react-label',
|
|
@@ -44,7 +44,7 @@ export default defineConfig({
|
|
|
44
44
|
'@proveanything/smartlinks': 'SL',
|
|
45
45
|
'react-router-dom': 'ReactRouterDOM', '@tanstack/react-query': 'ReactQuery',
|
|
46
46
|
'lucide-react': 'LucideReact', 'date-fns': 'dateFns', 'liquidjs': 'LiquidJS',
|
|
47
|
-
'class-variance-authority': 'CVA',
|
|
47
|
+
'marked': 'marked', 'class-variance-authority': 'CVA',
|
|
48
48
|
'@radix-ui/react-slot': 'RadixSlot', '@radix-ui/react-dialog': 'RadixDialog',
|
|
49
49
|
'@radix-ui/react-popover': 'RadixPopover', '@radix-ui/react-tooltip': 'RadixTooltip',
|
|
50
50
|
'@radix-ui/react-tabs': 'RadixTabs', '@radix-ui/react-accordion': 'RadixAccordion',
|
|
@@ -71,6 +71,7 @@ export default defineConfig({
|
|
|
71
71
|
| `lucide-react` | `LucideReact` | 1.47 |
|
|
72
72
|
| `date-fns` | `dateFns` | 4.4 |
|
|
73
73
|
| `liquidjs` | `LiquidJS` | 10.27+ |
|
|
74
|
+
| `marked` | `marked` | 12+ |
|
|
74
75
|
| `class-variance-authority` | `CVA` | 0.7 |
|
|
75
76
|
| `@radix-ui/react-slot` | `RadixSlot` | 1.2.4 |
|
|
76
77
|
| `@radix-ui/react-dialog` | `RadixDialog` | 1.1.23 |
|
|
@@ -85,7 +86,10 @@ export default defineConfig({
|
|
|
85
86
|
| `@radix-ui/react-progress` | `RadixProgress` | 1.1.8 |
|
|
86
87
|
| `@radix-ui/react-avatar` | `RadixAvatar` | 1.1.11 |
|
|
87
88
|
|
|
88
|
-
`liquidjs`
|
|
89
|
+
`liquidjs` and `marked` are **host-provided** — externalise them, don't ship a second copy
|
|
90
|
+
(frequently missed). `marked` is new in **contract v6**: the portal and hub render markdown in the
|
|
91
|
+
container, so an app should use the host's renderer rather than bundling its own. `marked` does not
|
|
92
|
+
sanitise HTML — if you render untrusted markdown, sanitise the output (e.g. DOMPurify) yourself.
|
|
89
93
|
|
|
90
94
|
## Backwards compatibility
|
|
91
95
|
|
|
@@ -111,7 +115,7 @@ app ships the Tailwind 4 CSS-first layout as the default; see its README.)
|
|
|
111
115
|
|
|
112
116
|
React **19.3** · Vite **8.3** · react-router-dom **7.18** · Tailwind **4.3** (CSS-first) ·
|
|
113
117
|
TypeScript **6.0** · ESLint **10.11** · `@proveanything/smartlinks` **2.0.5** ·
|
|
114
|
-
`@proveanything/smartlinks-utils-ui` **1.16.4** · liquidjs **10.29
|
|
118
|
+
`@proveanything/smartlinks-utils-ui` **1.16.4** · liquidjs **10.29** · marked **12+**.
|
|
115
119
|
|
|
116
120
|
> **TypeScript 7** (the native/Go compiler) is **deliberately deferred** — tooling hasn't settled.
|
|
117
121
|
> Target **TS 6** for R5; it compiles existing code with no source changes.
|
|
@@ -138,8 +142,8 @@ never drift:
|
|
|
138
142
|
|
|
139
143
|
```ts
|
|
140
144
|
import {
|
|
141
|
-
SHARED_DEPENDENCY_CONTRACT_VERSION, // '
|
|
142
|
-
SHARED_DEPENDENCIES, // [{ specifier, globalName, minVersion, importMapPath }, …] (
|
|
145
|
+
SHARED_DEPENDENCY_CONTRACT_VERSION, // 'v6'
|
|
146
|
+
SHARED_DEPENDENCIES, // [{ specifier, globalName, minVersion, importMapPath }, …] (26)
|
|
143
147
|
SHARED_DEPENDENCY_SPECIFIERS, // bare specifiers — drop straight into a bundler `external` list
|
|
144
148
|
getHostSharedDependencies, // what the live host advertises at runtime, or null
|
|
145
149
|
} from '@proveanything/smartlinks'
|
package/dist/docs/overview.md
CHANGED
|
@@ -60,7 +60,7 @@ The SmartLinks SDK (`@proveanything/smartlinks`) includes comprehensive document
|
|
|
60
60
|
| **Mobile Admin Container** | `docs/mobile-admin-container.md` | Building a separate Capacitor-aware mobile admin bundle for field operators |
|
|
61
61
|
| **Executors** | `docs/executor.md` | Building executor bundles for SEO, LLM content, programmatic config |
|
|
62
62
|
| **Server Functions** | `docs/server-functions.md` | App-authored server-side functions `(ctx, event) ⇒ result`: security model, runtime surface, invoking |
|
|
63
|
-
| **Agent Tools** | `docs/agent-tools.md` | Exposing your app's actions to the SmartLinks agent — an MCP facade over server functions;
|
|
63
|
+
| **Agent Tools** | `docs/agent-tools.md` | Exposing your app's actions to the SmartLinks agent — an MCP facade over server functions; **opt-in per app, additive, no migration**; complements `app.admin.json` (functions serve/adapt it, don't replace it); live loop staged |
|
|
64
64
|
| **Deploying & Registering** | `docs/deploying-apps.md` | Getting your app into the platform: fast dev publish, channels, deploy keys, registering releases |
|
|
65
65
|
| **Host Dependency Contract (R5)** | `docs/host-dependency-contract.md` | The libraries the host provides (React 19, Router 7, Radix, liquidjs, …), the externalise-don't-bundle rule + Vite config, and React-18 backwards-compat |
|
|
66
66
|
| **Deep Linking** | `docs/deep-link-discovery.md` | URL state management, navigable states, portal menus, AI nav |
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export { IframeResponder, isAdminFromRoles, buildIframeSrc, } from './iframeResp
|
|
|
8
8
|
export * as utils from './utils/index.js';
|
|
9
9
|
export { SHARED_DEPENDENCY_CONTRACT_VERSION, SHARED_DEPENDENCIES, SHARED_DEPENDENCY_SPECIFIERS, importMapPathFor, getHostSharedDependencies, } from './shared-dependencies.js';
|
|
10
10
|
export type { SharedDependency, HostSharedDependencies } from './shared-dependencies.js';
|
|
11
|
+
export { AI_TOOL_NAMES, BUILTIN_AI_TOOLS, getBuiltinAiTool } from './ai-tools.js';
|
|
12
|
+
export type { BuiltinAiToolDescriptor } from './ai-tools.js';
|
|
11
13
|
export type { PortalPathParams, Gs1DigitalLinkParams, ConditionParams, ConditionDebugOptions, ConditionDebugLogger, ConditionSet, Condition, UserInfo, ProductInfo, ProofInfo, CollectionInfo, } from './utils/index.js';
|
|
12
14
|
export type { LoginResponse, VerifyTokenResponse, AccountInfoResponse, AuthLocation, } from "./api/auth.js";
|
|
13
15
|
export type { UserAccountRegistrationRequest, } from "./types/auth.js";
|
package/dist/index.js
CHANGED
|
@@ -13,4 +13,6 @@ import * as utils_1 from './utils/index.js';
|
|
|
13
13
|
export { utils_1 as utils };
|
|
14
14
|
// Shared dependency contract (host↔app) — one source of truth for externalized deps
|
|
15
15
|
export { SHARED_DEPENDENCY_CONTRACT_VERSION, SHARED_DEPENDENCIES, SHARED_DEPENDENCY_SPECIFIERS, importMapPathFor, getHostSharedDependencies, } from './shared-dependencies.js';
|
|
16
|
+
// Built-in AI tool catalog (design-time discovery of the core agentic toolset)
|
|
17
|
+
export { AI_TOOL_NAMES, BUILTIN_AI_TOOLS, getBuiltinAiTool } from './ai-tools.js';
|
|
16
18
|
export { HostCapabilityUnavailableError, HostPermissionDeniedError, HostTimeoutError, } from './mobile-admin/errors.js';
|