@moldea.ai/adapter-cloudflare-agents 3.0.0 → 3.0.2
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 +5 -1
- package/docs/binding-example.md +239 -0
- package/docs/evidence-and-diagnostics.md +13 -0
- package/docs/index.md +15 -0
- package/docs/limitations.md +21 -0
- package/docs/verified-targets.md +21 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ The package implements the official `cloudflare-agents` runtime adapter for `@mo
|
|
|
8
8
|
|
|
9
9
|
## Supported targets
|
|
10
10
|
|
|
11
|
-
Version `3.0.
|
|
11
|
+
Version `3.0.2` supports:
|
|
12
12
|
|
|
13
13
|
- Repository Format version `1`
|
|
14
14
|
- `@moldea.ai/core ^4.0.0`
|
|
@@ -71,6 +71,10 @@ Evidence is source-grounded, references existing repository files, and contains
|
|
|
71
71
|
|
|
72
72
|
## Documentation
|
|
73
73
|
|
|
74
|
+
- [Complete binding example](docs/binding-example.md): manifest, canonical instructions, runtime source, and supported schema or routing relationships.
|
|
75
|
+
|
|
76
|
+
These guides are included in the installed package. Open only the page relevant to your task.
|
|
77
|
+
|
|
74
78
|
- [Adapter contract](docs/index.md)
|
|
75
79
|
- [Verified targets](docs/verified-targets.md)
|
|
76
80
|
- [Evidence and diagnostics](docs/evidence-and-diagnostics.md)
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Binding example
|
|
3
|
+
description: Complete manifest and source files for inspecting cloudflare-agents bindings locally.
|
|
4
|
+
order: 5
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Binding example
|
|
8
|
+
|
|
9
|
+
Read this example before searching adapter implementation for binding syntax. It is a complete **static inspection** file set, not a deployment starter or a live provider test. The files are checked together through this adapter and Core without installing or executing the target SDK. Keep application setup, credentials, provider model access, tool execution, and deployment configuration separate.
|
|
10
|
+
|
|
11
|
+
## How the bindings connect
|
|
12
|
+
|
|
13
|
+
Both exported classes are bound separately. Think connects `getSystemPrompt` and the closed `getTools` map; it has no agent input/output schema evidence. AIChatAgent connects its direct `streamText` call and `Output.object` schema. `agentTool` supplies the exact target routing description. Function tools bind `execute`, `inputSchema`, and `outputSchema`. The Markdown imports require the application's Worker text-module configuration; this is not a deployable Worker scaffold.
|
|
14
|
+
|
|
15
|
+
Paths below are repository-root-relative logical paths. Keep the canonical instructions as the policy source. General manifest semantics belong to the [Repository Format specification](https://packages.moldea.ai/repository-format/). Use the other local guides for the full supported boundary and limitations; this example does not expand them.
|
|
16
|
+
|
|
17
|
+
## Files
|
|
18
|
+
|
|
19
|
+
<!-- example:start -->
|
|
20
|
+
|
|
21
|
+
### /moldea/moldea.yaml
|
|
22
|
+
|
|
23
|
+
```yaml
|
|
24
|
+
version: 1
|
|
25
|
+
agents:
|
|
26
|
+
support:
|
|
27
|
+
runtime:
|
|
28
|
+
id: 'cloudflare-agents'
|
|
29
|
+
bindings:
|
|
30
|
+
runtimeAgent:
|
|
31
|
+
path: '/src/agents.ts'
|
|
32
|
+
symbol: 'SupportAgent'
|
|
33
|
+
instructionLoader:
|
|
34
|
+
path: '/src/instructions.ts'
|
|
35
|
+
symbol: 'loadSupportInstruction'
|
|
36
|
+
tools:
|
|
37
|
+
find-order:
|
|
38
|
+
name: 'find_order'
|
|
39
|
+
description: 'Finds an order.'
|
|
40
|
+
implementation:
|
|
41
|
+
path: '/src/implementations.ts'
|
|
42
|
+
symbol: 'findOrder'
|
|
43
|
+
registration:
|
|
44
|
+
path: '/src/tools.ts'
|
|
45
|
+
symbol: 'findOrderTool'
|
|
46
|
+
inputSchema:
|
|
47
|
+
path: '/src/contracts.ts'
|
|
48
|
+
symbol: 'FindOrderInputSchema'
|
|
49
|
+
outputSchema:
|
|
50
|
+
path: '/src/contracts.ts'
|
|
51
|
+
symbol: 'FindOrderOutputSchema'
|
|
52
|
+
summary:
|
|
53
|
+
runtime:
|
|
54
|
+
id: 'cloudflare-agents'
|
|
55
|
+
bindings:
|
|
56
|
+
runtimeAgent:
|
|
57
|
+
path: '/src/agents.ts'
|
|
58
|
+
symbol: 'SummaryAgent'
|
|
59
|
+
instructionLoader:
|
|
60
|
+
path: '/src/instructions.ts'
|
|
61
|
+
symbol: 'loadSummaryInstruction'
|
|
62
|
+
outputSchema:
|
|
63
|
+
path: '/src/contracts.ts'
|
|
64
|
+
symbol: 'SummaryOutputSchema'
|
|
65
|
+
tools:
|
|
66
|
+
find-order:
|
|
67
|
+
name: 'find_order'
|
|
68
|
+
description: 'Finds an order.'
|
|
69
|
+
implementation:
|
|
70
|
+
path: '/src/implementations.ts'
|
|
71
|
+
symbol: 'findOrder'
|
|
72
|
+
registration:
|
|
73
|
+
path: '/src/tools.ts'
|
|
74
|
+
symbol: 'findOrderTool'
|
|
75
|
+
inputSchema:
|
|
76
|
+
path: '/src/contracts.ts'
|
|
77
|
+
symbol: 'FindOrderInputSchema'
|
|
78
|
+
outputSchema:
|
|
79
|
+
path: '/src/contracts.ts'
|
|
80
|
+
symbol: 'FindOrderOutputSchema'
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### /package.json
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"dependencies": {
|
|
88
|
+
"@cloudflare/think": "^0.16.0",
|
|
89
|
+
"@cloudflare/ai-chat": "^0.10.2",
|
|
90
|
+
"agents": "^0.21.0",
|
|
91
|
+
"ai": "^7.0.0",
|
|
92
|
+
"zod": "4.6.4"
|
|
93
|
+
},
|
|
94
|
+
"name": "binding-example",
|
|
95
|
+
"private": true,
|
|
96
|
+
"type": "module"
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### /moldea/project.md
|
|
101
|
+
|
|
102
|
+
```markdown
|
|
103
|
+
# Fixture project
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### /moldea/agents/support/description.md
|
|
107
|
+
|
|
108
|
+
```markdown
|
|
109
|
+
Supports customers.
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### /moldea/agents/support/instruction.md
|
|
113
|
+
|
|
114
|
+
```markdown
|
|
115
|
+
You are the `support` agent.
|
|
116
|
+
|
|
117
|
+
Answer from supplied support facts. Do not invent order status or account information.
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### /moldea/agents/summary/description.md
|
|
121
|
+
|
|
122
|
+
```markdown
|
|
123
|
+
Summarizes requests.
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### /moldea/agents/summary/handoff-description.md
|
|
127
|
+
|
|
128
|
+
```markdown
|
|
129
|
+
Summarizes a support request.
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### /moldea/agents/summary/instruction.md
|
|
133
|
+
|
|
134
|
+
```markdown
|
|
135
|
+
You are the `summary` agent.
|
|
136
|
+
|
|
137
|
+
Summarize the supplied support request without inventing facts.
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### /src/contracts.ts
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
import { z } from 'zod';
|
|
144
|
+
|
|
145
|
+
// response and tool contracts
|
|
146
|
+
export const SummaryOutputSchema = z.object({ summary: z.string() });
|
|
147
|
+
export const FindOrderInputSchema = z.object({ orderId: z.string() });
|
|
148
|
+
export const FindOrderOutputSchema = z.object({
|
|
149
|
+
orderId: z.string(),
|
|
150
|
+
status: z.enum(['shipped', 'not_found']),
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### /src/instructions.ts
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
import supportInstruction from '../moldea/agents/support/instruction.md';
|
|
158
|
+
import summaryInstruction from '../moldea/agents/summary/instruction.md';
|
|
159
|
+
|
|
160
|
+
/** Loads the canonical support text through the Worker text-module loader. */
|
|
161
|
+
export const loadSupportInstruction = () => supportInstruction;
|
|
162
|
+
/** Loads the canonical summary text through the Worker text-module loader. */
|
|
163
|
+
export const loadSummaryInstruction = () => summaryInstruction;
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### /src/implementations.ts
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
/** Looks up an order in the example's fixed catalog. */
|
|
170
|
+
export const findOrder = async ({ orderId }: { orderId: string }) => ({
|
|
171
|
+
orderId,
|
|
172
|
+
status: orderId === 'order-1042' ? ('shipped' as const) : ('not_found' as const),
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### /src/tools.ts
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
import { tool } from 'ai';
|
|
180
|
+
import { FindOrderInputSchema, FindOrderOutputSchema } from './contracts.js';
|
|
181
|
+
import { findOrder } from './implementations.js';
|
|
182
|
+
export const findOrderTool = tool({
|
|
183
|
+
inputSchema: FindOrderInputSchema,
|
|
184
|
+
outputSchema: FindOrderOutputSchema,
|
|
185
|
+
execute: findOrder,
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### /src/agents.ts
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
import { AIChatAgent } from '@cloudflare/ai-chat';
|
|
193
|
+
import { Think } from '@cloudflare/think';
|
|
194
|
+
import { agentTool } from 'agents/agent-tools';
|
|
195
|
+
import { Output, streamText } from 'ai';
|
|
196
|
+
import { SummaryOutputSchema } from './contracts.js';
|
|
197
|
+
import { loadSummaryInstruction, loadSupportInstruction } from './instructions.js';
|
|
198
|
+
import { findOrderTool } from './tools.js';
|
|
199
|
+
|
|
200
|
+
export class SummaryAgent extends AIChatAgent {
|
|
201
|
+
onChatMessage(_onFinish: unknown, _options?: unknown) {
|
|
202
|
+
return streamText({
|
|
203
|
+
model: 'openai/gpt-5',
|
|
204
|
+
prompt: 'Summarize this support request.',
|
|
205
|
+
instructions: loadSummaryInstruction(),
|
|
206
|
+
output: Output.object({ schema: SummaryOutputSchema }),
|
|
207
|
+
tools: { find_order: findOrderTool },
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export const summaryHandoffTool = agentTool(SummaryAgent, {
|
|
213
|
+
description: 'Summarizes a support request.',
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
export class SupportAgent extends Think {
|
|
217
|
+
getSystemPrompt() {
|
|
218
|
+
return loadSupportInstruction();
|
|
219
|
+
}
|
|
220
|
+
getTools() {
|
|
221
|
+
return { find_order: findOrderTool, summarize: summaryHandoffTool };
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### /src/assets.d.ts
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
declare module '*.md' {
|
|
230
|
+
const text: string;
|
|
231
|
+
export default text;
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
<!-- example:end -->
|
|
236
|
+
|
|
237
|
+
## What the check establishes
|
|
238
|
+
|
|
239
|
+
The integration check reads these exact file blocks, requires positive adapter evidence for the documented relationships, and rejects a broken runtime binding. It does not prove that instructions are followed, that every SDK version accepts these forms, or that the application is ready for production. Continue using the installed adapter diagnostics for your actual source.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Evidence and diagnostics
|
|
3
|
+
description: Source-grounded observations and stable Cloudflare adapter failures.
|
|
4
|
+
order: 20
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Evidence and diagnostics
|
|
8
|
+
|
|
9
|
+
Package evidence records exact dependency declarations and whether each declaration is supported or ambiguous for the selected target. Unsupported disjoint ranges produce `CLOUDFLARE_AGENTS_RUNTIME_VERSION_UNSUPPORTED` and suppress target-derived evidence.
|
|
10
|
+
|
|
11
|
+
`agent-definition` identifies a supported exported class. `runtime-pattern` identifies direct AI SDK generation in `AIChatAgent`; Think does not emit it. `instruction-loader`, `schema`, and `tool-registration` require exact manifest binding identity. `handoff-registration` requires an active `agentTool` in a closed tools map, a unique registered target class, and an exact routing-description match against the target agent's handoff description or description fallback.
|
|
12
|
+
|
|
13
|
+
The package README is the canonical package diagnostic catalog. Dynamic or unsupported forms yield partial or no evidence rather than guessed relationships. Unsupported class initialization preserves package and language observations but suppresses all class method-derived results.
|
package/docs/index.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Cloudflare Agents adapter
|
|
3
|
+
description: Package contract, integration model, and public surface.
|
|
4
|
+
order: 0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Cloudflare Agents adapter
|
|
8
|
+
|
|
9
|
+
`@moldea.ai/adapter-cloudflare-agents` is the official source-neutral adapter for the `cloudflare-agents` runtime id. It implements `IRuntimeAdapter`, supports Repository Format version `1`, and exposes only `cloudflareAgentsAdapter`.
|
|
10
|
+
|
|
11
|
+
The adapter inspects TypeScript source through the repository reader supplied by Core. It does not execute source, load Cloudflare packages, inspect `node_modules`, use credentials, or make network requests. Runtime applications register the singleton with `createCore({ adapters: [cloudflareAgentsAdapter] })`; the local CLI registers active official adapters automatically.
|
|
12
|
+
|
|
13
|
+
The [Runtime Compatibility Matrix](https://packages.moldea.ai/compatibility/) is authoritative. This documentation explains the package behavior but does not expand the verified target boundary.
|
|
14
|
+
|
|
15
|
+
Start with the [complete binding example](https://packages.moldea.ai/adapters/cloudflare-agents/binding-example/) when connecting runtime source to canonical instructions, schemas, tools, or routing metadata. The same example ships locally as `docs/binding-example.md` in the installed package.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Boundaries and limitations
|
|
3
|
+
description: Unsupported Cloudflare surfaces, source forms, and the adapter security boundary.
|
|
4
|
+
order: 30
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Boundaries and limitations
|
|
8
|
+
|
|
9
|
+
The current verified targets do not claim support for:
|
|
10
|
+
|
|
11
|
+
- JavaScript, Python, CommonJS, default imports, namespace imports, or source outside TypeScript ESM
|
|
12
|
+
- the bare `Agent` class, custom harnesses, factories, indirect subclasses, re-export graphs, or decorators
|
|
13
|
+
- executable class fields, static blocks, computed member names, generator methods, or non-pass-through constructors
|
|
14
|
+
- dynamic session builders, `onCompaction`, mutable definitions, open tools maps, or channel-provided tool replacement
|
|
15
|
+
- nested generation calls, request variables, `prepareStep` instruction interpretation, or generation APIs other than `generateText` and `streamText`
|
|
16
|
+
- output variants other than `Output.object({ schema })` or any agent input schema
|
|
17
|
+
- dynamic, provider, MCP-generated, or inline tools as manifest registration identities
|
|
18
|
+
- arbitrary compiler resolution, `tsconfig` path aliases, directory indexes, package exports, or general re-export graphs
|
|
19
|
+
- runtime-generated strings, schema-content validation, provider compatibility, model behavior, or actual tool execution
|
|
20
|
+
|
|
21
|
+
Package detection uses nearest manifests, not lockfiles or installed `node_modules`. Each invocation sees one declared agent, exact same-runtime binding resolution, and only the bounded operations Core supplies through `IRuntimeAdapterRepository`. It receives no complete agent collection, project body index, host path, credential, environment variable, network client, or runtime process.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Verified targets
|
|
3
|
+
description: Exact Cloudflare package ranges and statically supported integration patterns.
|
|
4
|
+
order: 10
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Verified targets
|
|
8
|
+
|
|
9
|
+
## Think 0.16 with AI SDK 7
|
|
10
|
+
|
|
11
|
+
The `typescript-think-0-16-ai-sdk-7` target requires `@cloudflare/think >=0.16.0`, `agents >=0.21.0`, and `ai >=7.0.0`.
|
|
12
|
+
|
|
13
|
+
The runtime agent must be a directly exported class extending an exact named `Think` import. Instructions may come from a direct loader call returned by `getSystemPrompt` or from the supported closed `configureSession` chain. Function tools and handoffs must be active in a closed `getTools` map. This target emits no `runtime-pattern` evidence and supports no agent input or output schema binding.
|
|
14
|
+
|
|
15
|
+
## AIChatAgent 0.10 with AI SDK 7
|
|
16
|
+
|
|
17
|
+
The `typescript-ai-chat-agent-0-10-ai-sdk-7` target requires `@cloudflare/ai-chat >=0.10.2`, `agents >=0.21.0`, and `ai >=7.0.0`.
|
|
18
|
+
|
|
19
|
+
The runtime agent must be a directly exported class extending an exact named `AIChatAgent` import. Its supported `onChatMessage(onFinish, options?)` method contains direct `generateText({ ... })` or `streamText({ ... })` calls in its own lexical body. `instructions` takes precedence over `system`; `prepareStep` makes instructions unresolved. Agent output schemas use `Output.object({ schema })`.
|
|
20
|
+
|
|
21
|
+
Both targets require closed class initialization, named ESM imports, normalized `.ts`, `.tsx`, or `.mts` text, and exact relative ESM binding resolution.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moldea.ai/adapter-cloudflare-agents",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "Deterministic runtime evidence and diagnostics for Cloudflare Agents integrations.",
|
|
5
5
|
"homepage": "https://github.com/moldea-ai/packages/tree/main/projects/adapter-cloudflare-agents#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"files": [
|
|
19
19
|
"cover.png",
|
|
20
20
|
"dist",
|
|
21
|
+
"docs",
|
|
21
22
|
"LICENSE",
|
|
22
23
|
"README.md"
|
|
23
24
|
],
|