Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: CI

on:
pull_request:
push:
branches: [main]
tags: ["v*"]

permissions:
contents: read

jobs:
verify:
runs-on: ubuntu-latest
timeout-minutes: 8
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
persist-credentials: false
fetch-depth: 0
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version-file: package.json
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
node-version: 22
- run: bun install --frozen-lockfile
- run: bun run verify
- run: test -z "$(git status --porcelain --untracked-files=all -- dist)"
- name: Verify the installed tarball in Node and Bun
shell: bash
run: |
directory="$RUNNER_TEMP/package"
mkdir -p "$directory"
artifact="$(bun pm pack --ignore-scripts --quiet --destination "$directory")"
(cd "$directory" && sha256sum "$(basename "$artifact")" > SHA256SUMS)
consumer=$(mktemp -d)
cp scripts/check-consumer.mjs "$consumer/"
cd "$consumer"
bun add --ignore-scripts "$artifact"
node check-consumer.mjs
bun check-consumer.mjs
- name: Validate the release tag
if: github.ref_type == 'tag'
shell: bash
run: |
[[ "$GITHUB_REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]
[[ "$GITHUB_REF_NAME" == "v$(node -p "require('./package.json').version")" ]]
git merge-base --is-ancestor HEAD origin/main
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
if: github.ref_type == 'tag'
with:
name: verified-package
path: ${{ runner.temp }}/package/
if-no-files-found: error

release:
if: github.ref_type == 'tag'
needs: verify
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: verified-package
path: package
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
(cd package && sha256sum --check SHA256SUMS)
gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --verify-tag --generate-notes package/*.tgz package/SHA256SUMS
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules/
/*.tgz
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# DeepSeek Durable Objects

Run a DeepSeek agent loop inside a SQLite-backed Cloudflare Durable Object. The package persists native session history, recovers interrupted turns, and resumes parked tool calls. It supports DeepSeek's API and the OpenRouter Messages route.

## Install

```sh
bun add github:checkfu/deepseek-durable-objects#v0.0.1
```

GitHub releases also include an installable tarball and its SHA-256 checksum. Checkfu pins this repository to an exact commit in its Bun catalog.

## Use with a Worker

Import `openDeepSeekSession` from `deepseek-durable-objects`. Construct one runtime per Durable Object. Pass the object's SQLite storage, a stable session ID, the initial model configuration, and a tool host. Keep the provider and model pinned for that runtime.

Call `submit`, `settle`, and `abort` from the host's turn lifecycle. Use the same operation ID when recovering or resuming a turn. Drive recovery from the Durable Object alarm. The host supplies credentials and decides which tools can run, how to publish replies, and how to record usage. Use `withDeepSeekDispatch` from `deepseek-durable-objects/transport` to intercept a model dispatch for accounting.

Add `deepSeekWorkerdBuild` from `deepseek-durable-objects/workerd` to the Worker bundler using Cloudflare's Node compatibility. With Alchemy, load the plugin in the Worker source provider so the build sidecar can resolve it. The [standalone Worker fixture](test/fixtures/worker.mjs) shows the storage and tool interfaces in use.

## Develop

Run `bun install --frozen-lockfile` and `bun run verify`. The checks include the compiled package, direct provider fixtures, and a Workerd restart against the same SQLite Durable Object. Commit the generated `dist/` after changing the source so pinned Git installs can use it directly. To release, update the version and lockfile, merge to `main`, and push the matching `v<version>` tag.
480 changes: 480 additions & 0 deletions bun.lock

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions dist/DeepSeek.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { DeepSeekSessionOptions, DeepSeekTurn, DeepSeekTurnOutcome } from "./Types.ts";
export type { StreamChunk } from "@deepseek-ai/dsh-llm";
export type { DeepSeekStorage } from "./Storage.ts";
export type { DeepSeekSessionOptions, DeepSeekTurn, DeepSeekTurnOutcome } from "./Types.ts";
export declare const openDeepSeekSession: <Request extends DeepSeekTurn, Action extends object>(options: DeepSeekSessionOptions<Request, Action>) => Promise<{
submit: (request: Request, signal: AbortSignal) => Promise<void>;
settle: (request: Request, signal: AbortSignal) => Promise<DeepSeekTurnOutcome<Action> | null>;
abort: (operationId: string) => Promise<boolean>;
}>;
Loading