@krischoichoi/channel-web 0.6.0

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,152 @@
1
+ /**
2
+ * @krischoichoi/channel-web — client-safe DTO types shared across the host API and
3
+ * the Web client ("protocol").
4
+ *
5
+ * These are deliberately plain, serialisable wire types. They never carry
6
+ * secrets or adapter-internal payloads; anything that would leak a credential
7
+ * is intentionally omitted. The client half does not typecheck against these
8
+ * via tsc (it is bundled by esbuild), but keeping them here documents the
9
+ * exact shape the host API promises and gives M1 a stable contract.
10
+ */
11
+ /** Public view of one channel for the Web dashboard. */
12
+ export interface ChannelView {
13
+ /** Stable adapter / channel id (e.g. "weixin"). */
14
+ id: string;
15
+ /** Whether the channel is enabled in configuration. */
16
+ enabled: boolean;
17
+ /** Whether credentials are configured. */
18
+ configured: boolean;
19
+ /** Whether the adapter is currently mounted for this process. */
20
+ mounted: boolean;
21
+ /** Free-form status string, e.g. "connected" | "disconnected". */
22
+ status: string;
23
+ /** Optional health summary when the adapter exposes getHealth. */
24
+ health?: ChannelHealthView | null;
25
+ /** Adapter capability flags relevant to the dashboard. */
26
+ capabilities?: {
27
+ send?: boolean;
28
+ receive?: boolean;
29
+ auth?: boolean;
30
+ streaming?: boolean;
31
+ [key: string]: boolean | string | undefined;
32
+ } | null;
33
+ /** Sanitised last error message; never a raw secret/credential. */
34
+ lastError?: string | null;
35
+ }
36
+ /** Client-safe projection of ChannelHealth (never a credential). */
37
+ export interface ChannelHealthView {
38
+ status: 'ok' | 'degraded' | 'down' | 'unknown';
39
+ detail?: string | null;
40
+ connection?: boolean | null;
41
+ authenticated?: boolean | null;
42
+ }
43
+ /** Public QR auth challenge — never includes the adapter's private payload. */
44
+ export interface PublicAuthChallenge {
45
+ /** Stable challenge id used to poll/complete this flow. */
46
+ id: string;
47
+ /** Human-readable instruction. */
48
+ instruction: string;
49
+ /** Optional QR image as a data URL or URL for the dialog. */
50
+ qrUrl?: string | null;
51
+ /** Optional expiry epoch ms. */
52
+ expiresAt?: number | null;
53
+ }
54
+ /** Public auth-flow poll response. */
55
+ export interface PublicAuthPoll {
56
+ /** Flow state. */
57
+ state: 'pending' | 'authenticated' | 'expired' | 'failed';
58
+ /** Human-readable detail when the state is not pending. */
59
+ detail?: string | null;
60
+ /** Optional hint the UI should surface (e.g. "enter verification code"). */
61
+ prompt?: string | null;
62
+ }
63
+ /** Request body for the verification-code (auth/input) endpoint. */
64
+ export interface PublicAuthInput {
65
+ kind: 'verification-code';
66
+ value: string;
67
+ }
68
+ /** Standard structured error body returned by the host API. */
69
+ export interface PublicError {
70
+ error: {
71
+ code: string;
72
+ message: string;
73
+ };
74
+ }
75
+ /** How a channel begins an authorization flow (doc §15). */
76
+ export type AuthMethod = 'qr' | 'device' | 'portal-login' | 'credentials' | 'hybrid';
77
+ /** Fine-grained progress of an auth flow (doc §15/§16). */
78
+ export type AuthPhase = 'preparing' | 'waiting-scan' | 'scanned' | 'waiting-confirm' | 'verification-required' | 'credentials-required' | 'authorized' | 'expired' | 'failed' | 'cancelled';
79
+ /** Coarse public auth state, kept M1-compatible (doc §15). */
80
+ export type AuthState = 'pending' | 'authenticated' | 'expired' | 'failed';
81
+ /** Structured QR payload (doc §17): opaque content, data URL, or external URL. */
82
+ export interface PublicQrPayload {
83
+ kind: 'content' | 'data-url' | 'external-url';
84
+ value: string;
85
+ expiresAt?: number | null;
86
+ }
87
+ /** Structured user-facing prompt associated with a phase (doc §16). */
88
+ export interface PublicAuthPrompt {
89
+ kind: 'verification-code' | 'confirm-on-phone' | 'credentials-required' | 'open-browser';
90
+ message?: string | null;
91
+ }
92
+ /** Public auth status returned by polling (doc §16). */
93
+ export interface PublicAuthStatus {
94
+ state: AuthState;
95
+ phase: AuthPhase;
96
+ prompt?: PublicAuthPrompt | null;
97
+ expiresAt?: number | null;
98
+ detail?: string | null;
99
+ }
100
+ /** Browser-facing auth session (doc §18). Never contains secret values. */
101
+ export interface PublicAuthSession {
102
+ id: string;
103
+ channelId: string;
104
+ state: AuthState;
105
+ phase: AuthPhase;
106
+ qr?: PublicQrPayload | null;
107
+ expiresAt?: number | null;
108
+ prompt?: PublicAuthPrompt | null;
109
+ }
110
+ /** Input that begins an auth flow (doc §14/§19). */
111
+ export interface AuthBeginInput {
112
+ method: AuthMethod;
113
+ accountId?: string;
114
+ }
115
+ /** Auth input submitted during a flow (e.g. a verification code). */
116
+ export interface AuthInput {
117
+ kind: 'verification-code';
118
+ value: string;
119
+ }
120
+ /** One selectable setup field of a channel. Secret refs are never exposed. */
121
+ export interface ChannelSetupField {
122
+ name: string;
123
+ kind: 'text' | 'secret';
124
+ secret: boolean;
125
+ configured: boolean;
126
+ writable: boolean;
127
+ }
128
+ /** Static setup descriptor advertising a channel's editable surface (doc §29). */
129
+ export interface ChannelSetupDescriptor {
130
+ fields: ChannelSetupField[];
131
+ authMethods: AuthMethod[];
132
+ setupUrl?: string;
133
+ }
134
+ /** Dynamic configured state: never returns secret values (doc §14/§29). */
135
+ export interface ConfiguredState {
136
+ configured: boolean;
137
+ fields: Record<string, {
138
+ configured: boolean;
139
+ writable: boolean;
140
+ source?: string;
141
+ }>;
142
+ }
143
+ /** Row returned by GET /v2/channels (doc §29). */
144
+ export interface ChannelSummary {
145
+ id: string;
146
+ configured: boolean;
147
+ enabled: boolean;
148
+ mounted: boolean;
149
+ runtime: 'running' | 'stopped';
150
+ connection: 'connected' | 'degraded' | 'disconnected' | 'unknown';
151
+ }
152
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,wDAAwD;AACxD,MAAM,WAAW,WAAW;IAC1B,mDAAmD;IACnD,EAAE,EAAE,MAAM,CAAC;IACX,uDAAuD;IACvD,OAAO,EAAE,OAAO,CAAC;IACjB,0CAA0C;IAC1C,UAAU,EAAE,OAAO,CAAC;IACpB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UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/B,UAAU,EAAE,WAAW,GAAG,UAAU,GAAG,cAAc,GAAG,SAAS,CAAC;CACnE"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @krischoichoi/channel-web — client-safe DTO types shared across the host API and
3
+ * the Web client ("protocol").
4
+ *
5
+ * These are deliberately plain, serialisable wire types. They never carry
6
+ * secrets or adapter-internal payloads; anything that would leak a credential
7
+ * is intentionally omitted. The client half does not typecheck against these
8
+ * via tsc (it is bundled by esbuild), but keeping them here documents the
9
+ * exact shape the host API promises and gives M1 a stable contract.
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@krischoichoi/channel-web",
3
+ "version": "0.6.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/krischoichoi/dsh-channels.git"
7
+ },
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "description": "DeepSeek Harness Web client: Settings > Channels (渠道) dashboard",
12
+ "type": "module",
13
+ "main": "./lib/index.js",
14
+ "types": "./lib/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./lib/index.d.ts",
18
+ "default": "./lib/index.js"
19
+ },
20
+ "./client": {
21
+ "default": "./lib/client.js"
22
+ },
23
+ "./protocol": {
24
+ "types": "./lib/protocol.d.ts",
25
+ "default": "./lib/protocol.js"
26
+ },
27
+ "./package.json": "./package.json"
28
+ },
29
+ "dsh": {
30
+ "client": {
31
+ "platform": "web",
32
+ "inject": [
33
+ "@deepseek-ai/dsh-client-locale",
34
+ "@deepseek-ai/dsh-client-ui-settings"
35
+ ]
36
+ }
37
+ },
38
+ "files": [
39
+ "lib"
40
+ ],
41
+ "scripts": {
42
+ "build": "tsc -p tsconfig.host.json && node build.mjs",
43
+ "typecheck": "tsc -p tsconfig.json",
44
+ "test": "vitest run",
45
+ "clean": "rimraf lib"
46
+ },
47
+ "dependencies": {
48
+ "@krischoichoi/channel-control": "workspace:*",
49
+ "@krischoichoi/channel-core": "workspace:*",
50
+ "qrcode": "^1.5.4",
51
+ "zod": "^4.4.3"
52
+ },
53
+ "devDependencies": {
54
+ "@deepseek-ai/cordis": "^4.0.4",
55
+ "@deepseek-ai/dsh-client-locale": "0.2.0-rc.2",
56
+ "@deepseek-ai/dsh-client-ui-settings": "0.2.0-rc.2",
57
+ "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.2",
58
+ "@deepseek-ai/dsh-client-ui-primitives": "0.2.0-rc.2",
59
+ "@types/qrcode": "^1.5.6",
60
+ "@types/react": "^18.3.1",
61
+ "esbuild": "^0.28.2",
62
+ "react": "^18.3.1",
63
+ "rimraf": "^6.0.0",
64
+ "typescript": "^5.9.0",
65
+ "vitest": "^3.2.0"
66
+ },
67
+ "peerDependencies": {
68
+ "@deepseek-ai/cordis": "^4.0.4",
69
+ "@deepseek-ai/dsh-client-locale": "0.2.0-rc.2",
70
+ "@deepseek-ai/dsh-client-ui-settings": "0.2.0-rc.2"
71
+ },
72
+ "license": "MIT"
73
+ }