@adhdev/daemon-core 0.8.71 → 0.8.73

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.
@@ -0,0 +1,22 @@
1
+ const HERMES_SESSION_ID_RE = /^\d{8}_\d{6}_[a-z0-9]+$/i
2
+
3
+ export function normalizeProviderSessionId(providerType: string | undefined, providerSessionId: string | null | undefined): string {
4
+ const normalizedProviderType = typeof providerType === 'string' ? providerType.trim() : ''
5
+ const normalizedId = typeof providerSessionId === 'string' ? providerSessionId.trim() : ''
6
+ if (!normalizedId) return ''
7
+
8
+ const lowered = normalizedId.toLowerCase()
9
+ if (lowered === 'undefined' || lowered === 'null') return ''
10
+
11
+ if (normalizedProviderType === 'hermes-cli' && !HERMES_SESSION_ID_RE.test(normalizedId)) {
12
+ return ''
13
+ }
14
+
15
+ return normalizedId
16
+ }
17
+
18
+ export function isLegacyVolatileSessionReadKey(key: string | null | undefined): boolean {
19
+ const normalizedKey = typeof key === 'string' ? key.trim() : ''
20
+ if (!normalizedKey) return false
21
+ return normalizedKey.startsWith('provider:codex:vscode-webview://')
22
+ }
@@ -1,6 +1,14 @@
1
1
  export const DEFAULT_SESSION_HOST_APP_NAME = 'adhdev'
2
2
  export const DEFAULT_STANDALONE_SESSION_HOST_APP_NAME = 'adhdev-standalone'
3
3
 
4
+ function validateStandaloneSessionHostAppName(explicit: string): void {
5
+ if (explicit !== DEFAULT_SESSION_HOST_APP_NAME) return
6
+ throw new Error(
7
+ `Standalone session-host namespace '${DEFAULT_SESSION_HOST_APP_NAME}' is reserved for the global daemon. `
8
+ + `Use '${DEFAULT_STANDALONE_SESSION_HOST_APP_NAME}' or another non-default namespace.`,
9
+ )
10
+ }
11
+
4
12
  export function resolveSessionHostAppName(options: {
5
13
  standalone?: boolean
6
14
  env?: NodeJS.ProcessEnv
@@ -10,6 +18,9 @@ export function resolveSessionHostAppName(options: {
10
18
  ? env.ADHDEV_SESSION_HOST_NAME.trim()
11
19
  : ''
12
20
 
13
- if (explicit) return explicit
21
+ if (explicit) {
22
+ if (options.standalone) validateStandaloneSessionHostAppName(explicit)
23
+ return explicit
24
+ }
14
25
  return options.standalone ? DEFAULT_STANDALONE_SESSION_HOST_APP_NAME : DEFAULT_SESSION_HOST_APP_NAME
15
26
  }