DeepSeek Harness PWA Sync 3 Core Phases

Building an open source PWA sidebar sync for bluusun.com's DeepSeek access layer starts with three sequential phases. Phase one is the client shell: a service worker with a stale-while-revalidate caching strategy, a manifest with standalone display mode, and an installable sidebar that docks via the Side Panel API in Chromium-based browsers. The sidebar holds conversation state in IndexedDB so it survives offline sessions and rehydrates when connectivity returns. Phase two is the sync engine itself. A CRDT approach, using something like Yjs, lets the same conversation history reconcile across a phone and a desktop install without a central conflict resolver, which matters when a user closes the panel mid-stream on one device. Phase three is the relay: a thin sync server, deployable on a free-tier host, that stores encrypted blobs keyed by a device-generated token rather than an account email.

Also worth reading: How to render HTML previews in the ask_user_question plugin for DeepSeek Harness? · How to run Claude legal harness locally on DeepSeek-V4.1-Flash? · Why does DeepSeek Harness count tokens differently?

The realistic failure point is phase two. CRDT merge logic for streaming chat output is genuinely hard because partial assistant messages arrive as deltas, and merging two divergent partial streams can produce garbled text that no user will forgive. A pragmatic compromise is to treat each completed message as the sync unit and let in-flight generations stay device-local. Ship the sync server as a Docker image with a single environment variable for the bluusun endpoint, and the project becomes forkable in an afternoon rather than a weekend.

OpenAI Compatible API Integration Mechanics

The integration surface is deliberately boring, which is a feature. Bluusun exposes an OpenAI-compatible endpoint, so the sidebar client uses the standard chat completions schema: a POST with model, messages, temperature, and stream flags, and server-sent events streaming back token deltas. That compatibility means existing SDKs, from the official openai npm package to LiteLLM proxies, work without modification. The engineering work concentrates on streaming resilience: reconnection with a Last-Event-ID cursor, abort controllers wired to the sidebar's close button, and graceful handling when the upstream model provider truncates a response mid-token.

The honest caveat is that "OpenAI-compatible" is a spectrum, not a guarantee. Tool calling schemas, logprobs, and JSON mode enforcement vary across DeepSeek and GLM backends, and a client that assumes full parity will break in ways that only surface in production. The sidebar should ship a capability probe on first load: a lightweight request that tests function calling and structured output, then degrades the UI accordingly. Version pinning matters too. If bluusun updates its gateway and a field like finish_reason changes shape, a pinned client version with a documented changelog turns a silent breakage into a visible, fixable diff.

GLM Model Routing Configuration Steps

Routing between DeepSeek and GLM on the same key is where the sidebar earns its keep. Step one: define a routing table in a JSON config shipped with the client, mapping task classes to models. Coding and long-context reasoning tasks route to DeepSeek; shorter multilingual or summarization tasks route to GLM, which tends to price competitively on those workloads. Step two: implement a fallback chain. If the primary model returns a 429 or 5xx, the router retries once on the same model with exponential backoff, then fails over to the alternate model with a visible banner in the sidebar so the user knows the answer came from a different brain.

Step three is the part most hobby projects skip: cost-aware routing. The client should track cumulative token spend per session in IndexedDB and surface a running estimate, since a sidebar that silently burns context window on every page the user visits becomes expensive fast. A sensible default caps auto-injected page context at 2,000 tokens and requires explicit user action to exceed it. Step four: log routing decisions locally, model chosen, latency, and fallback triggers, so users can audit why a query went where it did. Keep the config user-editable rather than hardcoding the routing table, because pricing shifts between DeepSeek and GLM happen quarterly and a hardcoded table rots quickly.

PWA Sidebar Sync Security Risks

The security surface here is wider than most developers assume. First, API key exposure: any key embedded in a PWA's client-side bundle is effectively public, so the sidebar must never ship a static bluusun credential. The workable pattern is a user-supplied key stored in IndexedDB with WebCrypto AES-GCM encryption derived from a passphrase, accepting the tradeoff that a forgotten passphrase means a lost key. Second, the sync relay is a man-in-the-middle target. Encrypted client-side blobs, as described earlier, mitigate this, but only if the encryption happens before the network call and the server never sees plaintext or the derived key.

Third, sidebar-specific risks: content scripts that auto-inject page context can leak credentials from the active tab, a logged-in banking session's DOM text, into a prompt sent to a third-party API. An allowlist approach, where the user explicitly enables per-site context injection, is the defensible default. Fourth, service worker cache poisoning: if the sync server is compromised, a malicious cached response could persist across sessions. Pinning the service worker to a content-hashed asset list and validating sync payloads against a schema before merge closes most of that hole. None of this is exotic; it is table stakes that open source projects routinely skip under shipping pressure, and reviewers should treat their absence as a blocker.

Low Cost API Valuation Metrics

Evaluating whether a low-cost API reseller like bluusun is worth building on requires the same skepticism applied to any thin-margin infrastructure play. The metrics that matter: price per million input and output tokens relative to first-party DeepSeek and GLM pricing, uptime history, and rate limit ceilings. A reseller can undercut first-party pricing by 20 to 40 percent on paper, but the discount is only real if throughput holds under load. Ask for a status page with at least 90 days of history and a documented rate limit before committing a production workload; a cheaper token that 429s during peak hours costs more in retries than it saves.

The structural risk is dependency concentration. Resellers operate on thin spreads and can reprice or fold with little notice, and an open source sidebar that hardcodes one endpoint inherits that fragility. The mitigation is architectural: make the base URL and model names configuration, not constants, so a user can repoint the client at the first-party API or another gateway in under a minute. For a hobby project, the calculus favors the discount; for anything with paying users, budget for the possibility of a full repricing event and model the break-even at roughly double current token costs. Cheap capacity is a rental, not an asset.

DeepSeek vs GLM API Comparison

MetricDeepSeekGLM (Zhipu)
Flagship reasoning modelDeepSeek-R1 class, strong on math/code benchmarksGLM-4.x class, competitive on agentic and coding tasks
Typical pricing tierAmong the lowest per-million-token rates among frontier-class modelsLow-cost tier, often within 2x of DeepSeek on output tokens
Context windowUp to ~128K tokens on current generationsUp to ~128K on flagship, shorter on cheaper tiers
Open weightsYes (MIT-style licensing on key releases)Partial; some GLM releases open-sourced, others API-only
Best-fit workloadLong-form reasoning, code generation, batch processingMultilingual tasks, tool-calling agents, latency-sensitive chat
The catalysts to watch are pricing revisions and licensing moves from both camps. DeepSeek's pattern of open-weight releases pressures GLM's API-only revenue, and any Zhipu filing or disclosure around its Hong Kong listing trajectory would clarify capital runway for sustained price competition. Risks cut both ways: export control tightening on advanced accelerators could constrain either provider's inference capacity, and a reseller like bluusun inherits whatever capacity crunch hits upstream. Monitor benchmark refreshes quarterly; a routing table built on last quarter's rankings is already stale.