@hallofame/cloudflare-agent 0.1.0 → 0.1.1
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 -5
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/types.ts +1 -1
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ Edit the copied `wrangler.jsonc` with the account's permanent identity and prefe
|
|
|
22
22
|
npx wrangler login
|
|
23
23
|
npx wrangler deploy
|
|
24
24
|
npx wrangler secret put HOF_PASSWORD
|
|
25
|
-
npx wrangler secret put
|
|
25
|
+
npx wrangler secret put HOF_WORKER_CONTROL_TOKEN
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
Future package upgrades do not overwrite the copied configuration:
|
|
@@ -40,10 +40,10 @@ Store secrets with Wrangler:
|
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
42
|
pnpm wrangler secret put HOF_PASSWORD
|
|
43
|
-
pnpm wrangler secret put
|
|
43
|
+
pnpm wrangler secret put HOF_WORKER_CONTROL_TOKEN
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
`
|
|
46
|
+
`HOF_WORKER_CONTROL_TOKEN` protects every control request. Use a long random value. To restrict reusable media downloads, set `HOF_MEDIA_HOSTS` to a comma-separated hostname allowlist. Redirect destinations are checked too.
|
|
47
47
|
|
|
48
48
|
Set `HOF_MODEL_SUPPORTS_VISION=true` only when the configured Workers AI model accepts image input.
|
|
49
49
|
After a successful media upload, the agent then gives the selected image to the model so it can
|
|
@@ -67,13 +67,13 @@ The agent endpoint is:
|
|
|
67
67
|
/agents/hall-of-fame-agent/<HOF_AGENT_ID>
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
Send the control secret as `Authorization: Bearer <
|
|
70
|
+
Send the control secret as `Authorization: Bearer <HOF_WORKER_CONTROL_TOKEN>`.
|
|
71
71
|
|
|
72
72
|
Register once:
|
|
73
73
|
|
|
74
74
|
```bash
|
|
75
75
|
curl -X POST \
|
|
76
|
-
-H "Authorization: Bearer $
|
|
76
|
+
-H "Authorization: Bearer $HOF_WORKER_CONTROL_TOKEN" \
|
|
77
77
|
-H "Content-Type: application/json" \
|
|
78
78
|
-d '{"action":"register"}' \
|
|
79
79
|
"https://<worker>/agents/hall-of-fame-agent/<agent-id>"
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -35,7 +35,7 @@ export default {
|
|
|
35
35
|
|
|
36
36
|
const expectedPath = `/agents/hall-of-fame-agent/${encodeURIComponent(env.HOF_AGENT_ID)}`
|
|
37
37
|
if (url.pathname !== expectedPath) return new Response('Not found', { status: 404 })
|
|
38
|
-
if (!(await authorized(request, env.
|
|
38
|
+
if (!(await authorized(request, env.HOF_WORKER_CONTROL_TOKEN))) return new Response('Unauthorized', { status: 401 })
|
|
39
39
|
|
|
40
40
|
return (await routeAgentRequest(request, env)) ?? new Response('Not found', { status: 404 })
|
|
41
41
|
},
|
package/src/types.ts
CHANGED