@aqian0/dsh-renderer 0.1.0 → 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.
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Zero-dependency streaming JSON parser and durable event extractor for
3
+ * `render_artifact` tool calls.
4
+ *
5
+ * Shared by the Conversation node assembler (`artifact-node.ts`) and the
6
+ * `ctx.resources` session-history recovery provider (`artifact-resource.ts`).
7
+ *
8
+ * @module dsh-renderer/shared/artifact-stream
9
+ */
10
+ import { type ArtifactContentKind } from './content-complexity.ts';
11
+ /** Canonical tool name matching Host registration (`src/host/artifact-tool.ts`). */
12
+ export declare const RENDER_ARTIFACT_TOOL_NAME = "render_artifact";
13
+ /** Partially decoded top-level fields from a streaming JSON object prefix. */
14
+ export interface StreamingArtifactFields {
15
+ readonly title?: string | undefined;
16
+ readonly kind?: ArtifactContentKind | undefined;
17
+ readonly lang?: string | undefined;
18
+ readonly contentBytes?: number | undefined;
19
+ readonly contentLines?: number | undefined;
20
+ }
21
+ /** Normalized complete `render_artifact` payload extracted from tool arguments. */
22
+ export interface ParsedArtifactArguments {
23
+ readonly artifactId: string;
24
+ readonly title: string;
25
+ readonly kind: ArtifactContentKind;
26
+ readonly lang: string;
27
+ readonly content: string;
28
+ readonly lines: number;
29
+ readonly bytes: number;
30
+ }
31
+ /** Logged `render_artifact` invocation extracted from a durable Session event. */
32
+ export interface LoggedRenderArtifact extends ParsedArtifactArguments {
33
+ readonly callId: string;
34
+ }
35
+ /**
36
+ * Incrementally extract top-level `title`, `kind`, `lang`, and streamed `content`
37
+ * size/line estimates from a partial JSON object produced by `tool-call-delta`.
38
+ */
39
+ export declare function extractStreamingArtifactFields(rawJsonPrefix: string): StreamingArtifactFields;
40
+ /**
41
+ * Parse and validate complete `render_artifact` arguments (either a JSON string
42
+ * from `tool/call` or a plain object from PTC `tool/ptc-dispatch*`).
43
+ */
44
+ export declare function parseArtifactToolArguments(raw: unknown): ParsedArtifactArguments | null;
45
+ /**
46
+ * Extract a complete logged `render_artifact` invocation from a durable DSH
47
+ * Session event (`tool/call`, `tool/ptc-dispatch-start`, or `tool/ptc-dispatch`).
48
+ */
49
+ export declare function extractLoggedRenderArtifact(event: {
50
+ readonly type: string;
51
+ readonly data: unknown;
52
+ }): LoggedRenderArtifact | undefined;
@@ -30,7 +30,9 @@ export interface RendererPluginConfig {
30
30
  readonly complexContentToSidebar: boolean;
31
31
  /** Register the `render_artifact` Host tool and prompt guidance so models emit standalone documents directly as streaming cards. */
32
32
  readonly enableArtifactTool: boolean;
33
- /** Automatically open settled `render_artifact` cards in the right Sidebar without waiting for a click. */
33
+ /** Register the bundled `visual-artifact` DSH skill so agents load visual craft guidance on demand and users can invoke `/visual-artifact`. */
34
+ readonly enableArtifactSkill: boolean;
35
+ /** Automatically open newly completed live `render_artifact` results in the right Sidebar (historical replays stay click-to-open). */
34
36
  readonly autoOpenArtifact: boolean;
35
37
  /** Enable the non-destructive `turnTail` fallback for raw HTML/SVG and `data:image/*` prose media. */
36
38
  readonly enableTurnMediaFallback: boolean;
@@ -39,8 +39,14 @@ export interface ContentComplexityAnalysis {
39
39
  }
40
40
  /** Minimum composite score required to collapse a fence into a Sidebar document card. */
41
41
  export declare const COMPLEX_CONTENT_SCORE_THRESHOLD = 6;
42
- /** Classify a lowercased fence language into a coarse content category. */
43
- export declare function classifyContentCategory(lang: string): ContentCategory;
42
+ /**
43
+ * Resolve whether a Markdown fence language + body should use a visual preview
44
+ * layer (`'html'` or `'svg'`), including `htm`/`xhtml`/`svg+xml` aliases and
45
+ * root-element `<svg>` sniffing inside `xml` fences.
46
+ */
47
+ export declare function resolveVisualFenceKind(lang: string, code: string): 'html' | 'svg' | null;
48
+ /** Classify a lowercased fence language (and optional body for XML `<svg>` sniffing) into a content category. */
49
+ export declare function classifyContentCategory(lang: string, code?: string): ContentCategory;
44
50
  /** Return a clean human-facing label for a fence language identifier. */
45
51
  export declare function formatFenceLanguageLabel(lang: string): string;
46
52
  /** Return an appropriate download file extension for an artifact kind + language. */
@@ -57,12 +57,37 @@ export interface ArtifactRecord {
57
57
  readonly code: string;
58
58
  readonly sessionId?: string | undefined;
59
59
  }
60
- /** Resource URI prefix used for right-Sidebar artifact tabs. */
60
+ /** Resource protocol name owned by `@aqian0/dsh-renderer` (`dsh-resource://dsh-renderer/...`). */
61
+ export declare const ARTIFACT_RESOURCE_PROTOCOL = "dsh-renderer";
62
+ /** Resource URI prefix used for in-memory / fence-backed right-Sidebar artifact tabs. */
61
63
  export declare const ARTIFACT_RESOURCE_PREFIX = "dsh-resource://dsh-renderer/artifact/";
64
+ /** Resource URI prefix used for durable Session-backed `render_artifact` tool-call tabs. */
65
+ export declare const ARTIFACT_CALL_RESOURCE_PREFIX = "dsh-resource://dsh-renderer/call/";
66
+ /** Session coordinate encoding used in durable `render_artifact` resource addresses. */
67
+ export type ArtifactSessionAddress = {
68
+ readonly kind: 'session';
69
+ readonly sessionId: string;
70
+ } | {
71
+ readonly kind: 'subagent';
72
+ readonly parentSessionId: string;
73
+ readonly childSessionId: string;
74
+ readonly mode: 'one-shot' | 'continuable' | 'unknown';
75
+ };
76
+ /** Parsed durable `render_artifact` call resource address. */
77
+ export interface ArtifactCallAddress {
78
+ readonly session: ArtifactSessionAddress;
79
+ readonly callId: string;
80
+ }
62
81
  /** Build a canonical `dsh-resource://` address for one Artifact id. */
63
82
  export declare function artifactAddressFor(id: string): string;
64
83
  /** Extract the Artifact id from a `dsh-resource://dsh-renderer/artifact/<id>` address. */
65
84
  export declare function parseArtifactAddress(address: string): string | null;
85
+ /** Build a durable Session-backed `dsh-resource://` address for one `render_artifact` call. */
86
+ export declare function artifactCallAddressFor(target: ArtifactCallAddress): string;
87
+ /** Parse and validate a durable `dsh-resource://dsh-renderer/call/...` address. */
88
+ export declare function parseArtifactCallAddress(address: string): ArtifactCallAddress | null;
89
+ /** Return whether `address` is a well-formed artifact or call resource owned by `@aqian0/dsh-renderer`. */
90
+ export declare function isArtifactResourceAddress(address: string): boolean;
66
91
  /**
67
92
  * Bounded in-memory store for Artifacts opened in the right Sidebar workbench
68
93
  * or fullscreen modal fallback.
@@ -70,6 +95,7 @@ export declare function parseArtifactAddress(address: string): string | null;
70
95
  export declare class ArtifactStore {
71
96
  private readonly maxEntries;
72
97
  private readonly records;
98
+ private readonly addressIndex;
73
99
  private readonly listeners;
74
100
  private modalArtifactId;
75
101
  private seq;
@@ -77,6 +103,7 @@ export declare class ArtifactStore {
77
103
  /** Insert or update an artifact, returning the stored record. */
78
104
  put(input: {
79
105
  readonly id?: string | undefined;
106
+ readonly address?: string | undefined;
80
107
  readonly kind: ArtifactKind;
81
108
  readonly lang?: string | undefined;
82
109
  readonly title: string;
@@ -85,7 +112,7 @@ export declare class ArtifactStore {
85
112
  }): ArtifactRecord;
86
113
  /** Look up one artifact by id. */
87
114
  get(id: string): ArtifactRecord | undefined;
88
- /** Look up one artifact by its `dsh-resource://` address. */
115
+ /** Look up one artifact by its `dsh-resource://` address (`/artifact/...` or `/call/...`). */
89
116
  getByAddress(address: string): ArtifactRecord | undefined;
90
117
  /** Open an artifact inside the fullscreen modal fallback. */
91
118
  openModal(id: string): void;
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Custom renderer",
4
- "description": "First-class render_artifact streaming cards, sandboxed HTML/SVG previews, right-Sidebar workbench for complex content, and inline visual media fallback for DeepSeek Harness."
4
+ "description": "First-class render_artifact streaming cards outside process folding, bundled visual-artifact skill, persistent Sidebar recovery, sandboxed HTML/SVG previews, and inline visual media fallback for DeepSeek Harness."
5
5
  }
6
6
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "自定义渲染器",
4
- "description": "面向 DeepSeek Harness 的原生 render_artifact 流式卡片工具、HTML/SVG 沙箱预览、高复杂度内容侧栏展开与行内媒体补齐插件。"
4
+ "description": "面向 DeepSeek Harness 的原生 render_artifact 常驻流式卡片、visual-artifact 技能、持久化侧栏恢复、HTML/SVG 沙箱预览与行内媒体补齐插件。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aqian0/dsh-renderer",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Custom renderer plugin for DeepSeek Harness",
5
5
  "keywords": [
6
6
  "deepseek-harness",
@@ -82,8 +82,12 @@
82
82
  "client": {
83
83
  "platform": "web",
84
84
  "inject": [
85
+ "@deepseek-ai/dsh-api-remotes",
85
86
  "@deepseek-ai/dsh-client-locale",
87
+ "@deepseek-ai/dsh-client-resources",
86
88
  "@deepseek-ai/dsh-client-ui-chat",
89
+ "@deepseek-ai/dsh-client-ui-conversation",
90
+ "@deepseek-ai/dsh-client-ui-session",
87
91
  "@deepseek-ai/dsh-client-ui-sidebar-right",
88
92
  "@deepseek-ai/dsh-client-ui-theme",
89
93
  "@deepseek-ai/dsh-client-ui-tool"