Bläddra i källkod

fix(api): repair runtime closure, gateway client bundle, and $host coverage

- python/sdk-runtime: add @deepseek-ai/dsh-util-time so the runtime
  dependency closure stays closed (dsh-subagent now depends on it).
- api/gateway: drop the dsh.client.external request for
  dsh-typert-protocol and admit the protocol package into INLINE_SAFE
  instead. The loader module table has no supplier for the protocol
  package, so the built client factory threw at require time; the
  protocol layer is duplication-safe by design (string marker,
  code-based discrimination), which is the inline-safe admission
  criterion.
- api/gateway tests: cover the $host getter (live service read,
  pre-ready home, and the construction-time fallback after the
  Connection service is withdrawn).
imccyu 1 månad sedan
förälder
incheckning
d40d678b93

+ 0 - 3
packages/api/gateway/package.json

@@ -35,9 +35,6 @@
   },
   "dsh": {
     "client": {
-      "external": [
-        "@deepseek-ai/dsh-typert-protocol"
-      ],
       "inject": [
         "@deepseek-ai/dsh-typert-registry",
         "@deepseek-ai/dsh-client-connection"

+ 30 - 0
packages/api/gateway/tests/gateway.client.spec.ts

@@ -5,6 +5,7 @@ import { describe, expect, expectTypeOf, it, vi } from 'vitest'
 import { z } from 'zod'
 import {
   apply as applyConnection,
+  type ConnectionGeneration,
   type ConnectionGenerationSource,
   type ConnectionHandle,
 } from '@deepseek-ai/dsh-client-connection/client'
@@ -548,6 +549,35 @@ describe('Client Remote transport readiness', () => {
     await client.dispose()
   })
 
+  it('reports Host facts as plain reads and keeps them through Connection withdrawal', async () => {
+    const ctx = new Context()
+    await ctx.plugin(TypertRegistry)
+    const generation = new GenerationHarness()
+    const live: { snapshot: ConnectionGeneration | undefined } = { snapshot: undefined }
+    const handle = {
+      isLoopback: true,
+      generation: { getSnapshot: () => live.snapshot, subscribe: () => () => {} },
+      rpc: {
+        call: vi.fn<ConnectionHandle['rpc']['call']>(),
+        open: () => unexpectedInProcessStream(),
+      },
+      registerGenerationSource: generation.register,
+      start: () => ({ stop: () => {} }),
+    } as unknown as ConnectionHandle
+    const withdraw = ctx.provide('connection', handle)
+    const client = ctx.plugin({ inject, apply })
+    await client
+    const remote = ctx.remote
+
+    expect(remote.$host).toEqual({ home: undefined, isLoopback: true })
+    live.snapshot = { id: 1, host: { home: '/hosts/primary' } }
+    expect(remote.$host).toEqual({ home: '/hosts/primary', isLoopback: true })
+
+    withdraw()
+    expect(ctx.get('connection')).toBeUndefined()
+    expect(remote.$host).toEqual({ home: '/hosts/primary', isLoopback: true })
+  })
+
   it('starts after Loader settlement and stops the owned loop on disposal', async () => {
     const readiness = deferredReadiness()
     const { client, start, stop } = await loaderReadinessBench(readiness.promise)

+ 1 - 1
packages/client/tsdown.client.ts

@@ -58,7 +58,7 @@ function styleInjectionModule(
  * Everything else under @deepseek-ai/* is either a module-table entry
  * (external) or a leak the purity gate rejects.
  */
-export const INLINE_SAFE = /^(?:@deepseek-ai\/dsh-(?:file-reference|session|llm|tools|brand|util-crypto|util-workspace-path)(?:\/|$)|@deepseek-ai\/dsh-token-meter\/client$)/
+export const INLINE_SAFE = /^(?:@deepseek-ai\/dsh-(?:file-reference|session|llm|tools|brand|typert-protocol|util-crypto|util-workspace-path)(?:\/|$)|@deepseek-ai\/dsh-token-meter\/client$)/
 
 /**
  * Vendored framework libraries: rescoped into @deepseek-ai, so the gate below

+ 3 - 0
pnpm-lock.yaml

@@ -10539,6 +10539,9 @@ importers:
       '@deepseek-ai/dsh-user-questions':
         specifier: workspace:^
         version: link:../../packages/interaction/user-questions
+      '@deepseek-ai/dsh-util-time':
+        specifier: workspace:^
+        version: link:../../packages/util/time
       '@deepseek-ai/dsh-web':
         specifier: workspace:^
         version: link:../../packages/web/web

+ 1 - 0
python/sdk-runtime/package.json

@@ -119,6 +119,7 @@
     "@deepseek-ai/dsh-user-approval": "workspace:^",
     "@deepseek-ai/dsh-anonymous-user-id": "workspace:^",
     "@deepseek-ai/dsh-user-questions": "workspace:^",
+    "@deepseek-ai/dsh-util-time": "workspace:^",
     "@deepseek-ai/dsh-web": "workspace:^",
     "@deepseek-ai/dsh-web-fetch-http": "workspace:^",
     "@deepseek-ai/dsh-web-search-deepseek": "workspace:^",