@huanlin/dsh-plugin-aigc-canvas 0.1.9 → 0.2.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.
- package/cordis.patch.yml +2 -2
- package/lib/client.js +3307 -3184
- package/lib/client.js.map +1 -1
- package/lib/config.d.ts +50 -12
- package/lib/context-types.d.ts +140 -114
- package/lib/entry-identity.d.ts +22 -0
- package/lib/index.d.ts +6 -4
- package/lib/index.js +292 -203
- package/lib/provider-shape.d.ts +15 -0
- package/lib/provider-store.d.ts +57 -22
- package/lib/settings.d.ts +78 -0
- package/lib/tools.d.ts +3 -3
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +19 -11
package/lib/config.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Serializable configuration and defaults for the AIGC canvas host half.
|
|
3
3
|
* The `providers` array holds one or more AIGC provider configs (name /
|
|
4
|
-
* endpoint / apiKey / instructions)
|
|
5
|
-
*
|
|
4
|
+
* endpoint / apiKey / instructions). Since dsh 0.1.7-rc.1 the editable
|
|
5
|
+
* fields are `.volatile()` members of the entry's profile-owned Cordis
|
|
6
|
+
* Config (DSH-0.1.7-J1-04): the composition `config:` in cordis.patch.yml is
|
|
7
|
+
* the first-boot seed only, and runtime edits persist per profile under the
|
|
8
|
+
* entry id `dsh-aigc-canvas` through the settings service.
|
|
6
9
|
*
|
|
7
10
|
* @module @huanlin/dsh-plugin-aigc-canvas/config
|
|
8
11
|
*/
|
|
9
|
-
import z from 'schemastery';
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
+
import z from '@deepseek-ai/schemastery';
|
|
13
|
+
import type { Volatile } from '@deepseek-ai/cordis';
|
|
14
|
+
export { PROVIDER_ID_PATTERN, validateProviderId } from './provider-shape.js';
|
|
12
15
|
/** How the aigc_http_request tool attaches the provider apiKey to requests. */
|
|
13
16
|
export interface AigcProviderAuth {
|
|
14
17
|
/**
|
|
@@ -34,7 +37,7 @@ export interface AigcProvider {
|
|
|
34
37
|
name: string;
|
|
35
38
|
/** Provider API endpoint URL. `stub://aigc-backend` = the built-in stub. */
|
|
36
39
|
endpoint: string;
|
|
37
|
-
/** Provider API key (
|
|
40
|
+
/** Provider API key (persisted with the entry config in cordis.patch.yml; set via GUI or seed). */
|
|
38
41
|
apiKey: string;
|
|
39
42
|
/** Free-form usage instructions the agent reads via aigc_get_provider_info. */
|
|
40
43
|
instructions: string;
|
|
@@ -52,8 +55,29 @@ export interface AigcCanvasConfig {
|
|
|
52
55
|
/** Maximum media bytes to write to disk per generated asset. */
|
|
53
56
|
mediaSizeLimit?: number;
|
|
54
57
|
}
|
|
55
|
-
/**
|
|
56
|
-
|
|
58
|
+
/**
|
|
59
|
+
* The live Cordis config the Loader passes to `apply`.
|
|
60
|
+
*
|
|
61
|
+
* `providers` is `.volatile()`: the field arrives as a stable reference whose
|
|
62
|
+
* `.get()` always returns the latest accepted value (a committed settings
|
|
63
|
+
* edit updates it in place without remounting the plugin). The other fields
|
|
64
|
+
* are composition-seed knobs resolved once at load.
|
|
65
|
+
*/
|
|
66
|
+
export interface AigcEntryConfig {
|
|
67
|
+
/** Live provider list reference; `.get()` returns the latest accepted value. */
|
|
68
|
+
providers?: Volatile<readonly AigcProvider[]>;
|
|
69
|
+
requestTimeoutMs?: number;
|
|
70
|
+
mediaSizeLimit?: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Schemastery schema for the plugin's profile-owned Config.
|
|
74
|
+
*
|
|
75
|
+
* `providers` is `.volatile()` (dsh 0.1.7-rc.1 DSH-0.1.7-J1-04): the settings
|
|
76
|
+
* service enumerates the entry's volatile fields for the configuration form,
|
|
77
|
+
* and a committed edit updates the running reference in place. The numeric
|
|
78
|
+
* knobs stay non-volatile (cordis.patch.yml seed only).
|
|
79
|
+
*/
|
|
80
|
+
export declare const Config: z<AigcEntryConfig>;
|
|
57
81
|
/** A fully-resolved provider (all fields guaranteed). */
|
|
58
82
|
export interface ResolvedAigcProvider extends AigcProvider {
|
|
59
83
|
name: string;
|
|
@@ -71,7 +95,21 @@ export interface ResolvedAigcConfig {
|
|
|
71
95
|
}
|
|
72
96
|
/** Returns true when the provider endpoint points at the built-in stub backend. */
|
|
73
97
|
export declare function isStubEndpoint(endpoint: string): boolean;
|
|
74
|
-
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Normalize a raw provider list (the volatile reference's latest snapshot, a
|
|
100
|
+
* legacy imported document, or a hand-edited override) into resolved
|
|
101
|
+
* providers. Non-object entries are skipped; duplicate ids keep the first
|
|
102
|
+
* occurrence (insertion order preserved).
|
|
103
|
+
* @param raw - the raw list value.
|
|
104
|
+
* @returns the resolved providers, in order, deduplicated by id.
|
|
105
|
+
*/
|
|
106
|
+
export declare function resolveAigcProviders(raw: unknown): readonly ResolvedAigcProvider[];
|
|
107
|
+
/**
|
|
108
|
+
* Resolve the apply-time seed config (direct-call defaults after Loader
|
|
109
|
+
* schema validation has normally run). The provider list reads the live
|
|
110
|
+
* volatile reference; when it resolves empty at load, the default stub is
|
|
111
|
+
* seeded so the tools always have one provider.
|
|
112
|
+
* @param config - the entry config the Loader passed to `apply`.
|
|
113
|
+
* @returns the fully defaulted seed settings.
|
|
114
|
+
*/
|
|
115
|
+
export declare function resolveAigcConfig(config: AigcEntryConfig | undefined): ResolvedAigcConfig;
|
package/lib/context-types.d.ts
CHANGED
|
@@ -1,114 +1,140 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Structural types for the cordis services this plugin consumes, plus the
|
|
3
|
-
* Context augmentation both halves share. A third-party plugin resolves
|
|
4
|
-
* outside the DSH monorepo's single cordis instance, so the upstream
|
|
5
|
-
* `declare module 'cordis'` augmentations do not reach this Context — and
|
|
6
|
-
* the npm cordis package does not declare the DSH-vendored runtime members
|
|
7
|
-
* (`ctx.effect`, the webServer/sessions/loader faces). The members below
|
|
8
|
-
* mirror the actual runtime shapes this plugin touches:
|
|
9
|
-
*
|
|
10
|
-
* - webServer: @deepseek-ai/dsh-host-webserver
|
|
11
|
-
* - sessions: @deepseek-ai/dsh-session (host side)
|
|
12
|
-
* - loader: @cordisjs/plugin-loader (entry options)
|
|
13
|
-
* - effect: the DSH-vendored cordis lifecycle helper
|
|
14
|
-
*
|
|
15
|
-
* Drift from upstream is contained to this file.
|
|
16
|
-
*/
|
|
17
|
-
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
18
|
-
import type { Duplex } from 'node:stream';
|
|
19
|
-
import type { Context } from 'cordis';
|
|
20
|
-
import type { AigcCanvasService } from './canvas-registry.js';
|
|
21
|
-
/** One named webserver route (mirror of the host-webserver WebRoute). */
|
|
22
|
-
export interface AigcWebRoute {
|
|
23
|
-
kind: 'exact' | 'prefix';
|
|
24
|
-
path: string;
|
|
25
|
-
handler: (req: IncomingMessage, res: ServerResponse) => void | Promise<void>;
|
|
26
|
-
}
|
|
27
|
-
/** One exact-path HTTP upgrade registration (mirror of WebUpgradeRoute). */
|
|
28
|
-
export interface AigcWebUpgradeRoute {
|
|
29
|
-
path: string;
|
|
30
|
-
handler: (req: IncomingMessage, socket: Duplex, head: Buffer) => void | Promise<void>;
|
|
31
|
-
}
|
|
32
|
-
/** The webServer service face this plugin uses. */
|
|
33
|
-
export interface AigcWebServer {
|
|
34
|
-
register(route: AigcWebRoute): () => void;
|
|
35
|
-
registerUpgrade(route: AigcWebUpgradeRoute): () => void;
|
|
36
|
-
}
|
|
37
|
-
/** A published session's header slice (authoritative cwd). */
|
|
38
|
-
export interface AigcSessionHeader {
|
|
39
|
-
cwd?: string;
|
|
40
|
-
}
|
|
41
|
-
/** The host session store face (`ctx.sessions.get(id)` returns the live session). */
|
|
42
|
-
export interface AigcSessionStore {
|
|
43
|
-
get(id: string): {
|
|
44
|
-
header: AigcSessionHeader;
|
|
45
|
-
} | undefined;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* The minimal Agent face this plugin uses for context injection.
|
|
49
|
-
* Mirrors `@deepseek-ai/dsh-agent`'s `Agent.inject()` — see the DSH
|
|
50
|
-
* agent loop's inbox/splice path. The plugin calls `inject()` to push
|
|
51
|
-
* a notice into the agent's next-step context (non-waking).
|
|
52
|
-
*/
|
|
53
|
-
export interface AigcAgent {
|
|
54
|
-
readonly id: string;
|
|
55
|
-
inject(message: AigcUserMessage): void;
|
|
56
|
-
}
|
|
57
|
-
/** A minimal user-role message for agent.inject (mirrors dsh-llm's UserMessage). */
|
|
58
|
-
export interface AigcUserMessage {
|
|
59
|
-
readonly id: string;
|
|
60
|
-
readonly role: 'user';
|
|
61
|
-
readonly content: ReadonlyArray<{
|
|
62
|
-
type: 'text';
|
|
63
|
-
text: string;
|
|
64
|
-
}>;
|
|
65
|
-
readonly source: {
|
|
66
|
-
readonly kind: 'plugin';
|
|
67
|
-
readonly plugin: string;
|
|
68
|
-
readonly form?: 'notice';
|
|
69
|
-
readonly summary?: string;
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
/** The agents registry face (`ctx.agents.get(sessionId)` returns the live agent). */
|
|
73
|
-
export interface AigcAgentRegistry {
|
|
74
|
-
get(id: string): AigcAgent | undefined;
|
|
75
|
-
}
|
|
76
|
-
/** One loader entry's options slice (the connection row's resolved config). */
|
|
77
|
-
export interface AigcLoaderEntry {
|
|
78
|
-
options: {
|
|
79
|
-
name: string;
|
|
80
|
-
config?: unknown;
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
/** The loader face used to read the connection row's trustedHosts config. */
|
|
84
|
-
export interface AigcLoader {
|
|
85
|
-
entries(): Iterable<AigcLoaderEntry>;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* The
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
*/
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Structural types for the cordis services this plugin consumes, plus the
|
|
3
|
+
* Context augmentation both halves share. A third-party plugin resolves
|
|
4
|
+
* outside the DSH monorepo's single cordis instance, so the upstream
|
|
5
|
+
* `declare module 'cordis'` augmentations do not reach this Context — and
|
|
6
|
+
* the npm cordis package does not declare the DSH-vendored runtime members
|
|
7
|
+
* (`ctx.effect`, the webServer/sessions/loader faces). The members below
|
|
8
|
+
* mirror the actual runtime shapes this plugin touches:
|
|
9
|
+
*
|
|
10
|
+
* - webServer: @deepseek-ai/dsh-host-webserver
|
|
11
|
+
* - sessions: @deepseek-ai/dsh-session (host side)
|
|
12
|
+
* - loader: @cordisjs/plugin-loader (entry options)
|
|
13
|
+
* - effect: the DSH-vendored cordis lifecycle helper
|
|
14
|
+
*
|
|
15
|
+
* Drift from upstream is contained to this file.
|
|
16
|
+
*/
|
|
17
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
18
|
+
import type { Duplex } from 'node:stream';
|
|
19
|
+
import type { Context } from 'cordis';
|
|
20
|
+
import type { AigcCanvasService } from './canvas-registry.js';
|
|
21
|
+
/** One named webserver route (mirror of the host-webserver WebRoute). */
|
|
22
|
+
export interface AigcWebRoute {
|
|
23
|
+
kind: 'exact' | 'prefix';
|
|
24
|
+
path: string;
|
|
25
|
+
handler: (req: IncomingMessage, res: ServerResponse) => void | Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
/** One exact-path HTTP upgrade registration (mirror of WebUpgradeRoute). */
|
|
28
|
+
export interface AigcWebUpgradeRoute {
|
|
29
|
+
path: string;
|
|
30
|
+
handler: (req: IncomingMessage, socket: Duplex, head: Buffer) => void | Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
/** The webServer service face this plugin uses. */
|
|
33
|
+
export interface AigcWebServer {
|
|
34
|
+
register(route: AigcWebRoute): () => void;
|
|
35
|
+
registerUpgrade(route: AigcWebUpgradeRoute): () => void;
|
|
36
|
+
}
|
|
37
|
+
/** A published session's header slice (authoritative cwd). */
|
|
38
|
+
export interface AigcSessionHeader {
|
|
39
|
+
cwd?: string;
|
|
40
|
+
}
|
|
41
|
+
/** The host session store face (`ctx.sessions.get(id)` returns the live session). */
|
|
42
|
+
export interface AigcSessionStore {
|
|
43
|
+
get(id: string): {
|
|
44
|
+
header: AigcSessionHeader;
|
|
45
|
+
} | undefined;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The minimal Agent face this plugin uses for context injection.
|
|
49
|
+
* Mirrors `@deepseek-ai/dsh-agent`'s `Agent.inject()` — see the DSH
|
|
50
|
+
* agent loop's inbox/splice path. The plugin calls `inject()` to push
|
|
51
|
+
* a notice into the agent's next-step context (non-waking).
|
|
52
|
+
*/
|
|
53
|
+
export interface AigcAgent {
|
|
54
|
+
readonly id: string;
|
|
55
|
+
inject(message: AigcUserMessage): void;
|
|
56
|
+
}
|
|
57
|
+
/** A minimal user-role message for agent.inject (mirrors dsh-llm's UserMessage). */
|
|
58
|
+
export interface AigcUserMessage {
|
|
59
|
+
readonly id: string;
|
|
60
|
+
readonly role: 'user';
|
|
61
|
+
readonly content: ReadonlyArray<{
|
|
62
|
+
type: 'text';
|
|
63
|
+
text: string;
|
|
64
|
+
}>;
|
|
65
|
+
readonly source: {
|
|
66
|
+
readonly kind: 'plugin';
|
|
67
|
+
readonly plugin: string;
|
|
68
|
+
readonly form?: 'notice';
|
|
69
|
+
readonly summary?: string;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** The agents registry face (`ctx.agents.get(sessionId)` returns the live agent). */
|
|
73
|
+
export interface AigcAgentRegistry {
|
|
74
|
+
get(id: string): AigcAgent | undefined;
|
|
75
|
+
}
|
|
76
|
+
/** One loader entry's options slice (the connection row's resolved config). */
|
|
77
|
+
export interface AigcLoaderEntry {
|
|
78
|
+
options: {
|
|
79
|
+
name: string;
|
|
80
|
+
config?: unknown;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** The loader face used to read the connection row's trustedHosts config. */
|
|
84
|
+
export interface AigcLoader {
|
|
85
|
+
entries(): Iterable<AigcLoaderEntry>;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The settings service face this plugin uses (mirror of
|
|
89
|
+
* `@deepseek-ai/dsh-settings` `SettingsForms`, dsh 0.1.7-rc.1). Restated
|
|
90
|
+
* structurally like the other faces above so the third-party resolution
|
|
91
|
+
* tree typechecks without a dependency on the DSH package.
|
|
92
|
+
*/
|
|
93
|
+
export interface AigcSettingsForms {
|
|
94
|
+
/** Register the calling plugin instance's settings-page policy. */
|
|
95
|
+
configure(presentation: {
|
|
96
|
+
auto?: boolean;
|
|
97
|
+
}, owner?: AigcCordisFiber): () => void;
|
|
98
|
+
/** Merge editable (volatile) fields into one entry's profile config. */
|
|
99
|
+
update(ns: string, patch: object, expectedRevision?: number): Promise<void>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Structural slice of the DSH-vendored cordis `Fiber`: `configure` keys its
|
|
103
|
+
* presentation policy by fiber identity, and the plugin only ever passes
|
|
104
|
+
* `ctx.fiber` through.
|
|
105
|
+
*/
|
|
106
|
+
export interface AigcCordisFiber {
|
|
107
|
+
readonly uid: number | null;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The tools service face restated.
|
|
111
|
+
* Mirrored here exactly like better-sidebar does — the dual-cordis-instance
|
|
112
|
+
* resolution otherwise hides the upstream augmentation. The `tools` service
|
|
113
|
+
* face is declared in `./types.d.ts` (the ambient cordis module augmentation)
|
|
114
|
+
* and not restated here to avoid a "subsequent property declarations must
|
|
115
|
+
* have the same type" error.
|
|
116
|
+
*/
|
|
117
|
+
export interface AigcToolsService {
|
|
118
|
+
register(tool: unknown): () => void;
|
|
119
|
+
}
|
|
120
|
+
declare module 'cordis' {
|
|
121
|
+
interface Context {
|
|
122
|
+
webServer: AigcWebServer;
|
|
123
|
+
sessions: AigcSessionStore;
|
|
124
|
+
agents: AigcAgentRegistry;
|
|
125
|
+
loader: AigcLoader;
|
|
126
|
+
/** The profile-owned settings forms service (dsh 0.1.7-rc.1); undefined when no settings provider is mounted. */
|
|
127
|
+
settings: AigcSettingsForms;
|
|
128
|
+
/** The plugin instance's fiber (DSH-vendored cordis). */
|
|
129
|
+
fiber: AigcCordisFiber;
|
|
130
|
+
/**
|
|
131
|
+
* The host-side AIGC canvas registry: holds the per-session element
|
|
132
|
+
* table (prompts + generated assets) and edges. Provided by the host
|
|
133
|
+
* half (see {@link ./canvas-registry.ts}); undefined on the client.
|
|
134
|
+
*/
|
|
135
|
+
aigcCanvas: AigcCanvasService;
|
|
136
|
+
/** Register a lifecycle callback (DSH-vendored cordis). */
|
|
137
|
+
effect(fn: () => void | (() => void), label?: string): void;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export type { Context };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* entry-identity.ts — the identity triple that binds this plugin's three
|
|
3
|
+
* naming surfaces together. Keeping them in one dependency-free module lets
|
|
4
|
+
* a unit test pin them against `cordis.patch.yml` and `package.json`
|
|
5
|
+
* (a mismatched `plugins.row.config` key fails silently: the row's configure
|
|
6
|
+
* entry simply never appears).
|
|
7
|
+
*
|
|
8
|
+
* - ENTRY_ID: the profile entry id — the `id` of the insert row in
|
|
9
|
+
* `cordis.patch.yml`. The Host serves the entry's volatile config under
|
|
10
|
+
* it, so it keys `ctx.configForms.get` and `settings.update`.
|
|
11
|
+
* - PACKAGE_NAME: the bundle's npm package name — the row's `name` field.
|
|
12
|
+
* - ROW_CONFIG_KEY: the Plugins page `plugins.row.config` slot key,
|
|
13
|
+
* `<package name>#<row id>` with the row id passed through verbatim.
|
|
14
|
+
*
|
|
15
|
+
* @module @huanlin/dsh-plugin-aigc-canvas/entry-identity
|
|
16
|
+
*/
|
|
17
|
+
/** Profile entry id (= the `cordis.patch.yml` insert row id / settings namespace). */
|
|
18
|
+
export declare const ENTRY_ID = "dsh-aigc-canvas";
|
|
19
|
+
/** Bundle package name (the Loader resolves the row's module through it). */
|
|
20
|
+
export declare const PACKAGE_NAME = "@huanlin/dsh-plugin-aigc-canvas";
|
|
21
|
+
/** `plugins.row.config` key: the bundle's package name `#` the patch row id. */
|
|
22
|
+
export declare const ROW_CONFIG_KEY = "@huanlin/dsh-plugin-aigc-canvas#dsh-aigc-canvas";
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Context } from './context-types.js';
|
|
2
|
-
import { Config, type
|
|
3
|
-
|
|
4
|
-
export
|
|
2
|
+
import { Config, type AigcEntryConfig, type AigcProvider, type ResolvedAigcConfig, type ResolvedAigcProvider } from './config.js';
|
|
3
|
+
import { SETTINGS_NAMESPACE } from './settings.js';
|
|
4
|
+
export { Config, SETTINGS_NAMESPACE };
|
|
5
|
+
export type { AigcCanvasConfig } from './config.js';
|
|
6
|
+
export type { AigcEntryConfig, AigcProvider, ResolvedAigcConfig, ResolvedAigcProvider };
|
|
5
7
|
export type { Context } from './context-types.js';
|
|
6
8
|
export type { AigcCanvasService, AigcElement, AigcEdge, AigcCanvasState, AigcElementKind, } from './canvas-registry.js';
|
|
7
9
|
/** Plugin identity for cordis.yml rows. */
|
|
@@ -9,4 +11,4 @@ export declare const name = "dsh-aigc-canvas";
|
|
|
9
11
|
/** Services required before mounting. */
|
|
10
12
|
export declare const inject: string[];
|
|
11
13
|
/** Plugin body. */
|
|
12
|
-
export declare function apply(ctx: Context, config?:
|
|
14
|
+
export declare function apply(ctx: Context, config?: AigcEntryConfig): void;
|