dsh-typst-plugin 0.0.0-stage → 0.1.0-alpha.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.
Files changed (106) hide show
  1. package/LICENSE +21 -0
  2. package/README.en.md +87 -0
  3. package/README.md +86 -2
  4. package/cordis.patch.yml +6 -0
  5. package/docs/images/icon.png +0 -0
  6. package/docs/plugin-detail.en.md +2 -0
  7. package/docs/plugin-detail.md +2 -0
  8. package/lib/client.js +41044 -0
  9. package/lib/client.js.map +7 -0
  10. package/lib/config.d.ts +50 -0
  11. package/lib/config.d.ts.map +1 -0
  12. package/lib/config.js +31 -0
  13. package/lib/config.js.map +7 -0
  14. package/lib/constants.d.ts +58 -0
  15. package/lib/constants.d.ts.map +1 -0
  16. package/lib/constants.js +62 -0
  17. package/lib/constants.js.map +7 -0
  18. package/lib/contract.d.ts +179 -0
  19. package/lib/contract.d.ts.map +1 -0
  20. package/lib/contract.js +1 -0
  21. package/lib/contract.js.map +7 -0
  22. package/lib/errors.d.ts +77 -0
  23. package/lib/errors.d.ts.map +1 -0
  24. package/lib/errors.js +86 -0
  25. package/lib/errors.js.map +7 -0
  26. package/lib/host/facts.d.ts +31 -0
  27. package/lib/host/facts.d.ts.map +1 -0
  28. package/lib/host/facts.js +151 -0
  29. package/lib/host/facts.js.map +7 -0
  30. package/lib/index.d.ts +2 -0
  31. package/lib/index.d.ts.map +1 -0
  32. package/lib/index.js +5 -0
  33. package/lib/index.js.map +7 -0
  34. package/lib/remote.d.ts +69 -0
  35. package/lib/remote.d.ts.map +1 -0
  36. package/lib/remote.js +146 -0
  37. package/lib/remote.js.map +7 -0
  38. package/lib/service.d.ts +47 -0
  39. package/lib/service.d.ts.map +1 -0
  40. package/lib/service.js +110 -0
  41. package/lib/service.js.map +7 -0
  42. package/lib/skills/typst.d.ts +13 -0
  43. package/lib/skills/typst.d.ts.map +1 -0
  44. package/lib/skills/typst.js +72 -0
  45. package/lib/skills/typst.js.map +7 -0
  46. package/lib/status-codec.d.ts +11 -0
  47. package/lib/status-codec.d.ts.map +1 -0
  48. package/lib/status-codec.js +6 -0
  49. package/lib/status-codec.js.map +7 -0
  50. package/lib/tools/registration.d.ts +22 -0
  51. package/lib/tools/registration.d.ts.map +1 -0
  52. package/lib/tools/registration.js +525 -0
  53. package/lib/tools/registration.js.map +7 -0
  54. package/lib/tools/shared.d.ts +31 -0
  55. package/lib/tools/shared.d.ts.map +1 -0
  56. package/lib/tools/shared.js +70 -0
  57. package/lib/tools/shared.js.map +7 -0
  58. package/lib/typert.d.ts +23 -0
  59. package/lib/typert.d.ts.map +1 -0
  60. package/lib/typert.js +67 -0
  61. package/lib/typert.js.map +7 -0
  62. package/lib/typst/diagnostics.d.ts +58 -0
  63. package/lib/typst/diagnostics.d.ts.map +1 -0
  64. package/lib/typst/diagnostics.js +171 -0
  65. package/lib/typst/diagnostics.js.map +7 -0
  66. package/lib/typst/locate.d.ts +68 -0
  67. package/lib/typst/locate.d.ts.map +1 -0
  68. package/lib/typst/locate.js +194 -0
  69. package/lib/typst/locate.js.map +7 -0
  70. package/lib/typst/mainfile.d.ts +21 -0
  71. package/lib/typst/mainfile.d.ts.map +1 -0
  72. package/lib/typst/mainfile.js +64 -0
  73. package/lib/typst/mainfile.js.map +7 -0
  74. package/lib/typst/match.d.ts +59 -0
  75. package/lib/typst/match.d.ts.map +1 -0
  76. package/lib/typst/match.js +171 -0
  77. package/lib/typst/match.js.map +7 -0
  78. package/lib/typst/oneshot.d.ts +45 -0
  79. package/lib/typst/oneshot.d.ts.map +1 -0
  80. package/lib/typst/oneshot.js +76 -0
  81. package/lib/typst/oneshot.js.map +7 -0
  82. package/lib/typst/pdf-extract.d.ts +29 -0
  83. package/lib/typst/pdf-extract.d.ts.map +1 -0
  84. package/lib/typst/pdf-extract.js +87 -0
  85. package/lib/typst/pdf-extract.js.map +7 -0
  86. package/lib/typst/pdfjs-worker.d.js +1 -0
  87. package/lib/typst/pdfjs-worker.d.js.map +7 -0
  88. package/lib/typst/text.d.ts +65 -0
  89. package/lib/typst/text.d.ts.map +1 -0
  90. package/lib/typst/text.js +314 -0
  91. package/lib/typst/text.js.map +7 -0
  92. package/lib/typst/watcher.d.ts +77 -0
  93. package/lib/typst/watcher.d.ts.map +1 -0
  94. package/lib/typst/watcher.js +219 -0
  95. package/lib/typst/watcher.js.map +7 -0
  96. package/lib/wire-schemas.d.ts +578 -0
  97. package/lib/wire-schemas.d.ts.map +1 -0
  98. package/lib/wire-schemas.js +384 -0
  99. package/lib/wire-schemas.js.map +7 -0
  100. package/lib/workspace/session.d.ts +209 -0
  101. package/lib/workspace/session.d.ts.map +1 -0
  102. package/lib/workspace/session.js +1232 -0
  103. package/lib/workspace/session.js.map +7 -0
  104. package/locale/en.json +9 -0
  105. package/locale/zh.json +9 -0
  106. package/package.json +256 -4
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Plugin configuration. The schema fills defaults and every field is
3
+ * `volatile`, so a settings commit lands in the running fiber without
4
+ * remounting and the workbench reads it per request. Structural reactions
5
+ * (a changed Typst path re-checks every workspace) ride
6
+ * `loader/volatile-update` in the service.
7
+ * @module dsh-typst/config
8
+ */
9
+ import type { Volatile } from "@deepseek-ai/cordis";
10
+ import Schema from "@deepseek-ai/schemastery";
11
+ export interface Config {
12
+ /**
13
+ * Full path of the typst executable. Empty looks typst up on PATH, in the
14
+ * common install locations, and finally in the login shell; set it only
15
+ * when Typst is installed somewhere else.
16
+ */
17
+ typstPath?: Volatile<string>;
18
+ }
19
+ /**
20
+ * Every field is `volatile`: the settings page edits the live entry, and the
21
+ * loader commits volatile edits into the running fiber without remounting.
22
+ */
23
+ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
24
+ typstPath: Schema<string, string, "volatile-defined">;
25
+ }>>, Schemastery.ObjectT<NoInfer<{
26
+ typstPath: Schema<string, string, "volatile-defined">;
27
+ }>>, "plain">;
28
+ /** The live entry the service holds: plain current values, unwrapped per read. */
29
+ export interface LiveEntry {
30
+ typstPath: string;
31
+ }
32
+ /**
33
+ * Read the live config values per request. The entry already passed the
34
+ * schema (the loader applies `Config` before the constructor runs), so this
35
+ * only unwraps volatile references.
36
+ * @param entry - the live entry the service holds.
37
+ * @returns the plain current values.
38
+ */
39
+ export declare function readResolvedConfig(entry: Config | object): {
40
+ typstPath: string;
41
+ };
42
+ /**
43
+ * Accept the loader entry (volatile references) or plain written values and
44
+ * normalize to the live-entry shape the service holds. Validation stays
45
+ * minimal: an empty string means "look typst up".
46
+ * @param entry - what the loader handed the constructor or the settings page wrote.
47
+ * @returns the live entry.
48
+ */
49
+ export declare function toLiveEntry(entry: Config | object): LiveEntry;
50
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,MAAM,MAAM,0BAA0B,CAAC;AAE9C,MAAM,WAAW,MAAM;IACrB;;;;OAIG;IACH,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CAC9B;AAED;;;GAGG;AACH,eAAO,MAAM,MAAM;;;;aAEjB,CAAC;AAEH,kFAAkF;AAClF,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB;AA0BD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG;IAC1D,SAAS,EAAE,MAAM,CAAC;CACnB,CAKA;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAK7D"}
package/lib/config.js ADDED
@@ -0,0 +1,31 @@
1
+ import { isVolatile } from "@deepseek-ai/cosmokit";
2
+ import Schema from "@deepseek-ai/schemastery";
3
+ const Config = Schema.object({
4
+ typstPath: Schema.string().default("").volatile()
5
+ });
6
+ function current(value) {
7
+ return isVolatile(value) ? value.get() : value;
8
+ }
9
+ function unwrapConfig(config) {
10
+ return Object.fromEntries(
11
+ Object.entries(config ?? {}).map(([key, value]) => [key, current(value)])
12
+ );
13
+ }
14
+ function readResolvedConfig(entry) {
15
+ const plain = unwrapConfig(entry);
16
+ return {
17
+ typstPath: typeof plain.typstPath === "string" ? plain.typstPath : ""
18
+ };
19
+ }
20
+ function toLiveEntry(entry) {
21
+ const plain = unwrapConfig(entry);
22
+ return {
23
+ typstPath: typeof plain.typstPath === "string" ? plain.typstPath : ""
24
+ };
25
+ }
26
+ export {
27
+ Config,
28
+ readResolvedConfig,
29
+ toLiveEntry
30
+ };
31
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/config.ts"],
4
+ "sourcesContent": ["/**\n * Plugin configuration. The schema fills defaults and every field is\n * `volatile`, so a settings commit lands in the running fiber without\n * remounting and the workbench reads it per request. Structural reactions\n * (a changed Typst path re-checks every workspace) ride\n * `loader/volatile-update` in the service.\n * @module dsh-typst/config\n */\n\nimport type { Volatile } from \"@deepseek-ai/cordis\";\nimport { isVolatile } from \"@deepseek-ai/cosmokit\";\nimport Schema from \"@deepseek-ai/schemastery\";\n\nexport interface Config {\n /**\n * Full path of the typst executable. Empty looks typst up on PATH, in the\n * common install locations, and finally in the login shell; set it only\n * when Typst is installed somewhere else.\n */\n typstPath?: Volatile<string>;\n}\n\n/**\n * Every field is `volatile`: the settings page edits the live entry, and the\n * loader commits volatile edits into the running fiber without remounting.\n */\nexport const Config = Schema.object({\n typstPath: Schema.string().default(\"\").volatile(),\n});\n\n/** The live entry the service holds: plain current values, unwrapped per read. */\nexport interface LiveEntry {\n typstPath: string;\n}\n\n/**\n * Read the current value behind a volatile reference. Plain values pass\n * through untouched, so callers holding pre-resolution input need no\n * wrapping.\n * @param value - a field value, possibly a volatile reference.\n * @returns the current plain value.\n */\nfunction current(value: unknown): unknown {\n return isVolatile(value) ? value.get() : value;\n}\n\n/**\n * Unwrap every top-level field of an entry to its plain value.\n * @param config - a Loader-resolved `Config` or human-written values.\n * @returns the plain field map, without schema defaults.\n */\nfunction unwrapConfig(\n config: Config | Record<string, unknown>,\n): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(config ?? {}).map(([key, value]) => [key, current(value)]),\n );\n}\n\n/**\n * Read the live config values per request. The entry already passed the\n * schema (the loader applies `Config` before the constructor runs), so this\n * only unwraps volatile references.\n * @param entry - the live entry the service holds.\n * @returns the plain current values.\n */\nexport function readResolvedConfig(entry: Config | object): {\n typstPath: string;\n} {\n const plain = unwrapConfig(entry);\n return {\n typstPath: typeof plain.typstPath === \"string\" ? plain.typstPath : \"\",\n };\n}\n\n/**\n * Accept the loader entry (volatile references) or plain written values and\n * normalize to the live-entry shape the service holds. Validation stays\n * minimal: an empty string means \"look typst up\".\n * @param entry - what the loader handed the constructor or the settings page wrote.\n * @returns the live entry.\n */\nexport function toLiveEntry(entry: Config | object): LiveEntry {\n const plain = unwrapConfig(entry);\n return {\n typstPath: typeof plain.typstPath === \"string\" ? plain.typstPath : \"\",\n };\n}\n"],
5
+ "mappings": "AAUA,SAAS,kBAAkB;AAC3B,OAAO,YAAY;AAeZ,MAAM,SAAS,OAAO,OAAO;AAAA,EAClC,WAAW,OAAO,OAAO,EAAE,QAAQ,EAAE,EAAE,SAAS;AAClD,CAAC;AAcD,SAAS,QAAQ,OAAyB;AACxC,SAAO,WAAW,KAAK,IAAI,MAAM,IAAI,IAAI;AAC3C;AAOA,SAAS,aACP,QACyB;AACzB,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,QAAQ,KAAK,CAAC,CAAC;AAAA,EAC1E;AACF;AASO,SAAS,mBAAmB,OAEjC;AACA,QAAM,QAAQ,aAAa,KAAK;AAChC,SAAO;AAAA,IACL,WAAW,OAAO,MAAM,cAAc,WAAW,MAAM,YAAY;AAAA,EACrE;AACF;AASO,SAAS,YAAY,OAAmC;AAC7D,QAAM,QAAQ,aAAa,KAAK;AAChC,SAAO;AAAA,IACL,WAAW,OAAO,MAAM,cAAc,WAAW,MAAM,YAAY;AAAA,EACrE;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Runtime constants shared by both halves. Values and type-only imports
3
+ * only: this module is on the client-graph allowlist
4
+ * (`scripts/client-graph-authority.mjs`), so a host-side import here would
5
+ * put host authority in the browser bundle.
6
+ * @module dsh-typst/constants
7
+ */
8
+ /** The wire namespace this plugin mounts its Typert remote under. */
9
+ export declare const TYPST_REMOTE_PACKAGE = "typst";
10
+ /** The settings/config namespace spelling shared by both halves. */
11
+ export declare const TYPST_SETTINGS_NAMESPACE = "typst";
12
+ /** Cordis service key of the host remote runtime (`TypstRuntime`). */
13
+ export declare const TYPST_STATUS_SERVICE_KEY = "typstStatus";
14
+ export declare const TYPST_STATUS_METHOD = "status";
15
+ export declare const TYPST_SET_MAIN_METHOD = "setMain";
16
+ export declare const TYPST_WATCH_METHOD = "watch";
17
+ export declare const TYPST_READ_PREVIEW_METHOD = "readPreview";
18
+ export declare const TYPST_LOCATE_SOURCE_METHOD = "locateSource";
19
+ /** Typst versions older than this are refused (ZCode typst-workbench parity). */
20
+ export declare const MIN_TYPST: readonly [number, number, number];
21
+ /** Tool names, flat domain-prefixed snake_case (dsh-zotero convention). */
22
+ export declare const TYPST_TOOL_NAMES: readonly ["typst_status", "typst_set_main", "typst_check", "typst_render_pages", "typst_show", "typst_clear_highlights", "typst_export_pdf"];
23
+ export type TypstToolName = (typeof TYPST_TOOL_NAMES)[number];
24
+ /**
25
+ * Ported from the ZCode typst-workbench server (0.2.0): the behavioral
26
+ * bounds every tool and the panel observe.
27
+ */
28
+ export declare const LIMITS: {
29
+ /** Silence window that decides a watch round has produced its diagnostics. */
30
+ readonly settleMs: 1500;
31
+ /** One-shot compile (render, export) timeout. */
32
+ readonly oneshotTimeoutMs: 120000;
33
+ /** Diagnostics returned to the model. */
34
+ readonly diagnostics: 30;
35
+ /** Status notification throttle. */
36
+ readonly notifyMs: 30;
37
+ /** Re-lookup interval while the panel is open and Typst is unusable; every setupShellEvery ticks the login shell is queried too. */
38
+ readonly setupWatchMs: 3000;
39
+ readonly setupShellEvery: 5;
40
+ /** How long `typst_check` waits for the document to settle. */
41
+ readonly checkTimeoutMs: 60000;
42
+ /** Maximum pages rendered per `typst_render_pages` call. */
43
+ readonly renderPages: 4;
44
+ readonly ppiDefault: 110;
45
+ readonly ppiMin: 36;
46
+ readonly ppiMax: 300;
47
+ /** Preview PDFs above this size are not served. */
48
+ readonly pdfBytes: number;
49
+ /** Retained compile snapshots (old ones drop for highlight relocation). */
50
+ readonly snapshots: 3;
51
+ };
52
+ /** Source files larger than this never enter source matching. */
53
+ export declare const SOURCE_FILE_MAX_BYTES: number;
54
+ /** Source files considered for one `locateSource` call. */
55
+ export declare const SOURCE_FILES_MAX = 500;
56
+ /** Dependency files consulted when computing the latest input modification. */
57
+ export declare const INPUT_FILES_MAX = 2000;
58
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,qEAAqE;AACrE,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAC5C,oEAAoE;AACpE,eAAO,MAAM,wBAAwB,UAAU,CAAC;AAChD,sEAAsE;AACtE,eAAO,MAAM,wBAAwB,gBAAgB,CAAC;AAEtD,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAC5C,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAC/C,eAAO,MAAM,kBAAkB,UAAU,CAAC;AAC1C,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AACvD,eAAO,MAAM,0BAA0B,iBAAiB,CAAC;AAEzD,iFAAiF;AACjF,eAAO,MAAM,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAc,CAAC;AAEvE,2EAA2E;AAC3E,eAAO,MAAM,gBAAgB,8IAQnB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,MAAM;IACjB,8EAA8E;;IAE9E,iDAAiD;;IAEjD,yCAAyC;;IAEzC,oCAAoC;;IAEpC,oIAAoI;;;IAGpI,+DAA+D;;IAE/D,4DAA4D;;;;;IAK5D,mDAAmD;;IAEnD,2EAA2E;;CAEnE,CAAC;AAEX,iEAAiE;AACjE,eAAO,MAAM,qBAAqB,QAAkB,CAAC;AACrD,2DAA2D;AAC3D,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,+EAA+E;AAC/E,eAAO,MAAM,eAAe,OAAQ,CAAC"}
@@ -0,0 +1,62 @@
1
+ const TYPST_REMOTE_PACKAGE = "typst";
2
+ const TYPST_SETTINGS_NAMESPACE = "typst";
3
+ const TYPST_STATUS_SERVICE_KEY = "typstStatus";
4
+ const TYPST_STATUS_METHOD = "status";
5
+ const TYPST_SET_MAIN_METHOD = "setMain";
6
+ const TYPST_WATCH_METHOD = "watch";
7
+ const TYPST_READ_PREVIEW_METHOD = "readPreview";
8
+ const TYPST_LOCATE_SOURCE_METHOD = "locateSource";
9
+ const MIN_TYPST = [0, 12, 0];
10
+ const TYPST_TOOL_NAMES = [
11
+ "typst_status",
12
+ "typst_set_main",
13
+ "typst_check",
14
+ "typst_render_pages",
15
+ "typst_show",
16
+ "typst_clear_highlights",
17
+ "typst_export_pdf"
18
+ ];
19
+ const LIMITS = {
20
+ /** Silence window that decides a watch round has produced its diagnostics. */
21
+ settleMs: 1500,
22
+ /** One-shot compile (render, export) timeout. */
23
+ oneshotTimeoutMs: 12e4,
24
+ /** Diagnostics returned to the model. */
25
+ diagnostics: 30,
26
+ /** Status notification throttle. */
27
+ notifyMs: 30,
28
+ /** Re-lookup interval while the panel is open and Typst is unusable; every setupShellEvery ticks the login shell is queried too. */
29
+ setupWatchMs: 3e3,
30
+ setupShellEvery: 5,
31
+ /** How long `typst_check` waits for the document to settle. */
32
+ checkTimeoutMs: 6e4,
33
+ /** Maximum pages rendered per `typst_render_pages` call. */
34
+ renderPages: 4,
35
+ ppiDefault: 110,
36
+ ppiMin: 36,
37
+ ppiMax: 300,
38
+ /** Preview PDFs above this size are not served. */
39
+ pdfBytes: 256 * 1024 * 1024,
40
+ /** Retained compile snapshots (old ones drop for highlight relocation). */
41
+ snapshots: 3
42
+ };
43
+ const SOURCE_FILE_MAX_BYTES = 4 * 1024 * 1024;
44
+ const SOURCE_FILES_MAX = 500;
45
+ const INPUT_FILES_MAX = 2e3;
46
+ export {
47
+ INPUT_FILES_MAX,
48
+ LIMITS,
49
+ MIN_TYPST,
50
+ SOURCE_FILES_MAX,
51
+ SOURCE_FILE_MAX_BYTES,
52
+ TYPST_LOCATE_SOURCE_METHOD,
53
+ TYPST_READ_PREVIEW_METHOD,
54
+ TYPST_REMOTE_PACKAGE,
55
+ TYPST_SETTINGS_NAMESPACE,
56
+ TYPST_SET_MAIN_METHOD,
57
+ TYPST_STATUS_METHOD,
58
+ TYPST_STATUS_SERVICE_KEY,
59
+ TYPST_TOOL_NAMES,
60
+ TYPST_WATCH_METHOD
61
+ };
62
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/constants.ts"],
4
+ "sourcesContent": ["/**\n * Runtime constants shared by both halves. Values and type-only imports\n * only: this module is on the client-graph allowlist\n * (`scripts/client-graph-authority.mjs`), so a host-side import here would\n * put host authority in the browser bundle.\n * @module dsh-typst/constants\n */\n\n/** The wire namespace this plugin mounts its Typert remote under. */\nexport const TYPST_REMOTE_PACKAGE = \"typst\";\n/** The settings/config namespace spelling shared by both halves. */\nexport const TYPST_SETTINGS_NAMESPACE = \"typst\";\n/** Cordis service key of the host remote runtime (`TypstRuntime`). */\nexport const TYPST_STATUS_SERVICE_KEY = \"typstStatus\";\n\nexport const TYPST_STATUS_METHOD = \"status\";\nexport const TYPST_SET_MAIN_METHOD = \"setMain\";\nexport const TYPST_WATCH_METHOD = \"watch\";\nexport const TYPST_READ_PREVIEW_METHOD = \"readPreview\";\nexport const TYPST_LOCATE_SOURCE_METHOD = \"locateSource\";\n\n/** Typst versions older than this are refused (ZCode typst-workbench parity). */\nexport const MIN_TYPST: readonly [number, number, number] = [0, 12, 0];\n\n/** Tool names, flat domain-prefixed snake_case (dsh-zotero convention). */\nexport const TYPST_TOOL_NAMES = [\n \"typst_status\",\n \"typst_set_main\",\n \"typst_check\",\n \"typst_render_pages\",\n \"typst_show\",\n \"typst_clear_highlights\",\n \"typst_export_pdf\",\n] as const;\n\nexport type TypstToolName = (typeof TYPST_TOOL_NAMES)[number];\n\n/**\n * Ported from the ZCode typst-workbench server (0.2.0): the behavioral\n * bounds every tool and the panel observe.\n */\nexport const LIMITS = {\n /** Silence window that decides a watch round has produced its diagnostics. */\n settleMs: 1_500,\n /** One-shot compile (render, export) timeout. */\n oneshotTimeoutMs: 120_000,\n /** Diagnostics returned to the model. */\n diagnostics: 30,\n /** Status notification throttle. */\n notifyMs: 30,\n /** Re-lookup interval while the panel is open and Typst is unusable; every setupShellEvery ticks the login shell is queried too. */\n setupWatchMs: 3_000,\n setupShellEvery: 5,\n /** How long `typst_check` waits for the document to settle. */\n checkTimeoutMs: 60_000,\n /** Maximum pages rendered per `typst_render_pages` call. */\n renderPages: 4,\n ppiDefault: 110,\n ppiMin: 36,\n ppiMax: 300,\n /** Preview PDFs above this size are not served. */\n pdfBytes: 256 * 1024 * 1024,\n /** Retained compile snapshots (old ones drop for highlight relocation). */\n snapshots: 3,\n} as const;\n\n/** Source files larger than this never enter source matching. */\nexport const SOURCE_FILE_MAX_BYTES = 4 * 1024 * 1024;\n/** Source files considered for one `locateSource` call. */\nexport const SOURCE_FILES_MAX = 500;\n/** Dependency files consulted when computing the latest input modification. */\nexport const INPUT_FILES_MAX = 2_000;\n"],
5
+ "mappings": "AASO,MAAM,uBAAuB;AAE7B,MAAM,2BAA2B;AAEjC,MAAM,2BAA2B;AAEjC,MAAM,sBAAsB;AAC5B,MAAM,wBAAwB;AAC9B,MAAM,qBAAqB;AAC3B,MAAM,4BAA4B;AAClC,MAAM,6BAA6B;AAGnC,MAAM,YAA+C,CAAC,GAAG,IAAI,CAAC;AAG9D,MAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAQO,MAAM,SAAS;AAAA;AAAA,EAEpB,UAAU;AAAA;AAAA,EAEV,kBAAkB;AAAA;AAAA,EAElB,aAAa;AAAA;AAAA,EAEb,UAAU;AAAA;AAAA,EAEV,cAAc;AAAA,EACd,iBAAiB;AAAA;AAAA,EAEjB,gBAAgB;AAAA;AAAA,EAEhB,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,QAAQ;AAAA;AAAA,EAER,UAAU,MAAM,OAAO;AAAA;AAAA,EAEvB,WAAW;AACb;AAGO,MAAM,wBAAwB,IAAI,OAAO;AAEzC,MAAM,mBAAmB;AAEzB,MAAM,kBAAkB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Wire identity shared by both halves: the view types the host serves and
3
+ * the browser half renders, plus the strict zod codecs both arms materialize
4
+ * (`wire-schemas.ts`). Values and type-only imports only — this module is on
5
+ * the client-graph allowlist (`scripts/client-graph-authority.mjs`).
6
+ * @module dsh-typst/contract
7
+ */
8
+ /**
9
+ * The plugin's one Remote failure code: every domain error crosses the wire
10
+ * as `typst/domain` with the stable domain code in `details`, so consumers
11
+ * discriminate by `details.code` while the wire keeps a single declared
12
+ * shape (the dsh-zotero pattern).
13
+ */
14
+ declare module "@deepseek-ai/dsh-typert-protocol" {
15
+ interface RemoteErrorDetailsMap {
16
+ "typst/domain": {
17
+ readonly code: string;
18
+ };
19
+ }
20
+ }
21
+ /** Where the located binary came from. */
22
+ export type TypstSource = "setting" | "path" | "common" | "shell";
23
+ export interface ToolchainReadyView {
24
+ state: "ready";
25
+ version: string;
26
+ path: string;
27
+ source: TypstSource;
28
+ }
29
+ export interface ToolchainMissingView {
30
+ state: "missing";
31
+ }
32
+ export interface ToolchainTooOldView {
33
+ state: "too_old";
34
+ version: string;
35
+ path: string;
36
+ source: TypstSource;
37
+ error: string;
38
+ }
39
+ export interface ToolchainErrorView {
40
+ state: "error";
41
+ path?: string;
42
+ source?: TypstSource;
43
+ error: string;
44
+ }
45
+ export type ToolchainView = ToolchainReadyView | ToolchainMissingView | ToolchainTooOldView | ToolchainErrorView;
46
+ export interface DiagnosticLocationView {
47
+ file: string;
48
+ line: number;
49
+ column: number;
50
+ }
51
+ export interface DiagnosticPointView {
52
+ message: string;
53
+ location: DiagnosticLocationView | null;
54
+ }
55
+ export interface DiagnosticView {
56
+ severity: "error" | "warning";
57
+ message: string;
58
+ location: DiagnosticLocationView | null;
59
+ excerpt?: string;
60
+ hints: string[];
61
+ trace: DiagnosticPointView[];
62
+ }
63
+ export type CompilePhase = "idle" | "starting" | "compiling" | "ok" | "warnings" | "error" | "crashed";
64
+ export interface StatusView {
65
+ phase: CompilePhase;
66
+ run: number;
67
+ durationMs?: number;
68
+ error?: string;
69
+ finishedAt?: number;
70
+ }
71
+ /** Metadata of the current preview PDF; bytes ride `readPreview`. */
72
+ export interface PreviewIdentity {
73
+ generation: number;
74
+ seq: number;
75
+ sha256: string;
76
+ }
77
+ export interface SnapshotView extends PreviewIdentity {
78
+ main: string;
79
+ run: number;
80
+ bytes: number;
81
+ pages: number;
82
+ createdAt: number;
83
+ }
84
+ export interface SourceRefView {
85
+ file: string;
86
+ line: number;
87
+ endLine: number;
88
+ }
89
+ /**
90
+ * One agent highlight. Rects are PDF user-space `[x1, y1, x2, y2]` boxes on
91
+ * the page; the panel maps them through the page viewport. `seq` names the
92
+ * snapshot the rects belong to; after a recompile the host re-locates the
93
+ * quote and pushes new rects (unmatched highlights turn `stale`).
94
+ */
95
+ export interface HighlightView {
96
+ id: string;
97
+ quote: string;
98
+ comment: string;
99
+ source?: SourceRefView;
100
+ identity: PreviewIdentity;
101
+ seq: number;
102
+ pageIndex: number;
103
+ rects: number[][];
104
+ stale: boolean;
105
+ createdAt: number;
106
+ }
107
+ /** A location request from `typst_show`; the panel notifies before navigating. */
108
+ export type PanelView = {
109
+ kind: "page";
110
+ pageIndex: number;
111
+ identity: PreviewIdentity;
112
+ } | {
113
+ kind: "highlight";
114
+ id: string;
115
+ identity: PreviewIdentity;
116
+ } | null;
117
+ export interface PackageManagerView {
118
+ name: string;
119
+ version?: string;
120
+ path: string;
121
+ }
122
+ export interface HostFactsView {
123
+ os: "macos" | "windows" | "linux" | "other";
124
+ osName: string;
125
+ arch: string;
126
+ tools: PackageManagerView[];
127
+ }
128
+ export interface SetupView {
129
+ facts: HostFactsView | null;
130
+ searched: string[];
131
+ }
132
+ /**
133
+ * Everything the panel renders, in one frame: the stream's first frame is
134
+ * the current state, later frames follow every relevant change (compile
135
+ * finished, snapshot replaced, highlight moved, toolchain changed).
136
+ */
137
+ export interface TypstStateFrame {
138
+ version: number;
139
+ generation: number;
140
+ previewError: string | null;
141
+ discovery: {
142
+ scanning: boolean;
143
+ includeExcluded: boolean;
144
+ visited: number;
145
+ errors: string[];
146
+ };
147
+ toolchain: ToolchainView;
148
+ workspace: string;
149
+ main: string | null;
150
+ candidates: string[];
151
+ /**
152
+ * The candidates this document includes, as typst's own dependency report
153
+ * names them. A fragment is a `.typ` file another file pulls in with
154
+ * `#include` or `#import`; compiling one on its own is rarely what the user
155
+ * means, so the panel lists them apart from other, unclassified files.
156
+ */
157
+ fragments: string[];
158
+ status: StatusView;
159
+ diagnostics: DiagnosticView[];
160
+ snapshot: SnapshotView | null;
161
+ highlights: HighlightView[];
162
+ view: PanelView;
163
+ viewSeq: number;
164
+ setup: SetupView;
165
+ }
166
+ /** Bytes for exactly one retained preview identity. */
167
+ export interface PreviewBytes extends PreviewIdentity {
168
+ data: Uint8Array<ArrayBuffer>;
169
+ }
170
+ /** One rendered-text → source candidate (`typst/locateSource` and the panel's selection toolbar). */
171
+ export interface SourceMatch {
172
+ file: string;
173
+ line: number;
174
+ column: number;
175
+ endLine: number;
176
+ excerpt: string;
177
+ score: number;
178
+ }
179
+ //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Stable error classes and codes for the Typst domain. Mirrors the
3
+ * dsh-zotero convention: `HarnessError` subclasses carry a machine-routable
4
+ * code on the host half; the remote layer re-arms them as `RemoteError`s
5
+ * keyed `<domain>/<reason>`, discriminated by code, never by instanceof.
6
+ * @module dsh-typst/errors
7
+ */
8
+ import { HarnessError } from "@deepseek-ai/dsh-llm";
9
+ /** Typst is not installed anywhere this computer's lookup covers. */
10
+ export declare const TYPST_MISSING = "TYPST_MISSING";
11
+ /** The installed Typst is older than the supported minimum. */
12
+ export declare const TYPST_TOO_OLD = "TYPST_TOO_OLD";
13
+ /** Typst exists but does not run (`--version` failed, broken install). */
14
+ export declare const TYPST_UNUSABLE = "TYPST_UNUSABLE";
15
+ /** No main `.typ` file is chosen and none could be picked automatically. */
16
+ export declare const TYPST_NO_MAIN = "TYPST_NO_MAIN";
17
+ /** The requested preview does not exist (nothing compiled successfully yet). */
18
+ export declare const TYPST_NO_PREVIEW = "TYPST_NO_PREVIEW";
19
+ /** A requested snapshot/page/highlight no longer exists. */
20
+ export declare const TYPST_NOT_FOUND = "TYPST_NOT_FOUND";
21
+ /** An argument the schemas cannot express violates a domain constraint. */
22
+ export declare const TYPST_INVALID_ARGUMENT = "TYPST_INVALID_ARGUMENT";
23
+ /** A path resolves outside the session workspace. */
24
+ export declare const TYPST_PATH_OUTSIDE_WORKSPACE = "TYPST_PATH_OUTSIDE_WORKSPACE";
25
+ /** The compile did not settle within the caller's budget. */
26
+ export declare const TYPST_TIMEOUT = "TYPST_TIMEOUT";
27
+ /** `typst watch` died or could not start. */
28
+ export declare const TYPST_WATCH_FAILED = "TYPST_WATCH_FAILED";
29
+ /** The requested quote/text was not found in the rendered preview. */
30
+ export declare const TYPST_QUOTE_NOT_FOUND = "TYPST_QUOTE_NOT_FOUND";
31
+ /** The Typst workbench service is not composed. */
32
+ export declare const TYPST_NOT_COMPOSED = "TYPST_NOT_COMPOSED";
33
+ /** Something unexpected; the message carries the domain fact. */
34
+ export declare const TYPST_UNEXPECTED = "TYPST_UNEXPECTED";
35
+ /** The one message every "typst workbench is not composed" answer spells. */
36
+ export declare const TYPST_NOT_COMPOSED_MESSAGE = "The Typst workbench service is not composed.";
37
+ export declare const TYPST_ERROR_CODES: readonly ["TYPST_MISSING", "TYPST_TOO_OLD", "TYPST_UNUSABLE", "TYPST_NO_MAIN", "TYPST_NO_PREVIEW", "TYPST_NOT_FOUND", "TYPST_INVALID_ARGUMENT", "TYPST_PATH_OUTSIDE_WORKSPACE", "TYPST_TIMEOUT", "TYPST_WATCH_FAILED", "TYPST_QUOTE_NOT_FOUND", "TYPST_NOT_COMPOSED", "TYPST_UNEXPECTED"];
38
+ /** Every stable error code a `TypstError` may carry. */
39
+ export type TypstErrorCode = (typeof TYPST_ERROR_CODES)[number];
40
+ /**
41
+ * Domain failure with a stable machine-routable code and an actionable,
42
+ * model-facing message. The tool registry renders it as `Error: <message>`
43
+ * with `isError: true`.
44
+ */
45
+ export declare class TypstError extends HarnessError {
46
+ readonly code: TypstErrorCode;
47
+ constructor(message: string, code: TypstErrorCode, options?: ErrorOptions);
48
+ }
49
+ /** The remote layer's one failure code (details carry the domain code). */
50
+ export declare const TYPST_REMOTE_DOMAIN: "typst/domain";
51
+ /**
52
+ * Rethrow a domain failure across the Typert wire as the plugin's one
53
+ * `typst/domain` code with the stable domain code in `details`. Consumers
54
+ * discriminate by `details.code`, never by instanceof (the client never
55
+ * sees these classes).
56
+ * @param error - the thrown value.
57
+ * @returns never; throws a `RemoteError` keyed `typst/domain`.
58
+ */
59
+ export declare function rethrowRemote(error: unknown): never;
60
+ /**
61
+ * Throw an argument error: the message is model-facing and names the
62
+ * offending value.
63
+ * @param message - the model-facing argument error text.
64
+ * @throws {TypstError} `TYPST_INVALID_ARGUMENT`.
65
+ */
66
+ export declare function invalid(message: string): never;
67
+ /** Install guidance shown whenever Typst cannot be found. */
68
+ export declare const INSTALL_HINT: string;
69
+ /**
70
+ * Wrap a domain call so every failure crosses the wire as a `RemoteError`
71
+ * with a stable `typst/<reason>` code (client remote calls never reject with
72
+ * anything else; they resolve `{ ok: false }`).
73
+ * @param call - the domain call.
74
+ * @returns the call's value.
75
+ */
76
+ export declare function domainCall<T>(call: () => Promise<T>): Promise<T>;
77
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,qEAAqE;AACrE,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAC7C,+DAA+D;AAC/D,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAC7C,0EAA0E;AAC1E,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAC/C,4EAA4E;AAC5E,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAC7C,gFAAgF;AAChF,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,4DAA4D;AAC5D,eAAO,MAAM,eAAe,oBAAoB,CAAC;AACjD,2EAA2E;AAC3E,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAC/D,qDAAqD;AACrD,eAAO,MAAM,4BAA4B,iCAAiC,CAAC;AAC3E,6DAA6D;AAC7D,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAC7C,6CAA6C;AAC7C,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AACvD,sEAAsE;AACtE,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAC7D,mDAAmD;AACnD,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AACvD,iEAAiE;AACjE,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD,6EAA6E;AAC7E,eAAO,MAAM,0BAA0B,iDACS,CAAC;AAEjD,eAAO,MAAM,iBAAiB,2RAcpB,CAAC;AAEX,wDAAwD;AACxD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,YAAY;IAC1C,SAAiB,IAAI,EAAE,cAAc,CAAC;gBAE1B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,YAAY;CAI1E;AAED,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,EAAG,cAAuB,CAAC;AAE3D;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAYnD;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAE9C;AAED,6DAA6D;AAC7D,eAAO,MAAM,YAAY,QAGwE,CAAC;AAElG;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAMtE"}
package/lib/errors.js ADDED
@@ -0,0 +1,86 @@
1
+ import { HarnessError } from "@deepseek-ai/dsh-llm";
2
+ import { RemoteError } from "@deepseek-ai/dsh-typert-protocol";
3
+ const TYPST_MISSING = "TYPST_MISSING";
4
+ const TYPST_TOO_OLD = "TYPST_TOO_OLD";
5
+ const TYPST_UNUSABLE = "TYPST_UNUSABLE";
6
+ const TYPST_NO_MAIN = "TYPST_NO_MAIN";
7
+ const TYPST_NO_PREVIEW = "TYPST_NO_PREVIEW";
8
+ const TYPST_NOT_FOUND = "TYPST_NOT_FOUND";
9
+ const TYPST_INVALID_ARGUMENT = "TYPST_INVALID_ARGUMENT";
10
+ const TYPST_PATH_OUTSIDE_WORKSPACE = "TYPST_PATH_OUTSIDE_WORKSPACE";
11
+ const TYPST_TIMEOUT = "TYPST_TIMEOUT";
12
+ const TYPST_WATCH_FAILED = "TYPST_WATCH_FAILED";
13
+ const TYPST_QUOTE_NOT_FOUND = "TYPST_QUOTE_NOT_FOUND";
14
+ const TYPST_NOT_COMPOSED = "TYPST_NOT_COMPOSED";
15
+ const TYPST_UNEXPECTED = "TYPST_UNEXPECTED";
16
+ const TYPST_NOT_COMPOSED_MESSAGE = "The Typst workbench service is not composed.";
17
+ const TYPST_ERROR_CODES = [
18
+ TYPST_MISSING,
19
+ TYPST_TOO_OLD,
20
+ TYPST_UNUSABLE,
21
+ TYPST_NO_MAIN,
22
+ TYPST_NO_PREVIEW,
23
+ TYPST_NOT_FOUND,
24
+ TYPST_INVALID_ARGUMENT,
25
+ TYPST_PATH_OUTSIDE_WORKSPACE,
26
+ TYPST_TIMEOUT,
27
+ TYPST_WATCH_FAILED,
28
+ TYPST_QUOTE_NOT_FOUND,
29
+ TYPST_NOT_COMPOSED,
30
+ TYPST_UNEXPECTED
31
+ ];
32
+ class TypstError extends HarnessError {
33
+ constructor(message, code, options) {
34
+ super(message, code, options);
35
+ this.name = "TypstError";
36
+ }
37
+ }
38
+ const TYPST_REMOTE_DOMAIN = "typst/domain";
39
+ function rethrowRemote(error) {
40
+ if (error instanceof TypstError) {
41
+ throw new RemoteError("typst/domain", error.message, { code: error.code });
42
+ }
43
+ if (error instanceof RemoteError) throw error;
44
+ throw new RemoteError(
45
+ "typst/domain",
46
+ error instanceof Error ? error.message : String(error),
47
+ {
48
+ code: TYPST_UNEXPECTED
49
+ }
50
+ );
51
+ }
52
+ function invalid(message) {
53
+ throw new TypstError(message, TYPST_INVALID_ARGUMENT);
54
+ }
55
+ const INSTALL_HINT = 'Install Typst (for example `brew install typst`, `winget install --id Typst.Typst`, `cargo install --locked typst-cli`, or a release from https://github.com/typst/typst/releases), or set its path in the plugin setting "Typst path".';
56
+ async function domainCall(call) {
57
+ try {
58
+ return await call();
59
+ } catch (error) {
60
+ rethrowRemote(error);
61
+ }
62
+ }
63
+ export {
64
+ INSTALL_HINT,
65
+ TYPST_ERROR_CODES,
66
+ TYPST_INVALID_ARGUMENT,
67
+ TYPST_MISSING,
68
+ TYPST_NOT_COMPOSED,
69
+ TYPST_NOT_COMPOSED_MESSAGE,
70
+ TYPST_NOT_FOUND,
71
+ TYPST_NO_MAIN,
72
+ TYPST_NO_PREVIEW,
73
+ TYPST_PATH_OUTSIDE_WORKSPACE,
74
+ TYPST_QUOTE_NOT_FOUND,
75
+ TYPST_REMOTE_DOMAIN,
76
+ TYPST_TIMEOUT,
77
+ TYPST_TOO_OLD,
78
+ TYPST_UNEXPECTED,
79
+ TYPST_UNUSABLE,
80
+ TYPST_WATCH_FAILED,
81
+ TypstError,
82
+ domainCall,
83
+ invalid,
84
+ rethrowRemote
85
+ };
86
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/errors.ts"],
4
+ "sourcesContent": ["/**\n * Stable error classes and codes for the Typst domain. Mirrors the\n * dsh-zotero convention: `HarnessError` subclasses carry a machine-routable\n * code on the host half; the remote layer re-arms them as `RemoteError`s\n * keyed `<domain>/<reason>`, discriminated by code, never by instanceof.\n * @module dsh-typst/errors\n */\n\nimport { HarnessError } from \"@deepseek-ai/dsh-llm\";\nimport { RemoteError } from \"@deepseek-ai/dsh-typert-protocol\";\n\n/** Typst is not installed anywhere this computer's lookup covers. */\nexport const TYPST_MISSING = \"TYPST_MISSING\";\n/** The installed Typst is older than the supported minimum. */\nexport const TYPST_TOO_OLD = \"TYPST_TOO_OLD\";\n/** Typst exists but does not run (`--version` failed, broken install). */\nexport const TYPST_UNUSABLE = \"TYPST_UNUSABLE\";\n/** No main `.typ` file is chosen and none could be picked automatically. */\nexport const TYPST_NO_MAIN = \"TYPST_NO_MAIN\";\n/** The requested preview does not exist (nothing compiled successfully yet). */\nexport const TYPST_NO_PREVIEW = \"TYPST_NO_PREVIEW\";\n/** A requested snapshot/page/highlight no longer exists. */\nexport const TYPST_NOT_FOUND = \"TYPST_NOT_FOUND\";\n/** An argument the schemas cannot express violates a domain constraint. */\nexport const TYPST_INVALID_ARGUMENT = \"TYPST_INVALID_ARGUMENT\";\n/** A path resolves outside the session workspace. */\nexport const TYPST_PATH_OUTSIDE_WORKSPACE = \"TYPST_PATH_OUTSIDE_WORKSPACE\";\n/** The compile did not settle within the caller's budget. */\nexport const TYPST_TIMEOUT = \"TYPST_TIMEOUT\";\n/** `typst watch` died or could not start. */\nexport const TYPST_WATCH_FAILED = \"TYPST_WATCH_FAILED\";\n/** The requested quote/text was not found in the rendered preview. */\nexport const TYPST_QUOTE_NOT_FOUND = \"TYPST_QUOTE_NOT_FOUND\";\n/** The Typst workbench service is not composed. */\nexport const TYPST_NOT_COMPOSED = \"TYPST_NOT_COMPOSED\";\n/** Something unexpected; the message carries the domain fact. */\nexport const TYPST_UNEXPECTED = \"TYPST_UNEXPECTED\";\n\n/** The one message every \"typst workbench is not composed\" answer spells. */\nexport const TYPST_NOT_COMPOSED_MESSAGE =\n \"The Typst workbench service is not composed.\";\n\nexport const TYPST_ERROR_CODES = [\n TYPST_MISSING,\n TYPST_TOO_OLD,\n TYPST_UNUSABLE,\n TYPST_NO_MAIN,\n TYPST_NO_PREVIEW,\n TYPST_NOT_FOUND,\n TYPST_INVALID_ARGUMENT,\n TYPST_PATH_OUTSIDE_WORKSPACE,\n TYPST_TIMEOUT,\n TYPST_WATCH_FAILED,\n TYPST_QUOTE_NOT_FOUND,\n TYPST_NOT_COMPOSED,\n TYPST_UNEXPECTED,\n] as const;\n\n/** Every stable error code a `TypstError` may carry. */\nexport type TypstErrorCode = (typeof TYPST_ERROR_CODES)[number];\n\n/**\n * Domain failure with a stable machine-routable code and an actionable,\n * model-facing message. The tool registry renders it as `Error: <message>`\n * with `isError: true`.\n */\nexport class TypstError extends HarnessError {\n declare readonly code: TypstErrorCode;\n\n constructor(message: string, code: TypstErrorCode, options?: ErrorOptions) {\n super(message, code, options);\n this.name = \"TypstError\";\n }\n}\n\n/** The remote layer's one failure code (details carry the domain code). */\nexport const TYPST_REMOTE_DOMAIN = \"typst/domain\" as const;\n\n/**\n * Rethrow a domain failure across the Typert wire as the plugin's one\n * `typst/domain` code with the stable domain code in `details`. Consumers\n * discriminate by `details.code`, never by instanceof (the client never\n * sees these classes).\n * @param error - the thrown value.\n * @returns never; throws a `RemoteError` keyed `typst/domain`.\n */\nexport function rethrowRemote(error: unknown): never {\n if (error instanceof TypstError) {\n throw new RemoteError(\"typst/domain\", error.message, { code: error.code });\n }\n if (error instanceof RemoteError) throw error;\n throw new RemoteError(\n \"typst/domain\",\n error instanceof Error ? error.message : String(error),\n {\n code: TYPST_UNEXPECTED,\n },\n );\n}\n\n/**\n * Throw an argument error: the message is model-facing and names the\n * offending value.\n * @param message - the model-facing argument error text.\n * @throws {TypstError} `TYPST_INVALID_ARGUMENT`.\n */\nexport function invalid(message: string): never {\n throw new TypstError(message, TYPST_INVALID_ARGUMENT);\n}\n\n/** Install guidance shown whenever Typst cannot be found. */\nexport const INSTALL_HINT =\n \"Install Typst (for example `brew install typst`, `winget install --id Typst.Typst`, \" +\n \"`cargo install --locked typst-cli`, or a release from \" +\n 'https://github.com/typst/typst/releases), or set its path in the plugin setting \"Typst path\".';\n\n/**\n * Wrap a domain call so every failure crosses the wire as a `RemoteError`\n * with a stable `typst/<reason>` code (client remote calls never reject with\n * anything else; they resolve `{ ok: false }`).\n * @param call - the domain call.\n * @returns the call's value.\n */\nexport async function domainCall<T>(call: () => Promise<T>): Promise<T> {\n try {\n return await call();\n } catch (error) {\n rethrowRemote(error);\n }\n}\n"],
5
+ "mappings": "AAQA,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAGrB,MAAM,gBAAgB;AAEtB,MAAM,gBAAgB;AAEtB,MAAM,iBAAiB;AAEvB,MAAM,gBAAgB;AAEtB,MAAM,mBAAmB;AAEzB,MAAM,kBAAkB;AAExB,MAAM,yBAAyB;AAE/B,MAAM,+BAA+B;AAErC,MAAM,gBAAgB;AAEtB,MAAM,qBAAqB;AAE3B,MAAM,wBAAwB;AAE9B,MAAM,qBAAqB;AAE3B,MAAM,mBAAmB;AAGzB,MAAM,6BACX;AAEK,MAAM,oBAAoB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAUO,MAAM,mBAAmB,aAAa;AAAA,EAG3C,YAAY,SAAiB,MAAsB,SAAwB;AACzE,UAAM,SAAS,MAAM,OAAO;AAC5B,SAAK,OAAO;AAAA,EACd;AACF;AAGO,MAAM,sBAAsB;AAU5B,SAAS,cAAc,OAAuB;AACnD,MAAI,iBAAiB,YAAY;AAC/B,UAAM,IAAI,YAAY,gBAAgB,MAAM,SAAS,EAAE,MAAM,MAAM,KAAK,CAAC;AAAA,EAC3E;AACA,MAAI,iBAAiB,YAAa,OAAM;AACxC,QAAM,IAAI;AAAA,IACR;AAAA,IACA,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,IACrD;AAAA,MACE,MAAM;AAAA,IACR;AAAA,EACF;AACF;AAQO,SAAS,QAAQ,SAAwB;AAC9C,QAAM,IAAI,WAAW,SAAS,sBAAsB;AACtD;AAGO,MAAM,eACX;AAWF,eAAsB,WAAc,MAAoC;AACtE,MAAI;AACF,WAAO,MAAM,KAAK;AAAA,EACpB,SAAS,OAAO;AACd,kBAAc,KAAK;AAAA,EACrB;AACF;",
6
+ "names": []
7
+ }