@familiar-ai/cloudflare 0.0.0 → 0.1.6

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 ADDED
@@ -0,0 +1,55 @@
1
+ # @familiar-ai/cloudflare
2
+
3
+ Runs one Familiar in one SQLite-backed Cloudflare Durable Object. It owns storage, alarms and recovery after eviction. The [development Worker](../../apps/cloudflare/README.md) exercises it with scripted models. See [Host on Cloudflare](https://aidanzealley.github.io/familiar/build/cloudflare/) (publishes once GitHub Pages deployment is enabled).
4
+
5
+ ```sh
6
+ npm install @familiar-ai/core @familiar-ai/cloudflare
7
+ ```
8
+
9
+ Use this package only in Workers. Inside your Durable Object, construct the adapter and forward its alarm:
10
+
11
+ ```ts
12
+ import { DurableObject } from 'cloudflare:workers'
13
+ import { DurableFamiliar } from '@familiar-ai/cloudflare'
14
+ import { createModels } from '@familiar-ai/core/models'
15
+ import {
16
+ fauxProvider,
17
+ fauxAssistantMessage,
18
+ } from '@familiar-ai/core/models/faux'
19
+
20
+ export class Bot extends DurableObject {
21
+ readonly familiar = new DurableFamiliar(this.ctx, {
22
+ familiar: () => {
23
+ const faux = fauxProvider({ models: [{ id: 'demo' }] })
24
+ const models = createModels()
25
+ models.setProvider(faux.provider)
26
+ faux.setResponses([fauxAssistantMessage('Hello from a Worker.')])
27
+ return {
28
+ models,
29
+ model: { provider: 'faux', modelId: 'demo' },
30
+ timeZone: 'Europe/London',
31
+ }
32
+ },
33
+ })
34
+
35
+ override alarm() {
36
+ return this.familiar.alarm()
37
+ }
38
+
39
+ async greet() {
40
+ return this.familiar.use((assistant) =>
41
+ assistant.send({
42
+ author: { id: 'owner', name: 'Sam' },
43
+ text: 'Hello',
44
+ requestId: crypto.randomUUID(),
45
+ }),
46
+ )
47
+ }
48
+ }
49
+ ```
50
+
51
+ This scripted model supplies one response per object opening. A lasting host configures its own provider, credentials, notifications and network policy in the factory. Configure a SQLite Durable Object binding and migration in Wrangler; see the [working configuration](../../apps/cloudflare/wrangler.jsonc).
52
+
53
+ Reach the assistant through `use()` so recovery is armed before work starts, and don't call its `dismiss()`. `terminate()` permanently refuses that object ID while keeping history; `status()` reports lifecycle and alarm state.
54
+
55
+ Local workerd tests cover reminder delivery after eviction, interrupted-reply recovery and persistent termination. ChatGPT sign-in and real-model operation on Workers have not been verified.
package/dist/index.d.ts CHANGED
@@ -1 +1,3 @@
1
1
  export { DurableFamiliar, FamiliarTerminated, type DurableFamiliarOptions, type DurableFamiliarStatus, type HostFamiliarOptions, } from './durable-familiar.ts';
2
+ export { openDurableObjectSqliteStorage, DurableObjectSqliteDatabase, } from '@earendil-works/pi-durable/storage/sqlite/cloudflare';
3
+ export { SqliteStorage, type SqliteStorageOptions, } from '@earendil-works/pi-durable/storage/sqlite';
package/dist/index.js CHANGED
@@ -1 +1,3 @@
1
1
  export { DurableFamiliar, FamiliarTerminated, } from "./durable-familiar.js";
2
+ export { openDurableObjectSqliteStorage, DurableObjectSqliteDatabase, } from '@earendil-works/pi-durable/storage/sqlite/cloudflare';
3
+ export { SqliteStorage, } from '@earendil-works/pi-durable/storage/sqlite';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@familiar-ai/cloudflare",
3
- "version": "0.0.0",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -18,13 +18,14 @@
18
18
  "access": "public"
19
19
  },
20
20
  "peerDependencies": {
21
- "@earendil-works/pi-durable": "1.4.0",
22
- "@familiar-ai/core": "0.0.0"
21
+ "@familiar-ai/core": "0.1.6"
23
22
  },
24
23
  "devDependencies": {
25
24
  "@cloudflare/workers-types": "5.20261023.1",
26
- "@earendil-works/pi-durable": "1.4.0",
27
- "@familiar-ai/core": "0.0.0"
25
+ "@familiar-ai/core": "0.1.6"
26
+ },
27
+ "dependencies": {
28
+ "@earendil-works/pi-durable": "1.4.0"
28
29
  },
29
30
  "scripts": {
30
31
  "typecheck": "tsc",