@sparkelf/dsh-patch-web-runtime-compat 0.2.1-alpha.24 → 0.2.1-alpha.25

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/package.json CHANGED
@@ -31,5 +31,5 @@
31
31
  "url": "git+https://github.com/SparkElf/deepseek-harness-plus.git"
32
32
  },
33
33
  "type": "module",
34
- "version": "0.2.1-alpha.24"
34
+ "version": "0.2.1-alpha.25"
35
35
  }
@@ -1,5 +1,5 @@
1
1
  diff --git a/packages/bundle/web-app/src/index.ts b/packages/bundle/web-app/src/index.ts
2
- index 28e078bd31..67f8c01043 100644
2
+ index 28e078bd31..b75d19244b 100644
3
3
  --- a/packages/bundle/web-app/src/index.ts
4
4
  +++ b/packages/bundle/web-app/src/index.ts
5
5
  @@ -15,6 +15,7 @@
@@ -10,16 +10,28 @@ index 28e078bd31..67f8c01043 100644
10
10
  import { dirname, join } from 'node:path'
11
11
  import { fileURLToPath } from 'node:url'
12
12
  import type { Context } from '@deepseek-ai/cordis'
13
- @@ -22,7 +23,7 @@ import z from '@deepseek-ai/schemastery'
14
- import { addHarnessSourceSection, auditStartupEntries } from '@deepseek-ai/dsh-app-boot'
15
- import type {} from '@deepseek-ai/dsh-client-connection'
16
- import * as FrontendStatic from '@deepseek-ai/dsh-host-frontend-static'
17
- -import { isLoopbackHost, normalizeBindAddress } from '@deepseek-ai/dsh-host-webserver'
18
- +import { isLoopbackHost, isWildcardHost, normalizeBindAddress } from '@deepseek-ai/dsh-host-webserver'
19
- import { launchedThroughSsh, launchEnvironmentOf } from '@deepseek-ai/dsh-launch-environment'
20
- import { scrubbedParentEnv } from '@deepseek-ai/dsh-subprocess'
21
- import type {} from '@deepseek-ai/cordis-plugin-loader'
22
- @@ -60,6 +61,17 @@ export interface Config {
13
+ @@ -36,6 +37,20 @@ export const name = 'web-app'
14
+ const SOURCE_ROOT = fileURLToPath(new URL('../../../..', import.meta.url))
15
+ const ANNOUNCED_ROOTS = new WeakSet<Context>()
16
+
17
+ +/**
18
+ + * Whether a bind address names every interface at once.
19
+ + *
20
+ + * Written here rather than imported from `dsh-host-webserver`: a deployment may carry an
21
+ + * alpha.1 build of that package, whose module exports three names and not
22
+ + * `isWildcardHost`; a missing import fails the whole plugin rather than this one test.
23
+ + * The set covers the IPv4 and IPv6 any-addresses and their IPv4-mapped forms.
24
+ + * @param host - bind address from configuration.
25
+ + * @returns true when the address is unspecified.
26
+ + */
27
+ +function isWildcardLiteral(host: string): boolean {
28
+ + return ['0.0.0.0', '::', '::0', '0:0:0:0:0:0:0:0', '::ffff:0.0.0.0'].includes(host.replace(/^\[|\]$/gu, '').toLowerCase())
29
+ +}
30
+ +
31
+ /** Services required before the web runtime can mount. */
32
+ export const inject = ['webServer']
33
+
34
+ @@ -60,6 +75,17 @@ export interface Config {
23
35
  * Absent or YAML `null` advertises the bind-address URL.
24
36
  */
25
37
  publicUrl?: string
@@ -37,7 +49,7 @@ index 28e078bd31..67f8c01043 100644
37
49
  }
38
50
 
39
51
  export const Config: z<Config> = z.object({
40
- @@ -67,6 +79,7 @@ export const Config: z<Config> = z.object({
52
+ @@ -67,6 +93,7 @@ export const Config: z<Config> = z.object({
41
53
  printUrl: z.boolean().default(true),
42
54
  surfaceContext: z.boolean().default(true),
43
55
  publicUrl: z.transform(z.string(), value => parsePublicUrl(value).href),
@@ -45,7 +57,7 @@ index 28e078bd31..67f8c01043 100644
45
57
  })
46
58
 
47
59
  /** Environment variable naming the advertised URL of this Web GUI. */
48
- @@ -245,6 +258,36 @@ export function apply(ctx: Context, config: Config): void {
60
+ @@ -245,6 +272,39 @@ export function apply(ctx: Context, config: Config): void {
49
61
  // through a local forwarding address that this process cannot derive.
50
62
  const handoffBrowser = config.openBrowser && !launchedThroughSsh(launchEnvironmentOf(ctx))
51
63
  ctx.plugin(FrontendStatic, { distIndex: internals.resolveDistIndex() })
@@ -68,7 +80,10 @@ index 28e078bd31..67f8c01043 100644
68
80
  + // list to the `connection` row, which leaves a profile layer written against
69
81
  + // the old row — one that serves a reverse-proxied origin — configuring a key
70
82
  + // nothing reads.
71
- + const compatLanAddresses = isWildcardHost(boundHost)
83
+ + // The wildcard test is written here rather than imported: a deployment can hold an
84
+ + // alpha.1 copy of `dsh-host-webserver`, whose module exports three names and not
85
+ + // `isWildcardHost`, and an import that fails takes this whole plugin down with it.
86
+ + const compatLanAddresses = isWildcardLiteral(boundHost)
72
87
  + ? Object.values(networkInterfaces()).flat()
73
88
  + .filter((iface): iface is NonNullable<typeof iface> => iface !== undefined && iface.family === 'IPv4' && !iface.internal)
74
89
  + .map(iface => iface.address)