@aryacode/dsh-arya-image-gen 0.0.0-stage → 0.20.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/LICENSE +201 -0
- package/NOTICE +24 -0
- package/README.md +292 -2
- package/cordis.patch.yml +5 -0
- package/docs/assets/readme/canvas-edit.webp +0 -0
- package/docs/assets/readme/canvas-generate.webp +0 -0
- package/docs/assets/readme/chat-example.webp +0 -0
- package/docs/assets/readme/chat-generate.webp +0 -0
- package/docs/assets/readme/comfyui-workflows.webp +0 -0
- package/docs/assets/readme/gallery-management.webp +0 -0
- package/docs/assets/readme/hero-arya-wide.webp +0 -0
- package/docs/assets/readme/hero-arya.webp +0 -0
- package/docs/assets/readme/inspiration-arya.webp +0 -0
- package/docs/assets/readme/inspiration-library.webp +0 -0
- package/docs/assets/readme/install-arya.webp +0 -0
- package/docs/assets/readme/multi-model-compare.webp +0 -0
- package/docs/assets/readme/other-features.webp +0 -0
- package/docs/assets/readme/plugin-detail.webp +0 -0
- package/docs/assets/readme/plugins-entry.webp +0 -0
- package/docs/assets/readme/regenerating.webp +0 -0
- package/docs/assets/readme/revision-switcher.webp +0 -0
- package/docs/assets/readme/studio-arya.webp +0 -0
- package/docs/assets/readme/studio-workbench.webp +0 -0
- package/docs/assets/readme/workflow-overview-en.webp +0 -0
- package/docs/assets/readme/workflow-overview.webp +0 -0
- package/docs/workflows/arya-qwen-image-pack.zip +0 -0
- package/docs/workflows/qwen-image-compose.json +1 -0
- package/docs/workflows/qwen-image-create.json +142 -0
- package/docs/workflows/qwen-image-cutout.json +142 -0
- package/docs/workflows/qwen-image-edit.json +1 -0
- package/docs/workflows/qwen-image-remove-bg.json +1 -0
- package/lib/agent-toolset.js +51 -0
- package/lib/client.js +127081 -0
- package/lib/index.js +28598 -0
- package/lib/types/agent-preset/billion-context.d.ts +150 -0
- package/lib/types/agent-preset/definition.d.ts +75 -0
- package/lib/types/agent-preset/persona.d.ts +10 -0
- package/lib/types/agent-preset/register.d.ts +40 -0
- package/lib/types/agent-preset/toolset.d.ts +36 -0
- package/lib/types/baoyu-compose.d.ts +59 -0
- package/lib/types/canvas-asset-route.d.ts +12 -0
- package/lib/types/canvas-state-route.d.ts +37 -0
- package/lib/types/canvas-state.d.ts +80 -0
- package/lib/types/canvas-tools.d.ts +44 -0
- package/lib/types/client/browser-image-utils.d.ts +23 -0
- package/lib/types/client/conversation-image-revisions.d.ts +24 -0
- package/lib/types/client/conversation-regenerate.d.ts +8 -0
- package/lib/types/client/gallery-store.d.ts +137 -0
- package/lib/types/client/gallery-view.d.ts +255 -0
- package/lib/types/client/generation-activity.d.ts +62 -0
- package/lib/types/client/image-cache.d.ts +26 -0
- package/lib/types/client/image-ref.d.ts +31 -0
- package/lib/types/client/image-result-node.d.ts +81 -0
- package/lib/types/client/index.d.ts +113 -0
- package/lib/types/client/inspiration-catalog-cache.d.ts +4 -0
- package/lib/types/client/inspiration-image-cache.d.ts +3 -0
- package/lib/types/client/inspiration-style.d.ts +1 -0
- package/lib/types/client/inspiration-view.d.ts +9 -0
- package/lib/types/client/multi-model-compare.d.ts +20 -0
- package/lib/types/client/settings-state.d.ts +12 -0
- package/lib/types/client/settings-write.d.ts +4 -0
- package/lib/types/client/studio-style.d.ts +1 -0
- package/lib/types/client/studio-view.d.ts +48 -0
- package/lib/types/client/tl/canvas-selection.d.ts +13 -0
- package/lib/types/client/tl/canvas-sync.d.ts +30 -0
- package/lib/types/client/tl/conversation-landings.d.ts +48 -0
- package/lib/types/client/tl/css-supports-shim.d.ts +21 -0
- package/lib/types/client/tl/gallery-canvas-button.d.ts +10 -0
- package/lib/types/client/tl/gallery-image-transfer.d.ts +12 -0
- package/lib/types/client/tl/studio-tl-canvas.d.ts +16 -0
- package/lib/types/client/tl/tl-brand-theme.d.ts +10 -0
- package/lib/types/client/tl/tl-brand-tokens.d.ts +24 -0
- package/lib/types/client/tl/tl-canvas-bridge.d.ts +39 -0
- package/lib/types/client/tl/tl-css.d.ts +2 -0
- package/lib/types/client/tl/tl-theme-css.d.ts +17 -0
- package/lib/types/comfyui-progress.d.ts +78 -0
- package/lib/types/comfyui-server-route.d.ts +10 -0
- package/lib/types/comfyui-server.d.ts +61 -0
- package/lib/types/comfyui-workflow.d.ts +80 -0
- package/lib/types/comfyui.d.ts +52 -0
- package/lib/types/config.d.ts +87 -0
- package/lib/types/fetch-diagnostics.d.ts +10 -0
- package/lib/types/generated/default-workflows.d.ts +16 -0
- package/lib/types/image-route.d.ts +35 -0
- package/lib/types/image-tool-context.d.ts +3 -0
- package/lib/types/import-route.d.ts +16 -0
- package/lib/types/index.d.ts +16 -0
- package/lib/types/inspiration-route.d.ts +6 -0
- package/lib/types/inspiration.d.ts +92 -0
- package/lib/types/progress-route.d.ts +10 -0
- package/lib/types/redact.d.ts +2 -0
- package/lib/types/reference-image.d.ts +56 -0
- package/lib/types/reference-import.d.ts +66 -0
- package/lib/types/save-generated.d.ts +83 -0
- package/lib/types/settings-health.d.ts +6 -0
- package/lib/types/shared.d.ts +519 -0
- package/lib/types/studio-route.d.ts +15 -0
- package/lib/types/studio.d.ts +14 -0
- package/lib/types/validate-workflows.d.ts +48 -0
- package/lib/types/workspace-save.d.ts +103 -0
- package/package.json +143 -5
- package/skills/arya-image-references/SKILL.md +74 -0
- package/skills/arya-image-workflows/SKILL.md +75 -0
- package/skills/install-arya-image-gen/SKILL.md +28 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* billion-context's compaction gate, as this bundle can observe it.
|
|
3
|
+
*
|
|
4
|
+
* `billion-context` ("bili") is an HTTP proxy plus a DSH plugin bundle that
|
|
5
|
+
* compresses the outgoing model request. It owns the context lane when it runs,
|
|
6
|
+
* so an Arya preset that mounts its own summarizer would put two compressors on
|
|
7
|
+
* one history. bili enforces that for the shipped presets by disabling the
|
|
8
|
+
* `@deepseek-ai/dsh-compaction-basic` and `@deepseek-ai/dsh-command-compact`
|
|
9
|
+
* rows by package name; the Arya Image preset mounts the same stock rows, and
|
|
10
|
+
* this module is how the definition learns to stand down instead.
|
|
11
|
+
*
|
|
12
|
+
* Two facts must BOTH hold before the preset stands down:
|
|
13
|
+
*
|
|
14
|
+
* 1. `ctx.get('biliBasicCompactionPolicy')` resolves - the service bili's
|
|
15
|
+
* always-on `bili-compaction-gate` entry publishes;
|
|
16
|
+
* 2. `globalThis.__BILI_DSH_COMPACTION_VERDICT__ === 'active'` - the verdict
|
|
17
|
+
* `bili-native`'s `apply()` declares once its plan keeps the lane owned.
|
|
18
|
+
*
|
|
19
|
+
* Neither is a published contract. `biliBasicCompactionPolicy` is an internal
|
|
20
|
+
* service name and the verdict is a global convention between two bili entries,
|
|
21
|
+
* so every reference here is wrapped in a constant, absence is fail-open (the
|
|
22
|
+
* stock rows run), and the warning is one line, never a throw.
|
|
23
|
+
*
|
|
24
|
+
* This is a DEFINITION-TIME stand-down, not an `internal/config` overlay. The
|
|
25
|
+
* overlay bili registers at load time walks resolved entry configs; a preset
|
|
26
|
+
* registered through the Host's `agentPresets.register()` is not an entry, so
|
|
27
|
+
* that overlay cannot reach it. The definition reads the gate once, just before
|
|
28
|
+
* it is built, which is also the only place a row can be written `disabled`.
|
|
29
|
+
*
|
|
30
|
+
* Timing: when bili is expected but its gate has not published yet, wait 25 ms
|
|
31
|
+
* per tick for up to 2000 ms. Once the service appears, allow 500 ms for the
|
|
32
|
+
* `active` verdict. Timeout, a missing service or an inactive verdict all mean
|
|
33
|
+
* "keep the stock rows", with one warning, because a double compressor is better
|
|
34
|
+
* than silently disabling compaction when bili is not actually compressing.
|
|
35
|
+
*
|
|
36
|
+
* @module @aryacode/dsh-arya-image-gen/agent-preset/billion-context
|
|
37
|
+
*/
|
|
38
|
+
/** The service bili's always-on gate entry publishes. Internal; bili 0.1.212. */
|
|
39
|
+
export declare const BILI_GATE_SERVICE = "biliBasicCompactionPolicy";
|
|
40
|
+
/** The process-global verdict bili-native sets when it owns the context lane. */
|
|
41
|
+
export declare const BILI_VERDICT_GLOBAL = "__BILI_DSH_COMPACTION_VERDICT__";
|
|
42
|
+
/** The only verdict value that means bili is compressing this process. */
|
|
43
|
+
export declare const BILI_VERDICT_ACTIVE = "active";
|
|
44
|
+
/** The bundle package name that marks bili as installed in the profile. */
|
|
45
|
+
export declare const BILI_BUNDLE_NAME = "billion-context";
|
|
46
|
+
/**
|
|
47
|
+
* Environment variables that name an attach-mode proxy. A launcher (`bili dsh`)
|
|
48
|
+
* or an explicit attach owns routing this way, which means bili is compressing
|
|
49
|
+
* even when the bundle is not listed in the profile.
|
|
50
|
+
*/
|
|
51
|
+
export declare const BILI_ATTACH_ENV: readonly string[];
|
|
52
|
+
/**
|
|
53
|
+
* Environment kill switches bili itself honors (`=== '0'`): with either set,
|
|
54
|
+
* `bili-native` plans `mode: "off"`, never declares the verdict, and hands the
|
|
55
|
+
* lane back to stock DSH compaction.
|
|
56
|
+
*/
|
|
57
|
+
export declare const BILI_KILL_ENV: readonly string[];
|
|
58
|
+
/**
|
|
59
|
+
* Environment variable that stands the native plugin down whenever it is
|
|
60
|
+
* defined at all (bili reads `!== undefined`, not a boolean value).
|
|
61
|
+
*/
|
|
62
|
+
export declare const BILI_REWRITES_ENV = "BILI_PROVIDER_REWRITES";
|
|
63
|
+
/** Poll cadence and the two waits, in milliseconds. */
|
|
64
|
+
export declare const BILI_TIMING: Readonly<{
|
|
65
|
+
pollMs: 25;
|
|
66
|
+
gateMs: 2000;
|
|
67
|
+
verdictMs: 500;
|
|
68
|
+
}>;
|
|
69
|
+
/** The one warning logged when bili is expected but its gate never latched. */
|
|
70
|
+
export declare const BILI_STAND_DOWN_WARNING = "billion-context is installed but its compaction gate did not become active; keeping the Arya Image stock compaction rows mounted";
|
|
71
|
+
/** The logger slice this module uses. */
|
|
72
|
+
export interface BiliLogger {
|
|
73
|
+
info?: (message: string) => void;
|
|
74
|
+
warn?: (message: string) => void;
|
|
75
|
+
}
|
|
76
|
+
/** The host surface this module reads. */
|
|
77
|
+
export interface StandDownHost {
|
|
78
|
+
/** Reads an optional host service; a missing service reads as undefined. */
|
|
79
|
+
get(serviceName: string): unknown;
|
|
80
|
+
/** Logger for the stand-down decision. */
|
|
81
|
+
logger?: BiliLogger;
|
|
82
|
+
}
|
|
83
|
+
/** The two waits and the poll cadence, in milliseconds. */
|
|
84
|
+
export interface BiliTiming {
|
|
85
|
+
pollMs?: number;
|
|
86
|
+
gateMs?: number;
|
|
87
|
+
verdictMs?: number;
|
|
88
|
+
}
|
|
89
|
+
/** Facts and test seams for {@link resolveStandDown}; production passes none. */
|
|
90
|
+
export interface StandDownOptions {
|
|
91
|
+
/** Host profile facts; defaults to the `profileContext` service. */
|
|
92
|
+
profileContext?: unknown;
|
|
93
|
+
/** Environment to read; defaults to `process.env`. */
|
|
94
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
95
|
+
/** Object carrying the verdict global; defaults to `globalThis`. */
|
|
96
|
+
scope?: unknown;
|
|
97
|
+
/** Wait between polls; defaults to a real timer. */
|
|
98
|
+
sleep?: (milliseconds: number) => Promise<unknown>;
|
|
99
|
+
/** Poll cadence and wait budgets. */
|
|
100
|
+
timing?: BiliTiming;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Whether bili's own kill switches say the native plugin is off.
|
|
104
|
+
*
|
|
105
|
+
* Mirrors `planNativeDsh()` in bili's `dist/agent/dsh-native.js`: the two
|
|
106
|
+
* switches are compared with `=== '0'`, and a DEFINED `BILI_PROVIDER_REWRITES`
|
|
107
|
+
* is enough (console/value irrelevant).
|
|
108
|
+
*
|
|
109
|
+
* @param env - environment to read; defaults to `process.env`.
|
|
110
|
+
* @returns true when bili cannot be compressing this process.
|
|
111
|
+
*/
|
|
112
|
+
export declare function isBiliKillSwitched(env?: Readonly<Record<string, string | undefined>>): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Whether this process should expect bili to own compaction.
|
|
115
|
+
*
|
|
116
|
+
* Three signals, in bili's own precedence: kill switches first (they outrank
|
|
117
|
+
* the attach variables in `planNativeDsh`), then an attach-mode proxy from the
|
|
118
|
+
* environment, then the mounted profile's startup bundles, then the parsed
|
|
119
|
+
* `--patch` overlays.
|
|
120
|
+
*
|
|
121
|
+
* A profile that simply lists `billion-context` in `dsh.profile.bundles` is the
|
|
122
|
+
* common case: the bundle layer mounts the gate entry whether or not
|
|
123
|
+
* `bili-native` is enabled, so the negative case still has to be detected
|
|
124
|
+
* through the kill switches rather than the bundle.
|
|
125
|
+
*
|
|
126
|
+
* @param profileContext - the Host's `profileContext` service, or anything else.
|
|
127
|
+
* @param env - environment to read; defaults to `process.env`.
|
|
128
|
+
* @returns true when bili is expected to compress this process.
|
|
129
|
+
*/
|
|
130
|
+
export declare function isBiliExpected(profileContext: unknown, env?: Readonly<Record<string, string | undefined>>): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Whether bili-native declared this process's lane owned.
|
|
133
|
+
*
|
|
134
|
+
* @param scope - the global scope to read; `globalThis` by default.
|
|
135
|
+
* @returns true for the exact `'active'` verdict.
|
|
136
|
+
*/
|
|
137
|
+
export declare function isBiliVerdictActive(scope?: unknown): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Whether the definition should disable its two stock compaction summary rows.
|
|
140
|
+
*
|
|
141
|
+
* Call this once, immediately before building a preset definition, and pass the
|
|
142
|
+
* result as `standDownCompaction`. The function never rejects and never throws:
|
|
143
|
+
* any unexpected failure resolves to `false` (keep the rows), because a
|
|
144
|
+
* duplicate summarizer is recoverable and a silently missing one is not.
|
|
145
|
+
*
|
|
146
|
+
* @param host - the feature's context surface (only `get` and `logger` are read).
|
|
147
|
+
* @param options - test seams; production passes none.
|
|
148
|
+
* @returns true only when bili's gate service exists AND its verdict is `active`.
|
|
149
|
+
*/
|
|
150
|
+
export declare function resolveStandDown(host: StandDownHost, options?: StandDownOptions): Promise<boolean>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** The preset id sessions record in their header. */
|
|
2
|
+
export declare const ARYA_IMAGE_PRESET_ID = "arya-image";
|
|
3
|
+
/** The name the preset picker shows. */
|
|
4
|
+
export declare const ARYA_IMAGE_PRESET_NAME = "Arya Image";
|
|
5
|
+
/** One line under the name in the picker. */
|
|
6
|
+
export declare const ARYA_IMAGE_PRESET_DESCRIPTION = "Image work with the image tools and a small core tool set; everything else stays out of the prompt.";
|
|
7
|
+
/** Sort position right after Arya Standard (2), where the image work belongs. */
|
|
8
|
+
export declare const ARYA_IMAGE_PRESET_ORDER = 2.5;
|
|
9
|
+
/** Row id of the tool-mask row inside the preset. */
|
|
10
|
+
export declare const ARYA_IMAGE_TOOLSET_ROW_ID = "arya-image-toolset";
|
|
11
|
+
/** Package subpath the tool-mask row mounts. */
|
|
12
|
+
export declare const ARYA_IMAGE_TOOLSET_MODULE = "@aryacode/dsh-arya-image-gen/agent-toolset";
|
|
13
|
+
/** One plugin row in a preset definition. */
|
|
14
|
+
export interface PresetRow {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
config?: unknown;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/** Marks a nested `cordis:group` row whose `config` is its child rows. */
|
|
20
|
+
group?: boolean;
|
|
21
|
+
/** Services the group provides in its own realm. */
|
|
22
|
+
isolate?: Record<string, true | string>;
|
|
23
|
+
}
|
|
24
|
+
/** The definition shape `agentPresets.register()` accepts. */
|
|
25
|
+
export interface AgentPresetDefinition {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
description: string;
|
|
29
|
+
order: number;
|
|
30
|
+
plugins: PresetRow[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The host tools an image session keeps beside the image tools.
|
|
34
|
+
*
|
|
35
|
+
* `working_directory` is absent from the preset's rows: the host mounts it
|
|
36
|
+
* globally, so the mask is what keeps it.
|
|
37
|
+
*
|
|
38
|
+
* @param platform - `process.platform` value of the host.
|
|
39
|
+
* @returns the global tool names the mask keeps.
|
|
40
|
+
*/
|
|
41
|
+
export declare function coreToolNames(platform: string): readonly string[];
|
|
42
|
+
/**
|
|
43
|
+
* The allow list handed to the mask row: the image tools plus the core set.
|
|
44
|
+
*
|
|
45
|
+
* @param platform - `process.platform` value of the host.
|
|
46
|
+
* @returns the global tool names the mask keeps.
|
|
47
|
+
*/
|
|
48
|
+
export declare function agentPresetAllowList(platform: string): string[];
|
|
49
|
+
/**
|
|
50
|
+
* The rows that give the session its tools.
|
|
51
|
+
*
|
|
52
|
+
* The working set is deliberately small: an image session that also carries
|
|
53
|
+
* goals, skills, plan mode, delegation, scheduling and a todo list spends
|
|
54
|
+
* prompt budget and decision space on tools it will not use. The compaction
|
|
55
|
+
* group stays - it mounts no tools, and it keeps the session's summarization
|
|
56
|
+
* and the billion-context stand-down working.
|
|
57
|
+
*
|
|
58
|
+
* @param platform - `process.platform` value of the host.
|
|
59
|
+
* @param standDownCompaction - whether billion-context owns compaction, so the
|
|
60
|
+
* stock summary rows must not run beside it.
|
|
61
|
+
* @returns the rows, in mount order.
|
|
62
|
+
*/
|
|
63
|
+
export declare function presetToolRows(platform: string, standDownCompaction?: boolean): PresetRow[];
|
|
64
|
+
/**
|
|
65
|
+
* Build the preset definition.
|
|
66
|
+
*
|
|
67
|
+
* @param options - host facts the definition depends on.
|
|
68
|
+
* @param options.platform - `process.platform` value of the host.
|
|
69
|
+
* @param options.standDownCompaction - whether billion-context owns compaction.
|
|
70
|
+
* @returns a definition `agentPresets.register()` accepts.
|
|
71
|
+
*/
|
|
72
|
+
export declare function buildAgentPresetDefinition(options: {
|
|
73
|
+
platform: string;
|
|
74
|
+
standDownCompaction?: boolean;
|
|
75
|
+
}): AgentPresetDefinition;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persona for the Arya Image preset.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately short: every token here is paid on every request, and the
|
|
5
|
+
* preset exists to keep an image session cheap. The tool descriptions own the
|
|
6
|
+
* operational detail (when to use edit_image, what a canvas selection means),
|
|
7
|
+
* so this text carries identity and posture only - plus the one research rule
|
|
8
|
+
* that makes a real subject come out right instead of approximated.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ARYA_IMAGE_PERSONA: string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Register the Arya Image preset with the host's preset registry.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the pattern the AryaCode presets use (see
|
|
5
|
+
* `dsh-aryacode-polish/presets/arya-standard/plugin.js`): the mount point is a
|
|
6
|
+
* plugin whose `inject` names the registry, so the Loader holds it until
|
|
7
|
+
* `agentPresets` exists and the registration lands while the composition is
|
|
8
|
+
* still settling. Registering from inside `apply()` with `ctx.inject()` is not
|
|
9
|
+
* equivalent: that callback can run after the Loader has settled, which is late
|
|
10
|
+
* enough for a preset list already read by the client to miss the new entry.
|
|
11
|
+
*
|
|
12
|
+
* Optional surface: a composition without `agentPresets` (headless, SDK) is a
|
|
13
|
+
* valid composition, so the service is looked up and skipped when absent.
|
|
14
|
+
* Registration is released with this plugin's fiber; a duplicate id is logged
|
|
15
|
+
* and dropped, because the preset already mounted is the one sessions are using.
|
|
16
|
+
*
|
|
17
|
+
* The mount is asynchronous because the compaction owner has to be settled
|
|
18
|
+
* first: when billion-context owns compaction, the definition is built with its
|
|
19
|
+
* stock summary rows disabled. The wait never exceeds the resolver's bounded
|
|
20
|
+
* poll, and a fiber that is disposed while waiting registers nothing.
|
|
21
|
+
*
|
|
22
|
+
* @module @aryacode/dsh-arya-image-gen/agent-preset/register
|
|
23
|
+
*/
|
|
24
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
25
|
+
/** Row configuration for the mount point. */
|
|
26
|
+
export interface AgentPresetMountConfig {
|
|
27
|
+
/** `process.platform` of the host; decides which shell tool the mask keeps. */
|
|
28
|
+
platform?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Mount the preset: register the definition and release it with this fiber.
|
|
32
|
+
*
|
|
33
|
+
* Awaits the billion-context compaction decision before building the definition,
|
|
34
|
+
* so a preset that loses its summary rows to another engine is registered once,
|
|
35
|
+
* in its final shape. A fiber disposed during that wait is not registered at all.
|
|
36
|
+
*
|
|
37
|
+
* @param ctx - the mount point's context, with `agentPresets` injected.
|
|
38
|
+
* @param config - host facts the definition depends on.
|
|
39
|
+
*/
|
|
40
|
+
export declare function mountAgentPreset(ctx: Context, config?: AgentPresetMountConfig): Promise<void>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Arya Image preset's tool mask.
|
|
3
|
+
*
|
|
4
|
+
* Mounted as a row inside the preset, so this context is the agent's scope:
|
|
5
|
+
* `ctx.tools.restrict({ allow })` then hides every inherited tool not named in
|
|
6
|
+
* the list, while the preset's own rows stay visible.
|
|
7
|
+
*
|
|
8
|
+
* Which names are legal is decided by `restrict()` itself, against the tools
|
|
9
|
+
* this scope can actually restrict - the inherited global layer plus every
|
|
10
|
+
* ancestor on the chain. It is NOT `ctx.tools.get(name)`: that answers from the
|
|
11
|
+
* global view only, and once presets moved their rows onto the agent plane the
|
|
12
|
+
* host's own tools became an ancestor contribution, invisible to `get()`. A
|
|
13
|
+
* presence filter built on `get()` therefore strips `read`, `write`, `pwsh`,
|
|
14
|
+
* `web_search` and the rest, leaving a mask that hides everything the preset
|
|
15
|
+
* was supposed to keep.
|
|
16
|
+
*
|
|
17
|
+
* Fail-open on purpose. A mask that cannot be applied (no agent scope, a names
|
|
18
|
+
* list the registry refuses) must leave the session exactly as it was - a
|
|
19
|
+
* session that loses its tools is worse than a session that pays for a few
|
|
20
|
+
* extra schemas.
|
|
21
|
+
*
|
|
22
|
+
* @module @aryacode/dsh-arya-image-gen/agent-toolset
|
|
23
|
+
*/
|
|
24
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
25
|
+
/** Row configuration: the global tool names that stay visible. */
|
|
26
|
+
export interface ToolsetConfig {
|
|
27
|
+
allow?: readonly string[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Apply the allow mask.
|
|
31
|
+
*
|
|
32
|
+
* @param ctx - the row's context, which must resolve to the agent scope.
|
|
33
|
+
* @param config - the row configuration from the preset definition.
|
|
34
|
+
*/
|
|
35
|
+
export declare function apply(ctx: Context, config?: ToolsetConfig): void;
|
|
36
|
+
export declare const inject: string[];
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** Pseudo inspiration source id that switches the view into composer mode. */
|
|
2
|
+
export declare const BAOYU_COMPOSER_SOURCE_ID = "baoyu-compose";
|
|
3
|
+
export interface BaoyuPaletteColor {
|
|
4
|
+
role: string;
|
|
5
|
+
name: string;
|
|
6
|
+
hex: string;
|
|
7
|
+
}
|
|
8
|
+
export interface BaoyuPalette {
|
|
9
|
+
id: string;
|
|
10
|
+
tagline: string;
|
|
11
|
+
colors: BaoyuPaletteColor[];
|
|
12
|
+
decorativeHints: string[];
|
|
13
|
+
bestFor: string;
|
|
14
|
+
pairs?: {
|
|
15
|
+
name: string;
|
|
16
|
+
a: string;
|
|
17
|
+
b: string;
|
|
18
|
+
feel: string;
|
|
19
|
+
}[];
|
|
20
|
+
}
|
|
21
|
+
export interface BaoyuRendering {
|
|
22
|
+
id: string;
|
|
23
|
+
tagline: string;
|
|
24
|
+
lines: string[];
|
|
25
|
+
texture: string[];
|
|
26
|
+
depth: string[];
|
|
27
|
+
elements: string[];
|
|
28
|
+
}
|
|
29
|
+
export interface BaoyuType {
|
|
30
|
+
id: string;
|
|
31
|
+
description: string;
|
|
32
|
+
composition: string;
|
|
33
|
+
}
|
|
34
|
+
export interface BaoyuMood {
|
|
35
|
+
id: string;
|
|
36
|
+
application: string;
|
|
37
|
+
}
|
|
38
|
+
export interface BaoyuTextLevel {
|
|
39
|
+
id: string;
|
|
40
|
+
area: string;
|
|
41
|
+
}
|
|
42
|
+
export interface BaoyuSelection {
|
|
43
|
+
type: string;
|
|
44
|
+
palette: string;
|
|
45
|
+
rendering: string;
|
|
46
|
+
text: string;
|
|
47
|
+
mood: string;
|
|
48
|
+
title: string;
|
|
49
|
+
}
|
|
50
|
+
export declare const BAOYU_TYPES: BaoyuType[];
|
|
51
|
+
export declare const BAOYU_PALETTES: BaoyuPalette[];
|
|
52
|
+
export declare const BAOYU_RENDERINGS: BaoyuRendering[];
|
|
53
|
+
export declare const BAOYU_TEXT_LEVELS: BaoyuTextLevel[];
|
|
54
|
+
export declare const BAOYU_MOODS: BaoyuMood[];
|
|
55
|
+
export declare const BAOYU_DEFAULT_SELECTION: BaoyuSelection;
|
|
56
|
+
/** Assemble the five-dimension selection into one generate_image-ready prompt. */
|
|
57
|
+
export declare function composeBaoyuPrompt(selection: BaoyuSelection): string;
|
|
58
|
+
/** Randomize every visual dimension, keeping the current title text. */
|
|
59
|
+
export declare function randomBaoyuSelection(current: BaoyuSelection): BaoyuSelection;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Selected originals are uploaded individually; previews stay memory-only. */
|
|
2
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
+
import type { ImageAttachmentRef, ImageMediaType } from '@deepseek-ai/dsh-attachment';
|
|
4
|
+
export interface CanvasAssetRouteDeps {
|
|
5
|
+
maxImageBytes: number;
|
|
6
|
+
/** Host validates image contents/dimensions and content-addresses the bytes. */
|
|
7
|
+
saveImage(image: {
|
|
8
|
+
data: Uint8Array;
|
|
9
|
+
mediaType: ImageMediaType;
|
|
10
|
+
}): Promise<ImageAttachmentRef>;
|
|
11
|
+
}
|
|
12
|
+
export declare function serveCanvasAsset(req: IncomingMessage, res: ServerResponse, deps: CanvasAssetRouteDeps): Promise<void>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Same-origin HTTP route receiving live canvas-state pushes from the
|
|
3
|
+
* workbench infinite canvas in the browser.
|
|
4
|
+
*
|
|
5
|
+
* The browser owns the tldraw canvas; this route is the only door that state
|
|
6
|
+
* enters the host process through. Every push is validated end to end
|
|
7
|
+
* (origin, method, body size, field shapes, embedded image bytes) before it
|
|
8
|
+
* reaches the mirror. Selection screenshots stay in memory: the mirror holds
|
|
9
|
+
* the decoded bytes and a tool persists them only when the model actually
|
|
10
|
+
* consumes them (view_canvas), so dead screenshots never hit the disk.
|
|
11
|
+
*/
|
|
12
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
13
|
+
import type { ImageMediaType } from '@deepseek-ai/dsh-attachment';
|
|
14
|
+
import { type CanvasStatePush } from './shared.js';
|
|
15
|
+
import type { CanvasMirror } from './canvas-state.js';
|
|
16
|
+
/** Dependencies required by the canvas-state route. */
|
|
17
|
+
export interface CanvasStateRouteDeps {
|
|
18
|
+
mirror: CanvasMirror;
|
|
19
|
+
/** Hard cap for the JSON body; sized by the caller from the attachment limits. */
|
|
20
|
+
maxBodyBytes: number;
|
|
21
|
+
/** Largest accepted selection screenshot in bytes. */
|
|
22
|
+
maxImageBytes: number;
|
|
23
|
+
}
|
|
24
|
+
/** Serve one canvas-state push. */
|
|
25
|
+
export declare function serveCanvasState(req: IncomingMessage, res: ServerResponse, deps: CanvasStateRouteDeps): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Validate one untrusted canvas-state push at the HTTP boundary.
|
|
28
|
+
* Returns a normalized copy, or undefined when any field is malformed.
|
|
29
|
+
* Present-but-malformed known fields reject the whole push: they signal a
|
|
30
|
+
* client/server version skew rather than a legitimately absent value.
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseCanvasStatePush(value: unknown): CanvasStatePush | undefined;
|
|
33
|
+
/** Decode and sanity-check an embedded selection screenshot data URL. */
|
|
34
|
+
export declare function decodeSelectionImage(dataUrl: string): {
|
|
35
|
+
data: Uint8Array;
|
|
36
|
+
mediaType: ImageMediaType;
|
|
37
|
+
} | undefined;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory mirror of the workbench infinite canvas.
|
|
3
|
+
*
|
|
4
|
+
* The tldraw canvas lives in the browser; the conversation agent lives in the
|
|
5
|
+
* host process. Browser instances push compact `CanvasStatePush` snapshots
|
|
6
|
+
* through the canvas-state route, and this mirror is the host-side truth the
|
|
7
|
+
* system-prompt digest, the canvas_state / view_canvas tools, and the
|
|
8
|
+
* edit_image `canvas_selection` source all read from. Nothing here is
|
|
9
|
+
* persisted: the mirror dies with the host process, matching the canvas's
|
|
10
|
+
* own session-scratch semantics.
|
|
11
|
+
*/
|
|
12
|
+
import type { ImageMediaType } from '@deepseek-ai/dsh-attachment';
|
|
13
|
+
import { type CanvasNodeSummary, type CanvasStatePush } from './shared.js';
|
|
14
|
+
/**
|
|
15
|
+
* Decoded selection screenshot held in memory only. Nothing touches the
|
|
16
|
+
* durable attachment store until a tool actually consumes it: most
|
|
17
|
+
* screenshots are replaced within seconds (selection changed) or die with
|
|
18
|
+
* the canvas (closed), and the immutable content-addressed store has no
|
|
19
|
+
* deletion — persisting them eagerly would leak disk forever.
|
|
20
|
+
*/
|
|
21
|
+
export interface CanvasSelectionImage {
|
|
22
|
+
data: Uint8Array;
|
|
23
|
+
mediaType: ImageMediaType;
|
|
24
|
+
}
|
|
25
|
+
/** Server-side view of one client push after validation. */
|
|
26
|
+
export interface CanvasMirrorEntry {
|
|
27
|
+
clientInstance: string;
|
|
28
|
+
connected: true;
|
|
29
|
+
nodeCount: number;
|
|
30
|
+
nodes: readonly CanvasNodeSummary[];
|
|
31
|
+
selectionCount: number;
|
|
32
|
+
selectionKinds: readonly string[];
|
|
33
|
+
/** Capped identity list of the selected shapes (name, attachment id, ...). */
|
|
34
|
+
selectionItems: readonly CanvasNodeSummary[];
|
|
35
|
+
/**
|
|
36
|
+
* Identity-bearing selection signature (count + kinds + item identities).
|
|
37
|
+
* Two selections of different shapes never share it, so a stale screenshot
|
|
38
|
+
* is never kept across a selection swap — even when count and kinds match.
|
|
39
|
+
*/
|
|
40
|
+
selectionSignature: string;
|
|
41
|
+
/** In-memory screenshot of the current selection, when one was pushed. */
|
|
42
|
+
selectionImage?: CanvasSelectionImage;
|
|
43
|
+
selectionStatus?: CanvasStatePush['selectionStatus'];
|
|
44
|
+
selectionError?: string;
|
|
45
|
+
/** Mirror receive time, used for the digest's "updated N ago" line. */
|
|
46
|
+
receivedAt: number;
|
|
47
|
+
/** Monotonic apply counter; `latest()` prefers the most recently applied instance. */
|
|
48
|
+
seq: number;
|
|
49
|
+
updatedAt: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Host-side mirror of every currently connected workbench canvas.
|
|
53
|
+
*
|
|
54
|
+
* One instance is shared by the canvas-state route, the canvas tools, and the
|
|
55
|
+
* system-prompt context registration. More than one canvas can be mounted at
|
|
56
|
+
* once (right-sidebar studio tab, conversation gallery tab); each instance
|
|
57
|
+
* pushes under its own `clientInstance` id and `latest()` reads the freshest.
|
|
58
|
+
*/
|
|
59
|
+
export declare class CanvasMirror {
|
|
60
|
+
private readonly entries;
|
|
61
|
+
private readonly sequences;
|
|
62
|
+
private nextSeq;
|
|
63
|
+
/**
|
|
64
|
+
* Apply one validated push. A disconnect removes the instance; an unchanged
|
|
65
|
+
* selection keeps the previously received screenshot bytes so the model can
|
|
66
|
+
* still view them while unrelated canvas edits keep flowing in.
|
|
67
|
+
*/
|
|
68
|
+
apply(push: CanvasStatePush, selectionImage?: CanvasSelectionImage): void;
|
|
69
|
+
/** The freshest connected canvas entry, or undefined. */
|
|
70
|
+
latest(): CanvasMirrorEntry | undefined;
|
|
71
|
+
/** The in-memory selection screenshot of the freshest canvas, if present. */
|
|
72
|
+
latestSelectionImage(): CanvasSelectionImage | undefined;
|
|
73
|
+
/** Whether any canvas instance is currently connected. */
|
|
74
|
+
connected(): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Compact one-screen digest of the canvas for the system prompt and tools.
|
|
77
|
+
* Evaluated per call so the "updated N ago" line stays current between pushes.
|
|
78
|
+
*/
|
|
79
|
+
digest(now?: number): string;
|
|
80
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-facing tools over the mirrored workbench canvas state.
|
|
3
|
+
*
|
|
4
|
+
* `canvas_state` answers "what is on the canvas right now" with a compact
|
|
5
|
+
* inventory; `view_canvas` returns the latest selection screenshot as a real
|
|
6
|
+
* image block so the model can look at hand-drawn sketches and annotated
|
|
7
|
+
* selections the way it looks at any conversation image. Both tools stay
|
|
8
|
+
* registered when no canvas is connected — their answers then tell the model
|
|
9
|
+
* to ask the user to open the workbench instead of failing silently.
|
|
10
|
+
*/
|
|
11
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
12
|
+
import type { ImageAttachmentRef, StoredImageAttachment } from '@deepseek-ai/dsh-attachment';
|
|
13
|
+
import type { CanvasMirror, CanvasSelectionImage } from './canvas-state.js';
|
|
14
|
+
import type { ReferenceImageAgent, ResolvedReferenceImage } from './reference-image.js';
|
|
15
|
+
/** The small attachment surface the canvas-selection resolver needs. */
|
|
16
|
+
export type CanvasSelectionImageStore = {
|
|
17
|
+
readImage(ref: ImageAttachmentRef, signal?: AbortSignal): Promise<StoredImageAttachment>;
|
|
18
|
+
};
|
|
19
|
+
/** Dependencies of the canvas tools beyond the mirror itself. */
|
|
20
|
+
export interface CanvasToolsDeps {
|
|
21
|
+
/**
|
|
22
|
+
* Materializes an in-memory selection screenshot as a durable attachment.
|
|
23
|
+
* Called by view_canvas only, at the moment the image actually enters the
|
|
24
|
+
* conversation — the durable store is content-addressed, so repeated views
|
|
25
|
+
* of the same bytes reuse one object and dead screenshots never persist.
|
|
26
|
+
*/
|
|
27
|
+
persistSelectionImage(image: CanvasSelectionImage): Promise<ImageAttachmentRef>;
|
|
28
|
+
}
|
|
29
|
+
/** Register the canvas tools on a context that owns a canvas mirror. */
|
|
30
|
+
export declare function registerCanvasTools(ctx: Context, mirror: CanvasMirror, deps: CanvasToolsDeps): void;
|
|
31
|
+
/**
|
|
32
|
+
* Resolve the mirrored canvas selection as an edit reference image for
|
|
33
|
+
* edit_image's `canvas_selection` source. The screenshot comes straight from
|
|
34
|
+
* the mirror's in-memory bytes — identical to what view_canvas shows the
|
|
35
|
+
* model — and is never persisted here: reference images go to the image
|
|
36
|
+
* provider, not the conversation.
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveCanvasSelectionReferences(input: {
|
|
39
|
+
mirror: CanvasMirror;
|
|
40
|
+
attachments: CanvasSelectionImageStore;
|
|
41
|
+
agent?: ReferenceImageAgent;
|
|
42
|
+
maxBytes?: number;
|
|
43
|
+
signal: AbortSignal;
|
|
44
|
+
}): Promise<ResolvedReferenceImage[]>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared browser image and DOM helpers for client views.
|
|
3
|
+
* Completely decoupled from gallery-view and studio-view to prevent circular dependencies.
|
|
4
|
+
*/
|
|
5
|
+
/** Convert a Blob to a data URL. Used for tldraw image assets, which need a
|
|
6
|
+
* self-contained src; the session canvas keeps them in memory only (no
|
|
7
|
+
* persistenceKey, nothing touches disk). */
|
|
8
|
+
export declare function blobToDataUrl(blob: Blob): Promise<string>;
|
|
9
|
+
/** Copy an image Blob to the OS clipboard, converting to PNG if required by the browser. */
|
|
10
|
+
export declare function copyImageBlob(blob: Blob): Promise<boolean>;
|
|
11
|
+
/** Safely trigger a browser file download by mounting an anchor element into the DOM. */
|
|
12
|
+
export declare function downloadBlobUrl(url: string, filename: string): void;
|
|
13
|
+
/** Human-readable relative time formatter supporting zh and en. */
|
|
14
|
+
export declare function formatRelativeTime(timestamp: number, lang: 'zh' | 'en'): string;
|
|
15
|
+
export interface ZipFileInput {
|
|
16
|
+
name: string;
|
|
17
|
+
data: Uint8Array;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Create a standard zero-compression (Store mode 0) PKZip Blob from an array of files.
|
|
21
|
+
* Zero external dependencies, pure browser ArrayBuffer/Blob, fast and universally compatible with OS extractors.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createZipBlob(files: ZipFileInput[]): Blob;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ImageAttachmentRef } from '@deepseek-ai/dsh-attachment';
|
|
2
|
+
import { type StudioProvider } from '../shared.js';
|
|
3
|
+
/** One regenerated version displayed in place of an original conversation image. */
|
|
4
|
+
export interface ConversationImageRevision {
|
|
5
|
+
attachment: ImageAttachmentRef;
|
|
6
|
+
prompt: string;
|
|
7
|
+
provider: StudioProvider;
|
|
8
|
+
/** Workflow that produced this revision. */
|
|
9
|
+
model: string;
|
|
10
|
+
output: string;
|
|
11
|
+
createdAt: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ConversationImageRevisionChain {
|
|
14
|
+
originId: string;
|
|
15
|
+
/** Zero selects the immutable conversation image; revisions use one-based positions. */
|
|
16
|
+
currentIndex: number;
|
|
17
|
+
revisions: ConversationImageRevision[];
|
|
18
|
+
}
|
|
19
|
+
/** Read the locally persisted replacement history for one immutable conversation image. */
|
|
20
|
+
export declare function loadConversationImageRevisionChain(originId: string): ConversationImageRevisionChain;
|
|
21
|
+
/** Append a generated version and make it the version shown by the conversation card. */
|
|
22
|
+
export declare function appendConversationImageRevision(originId: string, revision: ConversationImageRevision): ConversationImageRevisionChain;
|
|
23
|
+
/** Select an earlier or later version without altering the underlying conversation event. */
|
|
24
|
+
export declare function selectConversationImageRevision(originId: string, requestedIndex: number): ConversationImageRevisionChain;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type StudioGenerateRequest } from '../shared.js';
|
|
2
|
+
export interface RegeneratableImage {
|
|
3
|
+
provider: string;
|
|
4
|
+
model: string;
|
|
5
|
+
output?: string | undefined;
|
|
6
|
+
}
|
|
7
|
+
/** Build the workbench request that reproduces a conversation image with an edited prompt. */
|
|
8
|
+
export declare function conversationRegenerateRequest(image: RegeneratableImage, prompt: string): StudioGenerateRequest;
|