@supportpages.io/wtfm 0.0.0-stage → 0.3.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 (275) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +23 -0
  3. package/README.md +392 -2
  4. package/dist/actions.d.ts +98 -0
  5. package/dist/actions.js +86 -0
  6. package/dist/actions.js.map +1 -0
  7. package/dist/agent-settings.d.ts +22 -0
  8. package/dist/agent-settings.js +35 -0
  9. package/dist/agent-settings.js.map +1 -0
  10. package/dist/api.d.ts +14 -0
  11. package/dist/api.js +159 -0
  12. package/dist/api.js.map +1 -0
  13. package/dist/article-link.d.ts +16 -0
  14. package/dist/article-link.js +25 -0
  15. package/dist/article-link.js.map +1 -0
  16. package/dist/artifacts.d.ts +45 -0
  17. package/dist/artifacts.js +144 -0
  18. package/dist/artifacts.js.map +1 -0
  19. package/dist/brand.d.ts +4 -0
  20. package/dist/brand.js +9 -0
  21. package/dist/brand.js.map +1 -0
  22. package/dist/bridge.d.ts +2964 -0
  23. package/dist/bridge.js +1036 -0
  24. package/dist/bridge.js.map +1 -0
  25. package/dist/capacity.d.ts +5 -0
  26. package/dist/capacity.js +11 -0
  27. package/dist/capacity.js.map +1 -0
  28. package/dist/credentials.d.ts +13 -0
  29. package/dist/credentials.js +88 -0
  30. package/dist/credentials.js.map +1 -0
  31. package/dist/development-tls.d.ts +8 -0
  32. package/dist/development-tls.js +38 -0
  33. package/dist/development-tls.js.map +1 -0
  34. package/dist/errors.d.ts +15 -0
  35. package/dist/errors.js +18 -0
  36. package/dist/errors.js.map +1 -0
  37. package/dist/export.d.ts +11 -0
  38. package/dist/export.js +91 -0
  39. package/dist/export.js.map +1 -0
  40. package/dist/hosted-operations.d.ts +108 -0
  41. package/dist/hosted-operations.js +120 -0
  42. package/dist/hosted-operations.js.map +1 -0
  43. package/dist/hosting-benefits.d.ts +66 -0
  44. package/dist/hosting-benefits.js +67 -0
  45. package/dist/hosting-benefits.js.map +1 -0
  46. package/dist/index.d.ts +2 -0
  47. package/dist/index.js +49 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/local-inventory.d.ts +22 -0
  50. package/dist/local-inventory.js +59 -0
  51. package/dist/local-inventory.js.map +1 -0
  52. package/dist/local-setup.d.ts +208 -0
  53. package/dist/local-setup.js +140 -0
  54. package/dist/local-setup.js.map +1 -0
  55. package/dist/pairing.d.ts +71 -0
  56. package/dist/pairing.js +235 -0
  57. package/dist/pairing.js.map +1 -0
  58. package/dist/preferences.d.ts +18 -0
  59. package/dist/preferences.js +44 -0
  60. package/dist/preferences.js.map +1 -0
  61. package/dist/progress.d.ts +205 -0
  62. package/dist/progress.js +224 -0
  63. package/dist/progress.js.map +1 -0
  64. package/dist/reminders.d.ts +31 -0
  65. package/dist/reminders.js +73 -0
  66. package/dist/reminders.js.map +1 -0
  67. package/dist/replace-connection.d.ts +6 -0
  68. package/dist/replace-connection.js +77 -0
  69. package/dist/replace-connection.js.map +1 -0
  70. package/dist/repository-actions.d.ts +18 -0
  71. package/dist/repository-actions.js +9 -0
  72. package/dist/repository-actions.js.map +1 -0
  73. package/dist/repository-benefits.d.ts +96 -0
  74. package/dist/repository-benefits.js +64 -0
  75. package/dist/repository-benefits.js.map +1 -0
  76. package/dist/run-update.d.ts +17 -0
  77. package/dist/run-update.js +27 -0
  78. package/dist/run-update.js.map +1 -0
  79. package/dist/runs.d.ts +541 -0
  80. package/dist/runs.js +146 -0
  81. package/dist/runs.js.map +1 -0
  82. package/dist/runtime.d.ts +12 -0
  83. package/dist/runtime.js +58 -0
  84. package/dist/runtime.js.map +1 -0
  85. package/dist/schema.d.ts +277 -0
  86. package/dist/schema.js +66 -0
  87. package/dist/schema.js.map +1 -0
  88. package/dist/server.d.ts +4 -0
  89. package/dist/server.js +298 -0
  90. package/dist/server.js.map +1 -0
  91. package/dist/session.d.ts +1714 -0
  92. package/dist/session.js +619 -0
  93. package/dist/session.js.map +1 -0
  94. package/dist/settings.d.ts +9 -0
  95. package/dist/settings.js +21 -0
  96. package/dist/settings.js.map +1 -0
  97. package/dist/sync.d.ts +495 -0
  98. package/dist/sync.js +191 -0
  99. package/dist/sync.js.map +1 -0
  100. package/dist/telemetry-scrub.d.ts +13 -0
  101. package/dist/telemetry-scrub.js +51 -0
  102. package/dist/telemetry-scrub.js.map +1 -0
  103. package/dist/telemetry.d.ts +73 -0
  104. package/dist/telemetry.js +173 -0
  105. package/dist/telemetry.js.map +1 -0
  106. package/dist/walkthroughs.d.ts +224 -0
  107. package/dist/walkthroughs.js +109 -0
  108. package/dist/walkthroughs.js.map +1 -0
  109. package/dist/workspace.d.ts +14 -0
  110. package/dist/workspace.js +127 -0
  111. package/dist/workspace.js.map +1 -0
  112. package/dist/writer-agent.d.ts +21 -0
  113. package/dist/writer-agent.js +27 -0
  114. package/dist/writer-agent.js.map +1 -0
  115. package/dist/writer-entry.d.ts +171 -0
  116. package/dist/writer-entry.js +233 -0
  117. package/dist/writer-entry.js.map +1 -0
  118. package/dist/writing-style.d.ts +7 -0
  119. package/dist/writing-style.js +52 -0
  120. package/dist/writing-style.js.map +1 -0
  121. package/engine/SYNC.json +4 -0
  122. package/engine/VERSION +1 -0
  123. package/engine/detect-project/README.md +141 -0
  124. package/engine/detect-project/SKILL.md +1421 -0
  125. package/engine/detect-project/assets/desktop/desktop-frame.css +428 -0
  126. package/engine/detect-project/assets/game/game-frame.css +132 -0
  127. package/engine/detect-project/assets/macosui/LICENSE-puppertino.txt +21 -0
  128. package/engine/detect-project/assets/macosui/VERSIONS.txt +1 -0
  129. package/engine/detect-project/assets/macosui/fonts.css +15 -0
  130. package/engine/detect-project/assets/macosui/macos-frame.css +481 -0
  131. package/engine/detect-project/assets/macosui/puppertino.css +2153 -0
  132. package/engine/detect-project/assets/mobileui/LICENSE-fonts.txt +13 -0
  133. package/engine/detect-project/assets/mobileui/LICENSE-framework7.txt +52 -0
  134. package/engine/detect-project/assets/mobileui/VERSIONS.txt +6 -0
  135. package/engine/detect-project/assets/mobileui/device-frame.css +316 -0
  136. package/engine/detect-project/assets/mobileui/f7-color-theme.mjs +1345 -0
  137. package/engine/detect-project/assets/mobileui/f7-icons-names.json +1254 -0
  138. package/engine/detect-project/assets/mobileui/fonts.css +16 -0
  139. package/engine/detect-project/assets/mobileui/framework7-components.css +39 -0
  140. package/engine/detect-project/assets/mobileui/framework7-core.css +5245 -0
  141. package/engine/detect-project/assets/mobileui/icons.css +31 -0
  142. package/engine/detect-project/assets/mobileui/md3-defaults.css +89 -0
  143. package/engine/detect-project/assets/mobileui/platforms.json +46 -0
  144. package/engine/detect-project/assets/tailwind-fallback.css +1729 -0
  145. package/engine/detect-project/assets/webtui/LICENSE-webtui.txt +28 -0
  146. package/engine/detect-project/assets/webtui/VERSIONS.txt +7 -0
  147. package/engine/detect-project/assets/webtui/terminal-frame.css +195 -0
  148. package/engine/detect-project/assets/webtui/theme-catppuccin.css +1 -0
  149. package/engine/detect-project/assets/webtui/theme-everforest.css +1 -0
  150. package/engine/detect-project/assets/webtui/theme-gruvbox.css +1 -0
  151. package/engine/detect-project/assets/webtui/theme-nord.css +1 -0
  152. package/engine/detect-project/assets/webtui/theme-vitesse.css +1 -0
  153. package/engine/detect-project/assets/webtui/themes.json +37 -0
  154. package/engine/detect-project/assets/webtui/webtui-core.css +1 -0
  155. package/engine/detect-project/assets/win32ui/7css.css +2 -0
  156. package/engine/detect-project/assets/win32ui/LICENSE-7css.txt +21 -0
  157. package/engine/detect-project/assets/win32ui/VERSIONS.txt +1 -0
  158. package/engine/detect-project/assets/win32ui/win32-frame.css +278 -0
  159. package/engine/detect-project/package-lock.json +12 -0
  160. package/engine/detect-project/package.json +10 -0
  161. package/engine/detect-project/scripts/apply_runtime_profiles.js +313 -0
  162. package/engine/detect-project/scripts/check_css_health.js +412 -0
  163. package/engine/detect-project/scripts/check_project_map.js +150 -0
  164. package/engine/detect-project/scripts/check_runtime_coverage.js +311 -0
  165. package/engine/detect-project/scripts/check_runtime_recipe_quality.js +184 -0
  166. package/engine/detect-project/scripts/classify_app_type.sh +246 -0
  167. package/engine/detect-project/scripts/classify_surface.sh +95 -0
  168. package/engine/detect-project/scripts/classify_workspace.js +39 -0
  169. package/engine/detect-project/scripts/compile_css.sh +447 -0
  170. package/engine/detect-project/scripts/detect_static.js +645 -0
  171. package/engine/detect-project/scripts/detect_structure.js +187 -0
  172. package/engine/detect-project/scripts/include_census.js +451 -0
  173. package/engine/detect-project/scripts/json_get.js +142 -0
  174. package/engine/detect-project/scripts/merge_json.js +52 -0
  175. package/engine/detect-project/scripts/recommend_model_tier.js +252 -0
  176. package/engine/detect-project/scripts/resolve_route_chains.js +135 -0
  177. package/engine/detect-project/scripts/run_css_build.sh +40 -0
  178. package/engine/detect-project/scripts/sanitize_css.js +83 -0
  179. package/engine/detect-project/scripts/test_classify_surface.js +108 -0
  180. package/engine/detect-project/scripts/test_node_helpers.js +142 -0
  181. package/engine/detect-project/scripts/test_recommend_model_tier.js +119 -0
  182. package/engine/detect-project/scripts/test_resolve_route_chains.js +182 -0
  183. package/engine/detect-project/scripts/test_runtime_coverage.js +323 -0
  184. package/engine/detect-project/scripts/test_runtime_recipe_quality.js +187 -0
  185. package/engine/detect-project/scripts/theme_overrides.js +169 -0
  186. package/engine/detect-project/scripts/write_branding.js +129 -0
  187. package/engine/generate-illustrated-article/SKILL.md +461 -0
  188. package/engine/generate-illustrated-article/contracts/desktop.md +90 -0
  189. package/engine/generate-illustrated-article/contracts/game.md +38 -0
  190. package/engine/generate-illustrated-article/contracts/label-evidence.md +38 -0
  191. package/engine/generate-illustrated-article/contracts/macos.md +79 -0
  192. package/engine/generate-illustrated-article/contracts/mobile.md +40 -0
  193. package/engine/generate-illustrated-article/contracts/terminal.md +29 -0
  194. package/engine/generate-illustrated-article/contracts/win32.md +43 -0
  195. package/engine/generate-illustrated-article/package-lock.json +366 -0
  196. package/engine/generate-illustrated-article/package.json +15 -0
  197. package/engine/generate-illustrated-article/scripts/article_blocks.js +34 -0
  198. package/engine/generate-illustrated-article/scripts/check_article_json.js +105 -0
  199. package/engine/generate-illustrated-article/scripts/emit_walkthrough_signals.js +100 -0
  200. package/engine/generate-illustrated-article/scripts/extract_images.js +187 -0
  201. package/engine/generate-illustrated-article/scripts/generate_content_images.js +376 -0
  202. package/engine/generate-illustrated-article/scripts/include_census.js +451 -0
  203. package/engine/generate-illustrated-article/scripts/inject_assets.js +1691 -0
  204. package/engine/generate-illustrated-article/scripts/jit_mockup_css.js +191 -0
  205. package/engine/generate-illustrated-article/scripts/label_evidence.js +87 -0
  206. package/engine/generate-illustrated-article/scripts/lint_article_copy.js +252 -0
  207. package/engine/generate-illustrated-article/scripts/lint_mockup_fidelity.js +2403 -0
  208. package/engine/generate-illustrated-article/scripts/polish_tickets.js +1148 -0
  209. package/engine/generate-illustrated-article/scripts/related_repos.sh +52 -0
  210. package/engine/generate-illustrated-article/scripts/render_all.js +177 -0
  211. package/engine/generate-illustrated-article/scripts/render_mockup.js +665 -0
  212. package/engine/generate-illustrated-article/scripts/render_ready.js +164 -0
  213. package/engine/generate-illustrated-article/scripts/resolve_workspace.sh +86 -0
  214. package/engine/generate-illustrated-article/scripts/runtime_region_geometry.js +55 -0
  215. package/engine/generate-illustrated-article/scripts/source_paths.js +49 -0
  216. package/engine/generate-illustrated-article/scripts/test_control_visibility.js +30 -0
  217. package/engine/generate-illustrated-article/scripts/test_emit_walkthrough_signals.js +157 -0
  218. package/engine/generate-illustrated-article/scripts/test_generate_content_images.js +168 -0
  219. package/engine/generate-illustrated-article/scripts/test_include_census.js +126 -0
  220. package/engine/generate-illustrated-article/scripts/test_label_evidence.js +49 -0
  221. package/engine/generate-illustrated-article/scripts/test_lint_article_copy.js +138 -0
  222. package/engine/generate-illustrated-article/scripts/test_lint_mockup_fidelity.js +653 -0
  223. package/engine/generate-illustrated-article/scripts/test_node_ports.js +152 -0
  224. package/engine/generate-illustrated-article/scripts/test_polish_tickets.js +481 -0
  225. package/engine/generate-illustrated-article/scripts/test_related_repos.js +64 -0
  226. package/engine/generate-illustrated-article/scripts/test_render_ready.js +85 -0
  227. package/engine/generate-illustrated-article/scripts/test_source_paths.js +68 -0
  228. package/engine/generate-illustrated-article/scripts/trace_hook.js +79 -0
  229. package/engine/generate-illustrated-article/scripts/trace_hook.sh +4 -0
  230. package/engine/generate-illustrated-article/scripts/validate_html.js +114 -0
  231. package/engine/generate-illustrated-article/scripts/watermark.js +69 -0
  232. package/install.sh +14 -0
  233. package/package.json +57 -4
  234. package/scripts/auth.mjs +33 -0
  235. package/scripts/auto-update.mjs +7 -0
  236. package/scripts/build-plugin.mjs +58 -0
  237. package/scripts/build-release.mjs +94 -0
  238. package/scripts/check-release.mjs +40 -0
  239. package/scripts/check-runtime.mjs +10 -0
  240. package/scripts/cli.mjs +8 -0
  241. package/scripts/install.mjs +64 -0
  242. package/scripts/lib/agent-runner.mjs +181 -0
  243. package/scripts/lib/agent-settings.mjs +215 -0
  244. package/scripts/lib/article-skills.mjs +82 -0
  245. package/scripts/lib/auto-update.mjs +50 -0
  246. package/scripts/lib/brand.mjs +9 -0
  247. package/scripts/lib/browser.mjs +12 -0
  248. package/scripts/lib/claude-connection.mjs +33 -0
  249. package/scripts/lib/claude-permissions.mjs +47 -0
  250. package/scripts/lib/claude-plugin.mjs +15 -0
  251. package/scripts/lib/claude-writer.mjs +10 -0
  252. package/scripts/lib/cli-main.mjs +85 -0
  253. package/scripts/lib/cli.mjs +888 -0
  254. package/scripts/lib/codex-config.mjs +51 -0
  255. package/scripts/lib/codex-integration.mjs +61 -0
  256. package/scripts/lib/codex-skill.mjs +34 -0
  257. package/scripts/lib/harness-models.mjs +109 -0
  258. package/scripts/lib/install.mjs +269 -0
  259. package/scripts/lib/managed-writer.mjs +38 -0
  260. package/scripts/lib/planning.mjs +263 -0
  261. package/scripts/lib/prepare-update.mjs +85 -0
  262. package/scripts/lib/refresh-writers.mjs +12 -0
  263. package/scripts/lib/remove.mjs +167 -0
  264. package/scripts/lib/renderer.mjs +34 -0
  265. package/scripts/lib/terminal.mjs +252 -0
  266. package/scripts/lib/uninit.mjs +72 -0
  267. package/scripts/lib/update.mjs +55 -0
  268. package/scripts/lib/writer-recovery.mjs +35 -0
  269. package/scripts/lib/yolo.mjs +362 -0
  270. package/scripts/plugin-session.mjs +65 -0
  271. package/scripts/prepare-update.mjs +12 -0
  272. package/scripts/publish-release.mjs +92 -0
  273. package/scripts/skills/supportpages/SKILL.md +120 -0
  274. package/scripts/smoke-release.mjs +101 -0
  275. package/server.json +27 -0
@@ -0,0 +1,224 @@
1
+ import { z } from 'zod';
2
+ import type { Bridge } from './bridge.js';
3
+ import { contextSchema } from './schema.js';
4
+ export declare const walkthroughSchema: z.ZodObject<{
5
+ id: z.ZodString;
6
+ project_id: z.ZodString;
7
+ article_id: z.ZodString;
8
+ title: z.ZodString;
9
+ slug: z.ZodString;
10
+ revision: z.ZodString;
11
+ generation_status: z.ZodEnum<{
12
+ running: "running";
13
+ failed: "failed";
14
+ pending: "pending";
15
+ completed: "completed";
16
+ }>;
17
+ ready: z.ZodBoolean;
18
+ narrated: z.ZodBoolean;
19
+ publication_pending: z.ZodBoolean;
20
+ shared: z.ZodBoolean;
21
+ public_on_article: z.ZodBoolean;
22
+ review_url: z.ZodURL;
23
+ playback_url: z.ZodNullable<z.ZodURL>;
24
+ public_url: z.ZodNullable<z.ZodURL>;
25
+ article_public_url: z.ZodNullable<z.ZodURL>;
26
+ assets: z.ZodObject<{
27
+ video: z.ZodBoolean;
28
+ narrated_video: z.ZodBoolean;
29
+ subtitles: z.ZodBoolean;
30
+ transcript: z.ZodBoolean;
31
+ poster: z.ZodBoolean;
32
+ }, z.core.$strip>;
33
+ created_at: z.ZodISODateTime;
34
+ updated_at: z.ZodISODateTime;
35
+ generated_at: z.ZodNullable<z.ZodISODateTime>;
36
+ shared_at: z.ZodNullable<z.ZodISODateTime>;
37
+ error: z.ZodNullable<z.ZodObject<{
38
+ code: z.ZodString;
39
+ message: z.ZodString;
40
+ }, z.core.$strip>>;
41
+ transcript_text: z.ZodOptional<z.ZodNullable<z.ZodString>>;
42
+ transcript_omitted: z.ZodOptional<z.ZodBoolean>;
43
+ }, z.core.$strip>;
44
+ type Context = z.infer<typeof contextSchema>;
45
+ export declare class Walkthroughs {
46
+ private bridge;
47
+ constructor(bridge: Bridge);
48
+ private supported;
49
+ private check;
50
+ list(input?: {
51
+ after_id?: string;
52
+ through_id?: string;
53
+ article_id?: string;
54
+ }, context?: Context): Promise<{
55
+ project_id: string;
56
+ through_id: string;
57
+ next_cursor: string | null;
58
+ walkthroughs: {
59
+ id: string;
60
+ project_id: string;
61
+ article_id: string;
62
+ title: string;
63
+ slug: string;
64
+ revision: string;
65
+ generation_status: "running" | "failed" | "pending" | "completed";
66
+ ready: boolean;
67
+ narrated: boolean;
68
+ publication_pending: boolean;
69
+ shared: boolean;
70
+ public_on_article: boolean;
71
+ review_url: string;
72
+ playback_url: string | null;
73
+ public_url: string | null;
74
+ article_public_url: string | null;
75
+ assets: {
76
+ video: boolean;
77
+ narrated_video: boolean;
78
+ subtitles: boolean;
79
+ transcript: boolean;
80
+ poster: boolean;
81
+ };
82
+ created_at: string;
83
+ updated_at: string;
84
+ generated_at: string | null;
85
+ shared_at: string | null;
86
+ error: {
87
+ code: string;
88
+ message: string;
89
+ } | null;
90
+ transcript_text?: string | null | undefined;
91
+ transcript_omitted?: boolean | undefined;
92
+ }[];
93
+ }>;
94
+ get(id: string): Promise<{
95
+ id: string;
96
+ project_id: string;
97
+ article_id: string;
98
+ title: string;
99
+ slug: string;
100
+ revision: string;
101
+ generation_status: "running" | "failed" | "pending" | "completed";
102
+ ready: boolean;
103
+ narrated: boolean;
104
+ publication_pending: boolean;
105
+ shared: boolean;
106
+ public_on_article: boolean;
107
+ review_url: string;
108
+ playback_url: string | null;
109
+ public_url: string | null;
110
+ article_public_url: string | null;
111
+ assets: {
112
+ video: boolean;
113
+ narrated_video: boolean;
114
+ subtitles: boolean;
115
+ transcript: boolean;
116
+ poster: boolean;
117
+ };
118
+ created_at: string;
119
+ updated_at: string;
120
+ generated_at: string | null;
121
+ shared_at: string | null;
122
+ error: {
123
+ code: string;
124
+ message: string;
125
+ } | null;
126
+ transcript_text?: string | null | undefined;
127
+ transcript_omitted?: boolean | undefined;
128
+ }>;
129
+ refresh(context: Context, previous?: unknown): Promise<{
130
+ status: "unsupported";
131
+ instructions: string;
132
+ synced_at?: undefined;
133
+ project_id?: undefined;
134
+ api_origin?: undefined;
135
+ items?: undefined;
136
+ counts?: undefined;
137
+ } | {
138
+ status: "ready";
139
+ synced_at: string;
140
+ project_id: string;
141
+ api_origin: string;
142
+ items: {
143
+ id: string;
144
+ remote: {
145
+ id: string;
146
+ project_id: string;
147
+ article_id: string;
148
+ title: string;
149
+ slug: string;
150
+ revision: string;
151
+ generation_status: "running" | "failed" | "pending" | "completed";
152
+ ready: boolean;
153
+ narrated: boolean;
154
+ publication_pending: boolean;
155
+ shared: boolean;
156
+ public_on_article: boolean;
157
+ review_url: string;
158
+ playback_url: string | null;
159
+ public_url: string | null;
160
+ article_public_url: string | null;
161
+ assets: {
162
+ video: boolean;
163
+ narrated_video: boolean;
164
+ subtitles: boolean;
165
+ transcript: boolean;
166
+ poster: boolean;
167
+ };
168
+ created_at: string;
169
+ updated_at: string;
170
+ generated_at: string | null;
171
+ shared_at: string | null;
172
+ error: {
173
+ code: string;
174
+ message: string;
175
+ } | null;
176
+ transcript_text?: string | null | undefined;
177
+ transcript_omitted?: boolean | undefined;
178
+ } | null;
179
+ sync_status: "remote_only" | "synced" | "remote_changed" | "unavailable";
180
+ last_known?: {
181
+ id: string;
182
+ project_id: string;
183
+ article_id: string;
184
+ title: string;
185
+ slug: string;
186
+ revision: string;
187
+ generation_status: "running" | "failed" | "pending" | "completed";
188
+ ready: boolean;
189
+ narrated: boolean;
190
+ publication_pending: boolean;
191
+ shared: boolean;
192
+ public_on_article: boolean;
193
+ review_url: string;
194
+ playback_url: string | null;
195
+ public_url: string | null;
196
+ article_public_url: string | null;
197
+ assets: {
198
+ video: boolean;
199
+ narrated_video: boolean;
200
+ subtitles: boolean;
201
+ transcript: boolean;
202
+ poster: boolean;
203
+ };
204
+ created_at: string;
205
+ updated_at: string;
206
+ generated_at: string | null;
207
+ shared_at: string | null;
208
+ error: {
209
+ code: string;
210
+ message: string;
211
+ } | null;
212
+ transcript_text?: string | null | undefined;
213
+ transcript_omitted?: boolean | undefined;
214
+ } | undefined;
215
+ }[];
216
+ counts: {
217
+ remote: number;
218
+ changed: number;
219
+ unavailable: number;
220
+ };
221
+ instructions: string;
222
+ }>;
223
+ }
224
+ export {};
@@ -0,0 +1,109 @@
1
+ import { z } from 'zod';
2
+ import { remoteId } from './schema.js';
3
+ import { parse } from './artifacts.js';
4
+ import { fail } from './errors.js';
5
+ import { requireExecution, resolveAction } from './actions.js';
6
+ export const walkthroughSchema = z.object({
7
+ id: remoteId, project_id: remoteId, article_id: remoteId, title: z.string(), slug: z.string(),
8
+ revision: z.string().regex(/^[a-f0-9]{64}$/), generation_status: z.enum(['pending', 'running', 'completed', 'failed']),
9
+ ready: z.boolean(), narrated: z.boolean(), publication_pending: z.boolean(), shared: z.boolean(), public_on_article: z.boolean(),
10
+ review_url: z.url(), playback_url: z.url().nullable(), public_url: z.url().nullable(), article_public_url: z.url().nullable(),
11
+ assets: z.object({ video: z.boolean(), narrated_video: z.boolean(), subtitles: z.boolean(), transcript: z.boolean(), poster: z.boolean() }),
12
+ created_at: z.iso.datetime(), updated_at: z.iso.datetime(), generated_at: z.iso.datetime().nullable(), shared_at: z.iso.datetime().nullable(),
13
+ error: z.object({ code: z.string(), message: z.string().max(500) }).nullable(),
14
+ transcript_text: z.string().max(200_000).nullable().optional(), transcript_omitted: z.boolean().optional(),
15
+ });
16
+ const pageSchema = z.object({ project_id: remoteId, through_id: z.string().regex(/^\d+$/), next_cursor: remoteId.nullable(), walkthroughs: z.array(walkthroughSchema).max(500) });
17
+ const snapshotSchema = z.object({ project_id: remoteId, api_origin: z.url(), items: z.array(z.object({
18
+ id: remoteId, remote: walkthroughSchema.nullable(), last_known: walkthroughSchema.optional(),
19
+ sync_status: z.enum(['remote_only', 'synced', 'remote_changed', 'unavailable']),
20
+ })) });
21
+ export class Walkthroughs {
22
+ bridge;
23
+ constructor(bridge) {
24
+ this.bridge = bridge;
25
+ }
26
+ async supported() {
27
+ // Article and walkthrough inspection share the existing read permission.
28
+ // The additive context flag lets older clients keep their action contract.
29
+ requireExecution(await resolveAction(this.bridge, 'read_articles'), 'remote');
30
+ const context = await this.bridge.context();
31
+ if (!context.walkthrough_sync)
32
+ fail('server_update_required', 'Update the SupportPages server to inspect video walkthroughs.');
33
+ return context;
34
+ }
35
+ check(item, project) {
36
+ if (item.project_id !== project)
37
+ fail('invalid_response', 'The server returned a walkthrough from another project.');
38
+ for (const value of [item.review_url, item.playback_url]) {
39
+ if (!value)
40
+ continue;
41
+ const url = new URL(value), origin = new URL(this.bridge.api.origin);
42
+ if (url.username || url.password || url.origin !== origin.origin && !(this.bridge.api.dev && url.hostname === origin.hostname && url.protocol === 'https:'))
43
+ fail('invalid_response', 'Invalid walkthrough review link.');
44
+ }
45
+ return item;
46
+ }
47
+ async list(input = {}, context) {
48
+ context ??= await this.supported();
49
+ const binding = await this.bridge.binding();
50
+ if (context.project.id !== binding.project_id)
51
+ fail('destination_mismatch', 'The project changed while reading walkthroughs.');
52
+ const query = new URLSearchParams();
53
+ for (const [key, value] of Object.entries(input))
54
+ if (value !== undefined)
55
+ query.set(key, parse(key === 'through_id' ? z.string().regex(/^\d+$/) : remoteId, value));
56
+ const page = parse(pageSchema, await this.bridge.api.request('GET', `/projects/${binding.project_id}/walkthroughs${query.size ? `?${query}` : ''}`), 'invalid_response');
57
+ if (page.project_id !== binding.project_id || input.through_id !== undefined && page.through_id !== input.through_id)
58
+ fail('invalid_response', 'The walkthrough inventory changed project or bounds.');
59
+ let previous = BigInt(input.after_id ?? '0');
60
+ for (const item of page.walkthroughs) {
61
+ this.check(item, binding.project_id);
62
+ if (BigInt(item.id) <= previous || BigInt(item.id) > BigInt(page.through_id) || input.article_id && item.article_id !== input.article_id)
63
+ fail('invalid_response', 'Invalid walkthrough inventory page.');
64
+ previous = BigInt(item.id);
65
+ }
66
+ if (page.next_cursor && page.next_cursor !== page.walkthroughs.at(-1)?.id)
67
+ fail('invalid_response', 'Invalid walkthrough cursor.');
68
+ return page;
69
+ }
70
+ async get(id) {
71
+ parse(remoteId, id);
72
+ await this.supported();
73
+ const binding = await this.bridge.binding();
74
+ const item = this.check(parse(walkthroughSchema, await this.bridge.api.request('GET', `/projects/${binding.project_id}/walkthroughs/${id}`), 'invalid_response'), binding.project_id);
75
+ if (item.id !== id)
76
+ fail('invalid_response', 'The server returned another walkthrough.');
77
+ return item;
78
+ }
79
+ // Called under the project sync lock. The caller commits the combined article
80
+ // and video snapshot only after both complete inventories have been validated.
81
+ async refresh(context, previous) {
82
+ if (!context.walkthrough_sync)
83
+ return { status: 'unsupported', instructions: 'Update the SupportPages server to sync video walkthroughs.' };
84
+ const binding = await this.bridge.binding();
85
+ const prior = snapshotSchema.safeParse(previous);
86
+ const known = new Map(prior.success && prior.data.project_id === binding.project_id && prior.data.api_origin === binding.api_origin ? prior.data.items.map(item => [item.id, item.remote ?? item.last_known]) : []);
87
+ const rows = [];
88
+ let cursor, through;
89
+ do {
90
+ const page = await this.list({ after_id: cursor, through_id: through }, context);
91
+ rows.push(...page.walkthroughs);
92
+ if (rows.length > 100_000)
93
+ fail('inventory_truncated', 'Too many walkthroughs to sync. The previous snapshot has been kept.');
94
+ through = page.through_id;
95
+ cursor = page.next_cursor ?? undefined;
96
+ } while (cursor);
97
+ const items = rows.map(remote => {
98
+ const before = known.get(remote.id);
99
+ known.delete(remote.id);
100
+ return { id: remote.id, remote, sync_status: !before ? 'remote_only' : before.revision === remote.revision ? 'synced' : 'remote_changed' };
101
+ });
102
+ for (const [id, last_known] of known)
103
+ items.push({ id, remote: null, last_known, sync_status: 'unavailable' });
104
+ return { status: 'ready', synced_at: new Date().toISOString(), project_id: binding.project_id, api_origin: binding.api_origin, items,
105
+ counts: { remote: rows.length, changed: items.filter(item => item.sync_status === 'remote_changed').length, unavailable: known.size },
106
+ instructions: 'Current walkthrough metadata is refreshed. Missing videos are unavailable (removed or their article is no longer accessible); last_known is historical. Reads never regenerate or share a video.' };
107
+ }
108
+ }
109
+ //# sourceMappingURL=walkthroughs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walkthroughs.js","sourceRoot":"","sources":["../src/walkthroughs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAiB,QAAQ,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAC7F,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;IACtH,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,mBAAmB,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,iBAAiB,EAAE,CAAC,CAAC,OAAO,EAAE;IAChI,UAAU,EAAE,CAAC,CAAC,GAAG,EAAE,E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E,WAAW,EAAE,aAAa,EAAE,CAAC,CAAC;QAC/G,OAAO,EAAE,MAAM,EAAE,OAAgB,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,KAAK;YAC3I,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,KAAK,gBAAgB,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,IAAI,EAAE;YACrI,YAAY,EAAE,kMAAkM,EAAE,CAAC;IACvN,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ export declare class Workspace {
2
+ root: string;
3
+ private constructor();
4
+ static create(root: string): Promise<Workspace>;
5
+ private contains;
6
+ resolve(relative: string): Promise<string>;
7
+ read(relative: string, limit?: number): Promise<NonSharedBuffer>;
8
+ json(relative: string): Promise<unknown>;
9
+ exists(relative: string): Promise<boolean>;
10
+ write(relative: string, data: string | Buffer): Promise<string>;
11
+ writeJson(relative: string, data: unknown): Promise<string>;
12
+ list(relative: string): Promise<import("fs").Dirent<string>[]>;
13
+ lock<T>(fn: () => Promise<T>): Promise<T>;
14
+ }
@@ -0,0 +1,127 @@
1
+ import { constants } from 'node:fs';
2
+ import { mkdir, realpath, lstat, open, rename, rm, readdir } from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { randomUUID } from 'node:crypto';
5
+ import { fail } from './errors.js';
6
+ export class Workspace {
7
+ root;
8
+ constructor(root) {
9
+ this.root = root;
10
+ }
11
+ static async create(root) {
12
+ const canonical = await realpath(root);
13
+ if (!(await lstat(canonical)).isDirectory())
14
+ fail('invalid_workspace', 'The workspace must be a directory.');
15
+ return new Workspace(canonical);
16
+ }
17
+ contains(p) { const rel = path.relative(this.root, p); return rel === '' || (!rel.startsWith('..' + path.sep) && rel !== '..' && !path.isAbsolute(rel)); }
18
+ async resolve(relative) {
19
+ if (path.isAbsolute(relative) || relative.includes('\0'))
20
+ fail('invalid_path', 'Use a path relative to the configured workspace.');
21
+ const candidate = path.resolve(this.root, relative);
22
+ if (!this.contains(candidate))
23
+ fail('invalid_path', 'Path escapes the configured workspace.');
24
+ let cursor = this.root;
25
+ for (const part of path.relative(this.root, candidate).split(path.sep).filter(Boolean)) {
26
+ cursor = path.join(cursor, part);
27
+ try {
28
+ if ((await lstat(cursor)).isSymbolicLink())
29
+ fail('invalid_path', 'Artifact and state paths must not contain symlinks.');
30
+ }
31
+ catch (e) {
32
+ if (e.code !== 'ENOENT')
33
+ throw e;
34
+ }
35
+ }
36
+ return candidate;
37
+ }
38
+ async read(relative, limit = 2 * 1024 * 1024) {
39
+ const p = await this.resolve(relative);
40
+ let file;
41
+ try {
42
+ file = await open(p, constants.O_RDONLY | constants.O_NOFOLLOW);
43
+ }
44
+ catch (e) {
45
+ if (e.code === 'ENOENT')
46
+ fail('missing_artifact', `Missing ${relative}`);
47
+ throw e;
48
+ }
49
+ try {
50
+ const stat = await file.stat();
51
+ if (!stat.isFile() || stat.size > limit)
52
+ fail('invalid_artifact', `${relative} is not a regular file within the size limit.`);
53
+ const data = await file.readFile();
54
+ if (data.length > limit)
55
+ fail('invalid_artifact', `${relative} exceeds the size limit.`);
56
+ return data;
57
+ }
58
+ finally {
59
+ await file.close();
60
+ }
61
+ }
62
+ async json(relative) {
63
+ const data = await this.read(relative);
64
+ try {
65
+ return JSON.parse(data.toString('utf8'));
66
+ }
67
+ catch {
68
+ fail('invalid_artifact', `${relative} is not valid JSON.`);
69
+ }
70
+ }
71
+ async exists(relative) { try {
72
+ await lstat(await this.resolve(relative));
73
+ return true;
74
+ }
75
+ catch (e) {
76
+ if (e.code === 'ENOENT')
77
+ return false;
78
+ throw e;
79
+ } }
80
+ async write(relative, data) {
81
+ const target = await this.resolve(relative);
82
+ await mkdir(path.dirname(target), { recursive: true, mode: 0o700 });
83
+ await this.resolve(relative);
84
+ const temp = `${target}.${randomUUID()}.tmp`;
85
+ const file = await open(temp, 'wx', 0o600);
86
+ try {
87
+ await file.writeFile(data);
88
+ await file.sync();
89
+ }
90
+ finally {
91
+ await file.close();
92
+ }
93
+ try {
94
+ await rename(temp, target);
95
+ }
96
+ finally {
97
+ await rm(temp, { force: true });
98
+ }
99
+ return target;
100
+ }
101
+ async writeJson(relative, data) { return this.write(relative, JSON.stringify(data, null, 2) + '\n'); }
102
+ async list(relative) {
103
+ if (!await this.exists(relative))
104
+ return [];
105
+ return readdir(await this.resolve(relative), { withFileTypes: true });
106
+ }
107
+ async lock(fn) {
108
+ const dir = await this.resolve('.rtfm/supportpages');
109
+ await mkdir(dir, { recursive: true, mode: 0o700 });
110
+ const lock = await this.resolve('.rtfm/supportpages/operation.lock');
111
+ try {
112
+ await mkdir(lock);
113
+ }
114
+ catch (e) {
115
+ if (e.code === 'EEXIST')
116
+ fail('workspace_busy', 'Another operation holds the workspace lock. If its process crashed, remove .rtfm/supportpages/operation.lock after confirming it has stopped.');
117
+ throw e;
118
+ }
119
+ try {
120
+ return await fn();
121
+ }
122
+ finally {
123
+ await rm(lock, { recursive: true, force: true });
124
+ }
125
+ }
126
+ }
127
+ //# sourceMappingURL=workspace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.js","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,MAAM,OAAO,SAAS;IAC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AO,CAAC,mCAAmC,CAAC,CAAC;QACrE,IAAI,CAAC;YAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;QAAC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YAAC,IAAK,CAA2B,CAAC,IAAI,KAAK,QAAQ;gBAAE,IAAI,CAAC,gBAAgB,EAAE,+IAA+I,CAAC,CAAC;YAAC,MAAM,CAAC,CAAC;QAAC,CAAC;QAC9Q,IAAI,CAAC;YAAC,OAAO,MAAM,EAAE,EAAE,CAAC;QAAC,CAAC;gBAAS,CAAC;YAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAAC,CAAC;IAC1F,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ export declare const writerAgentName = "SupportPages.io";
2
+ export declare const writerAgentType = "supportpages-io";
3
+ /** Claude Code namespaces plugin agents as <plugin>:<agent>. The plugin's MCP
4
+ * configuration sets SUPPORTPAGES_PLUGIN to the plugin name. */
5
+ export declare const pluginName: string | undefined;
6
+ export declare const writerSubagentType: string;
7
+ export declare const writerPermissionInstruction = "Permission requests take priority over concise reporting and article chat guidance; approval prompts must include the command and access needed. When an operation needs additional permission and the host policy allows requests, use the host native approval mechanism directly with the exact command and a clear reason. A sandbox restriction is not an explicit user denial: request approval rather than immediately reporting failure. Wait for the approval decision and continue only if granted. Do not send a request only to the parent when a native approval prompt is available. If approval is denied, policy forbids requesting it, or this host cannot surface it, stop the blocked action and report permission_blocked to the parent with the failed command, specific cause and recovery needed. Do not retry around a denial, weaken sandbox settings, enable YOLO, or bypass restrictions. Publication consent remains the parent responsibility.";
8
+ export declare const backgroundWriterInstruction = "Background reporting: prioritize completing the article and resolving blockers over silence. After the entrypoint succeeds, notify the parent of startup with run_id and editor_url using the host messaging facility when available. Send concise milestone updates and report blockers immediately; include technical diagnostics needed for recovery instead of hiding them. Native approval prompts are allowed and must not be suppressed. Return a final result with run_id, status and editor_url. Report success only after the required finish command confirms delivery; otherwise report permission_blocked, delivery_pending, upload_failed or the specific failure. The parent handles the final user-facing response and publication consent.";
9
+ export declare const backgroundParentInstruction = "For background articles, supervise the delegated writer until it finishes or needs user intervention. Pass the complete task brief directly to the writer, preserve its task identity and completion notification, and record the successful launch with supportpages_update_run. Show the editor link and say launched unless actual startup is confirmed. Keep the main turn active and use the host agent wait/message facilities to receive progress, approval requests and the final result; do not end the turn merely because launch succeeded. Use bounded waits and concise progress updates rather than rapid status polling. Allow the writer to request native approvals directly when host policy permits. Never treat a sandbox restriction as an explicit user denial. If a background writer cannot surface approval, confirm it has stopped, then continue the same article in the foreground using the MCP recovery instructions and normal approval mechanism; foreground execution does not grant extra permissions. If approval is denied or forbidden by policy, report the specific block and stop that action without bypassing it. Inspect the writer final result and saved run: a host Completed notification alone is not success. For a stopped writer that failed or is permission_blocked before generation finished, record event=failed with stopped=true via supportpages_update_run and show the cause and recovery with the editor link. For a successfully generated writer, call supportpages_complete_article and report the confirmed delivery once. Recover delivery_pending or upload_failed through complete_article without regenerating or marking the writer failed. Keep the writer and MCP session alive. If the host cannot supervise a delegated task, use the foreground fallback; do not launch a separate agent CLI. Honor an explicit user request to return immediately, but explain that approvals or completion may require another user turn on hosts that do not wake the parent.";
10
+ export declare function writerReportingInstruction(background: boolean): string;
11
+ export declare const claudeWriterAgents: {
12
+ "supportpages-io": {
13
+ description: string;
14
+ model: string;
15
+ prompt: string;
16
+ };
17
+ };
18
+ export declare const writerLaunchInstruction: string;
19
+ export declare const writerAgentFile: string;
20
+ export declare const codexWriterFile: string;
21
+ export declare const codexWriterLaunchInstruction = "In Codex, use the registered supportpages-io custom agent for this article. Name the delegated task SupportPages.io followed by the article topic. Pass task_brief.codex_model and task_brief.codex_reasoning_effort as the host's model and reasoning_effort spawn overrides when non-null; omit null overrides to use Codex's configured defaults. Start with a fresh context containing the complete task brief so the host can apply explicit model overrides. Pass that brief directly in the subagent tool task/message argument; do not copy it into a temporary JSON file, create a handoff script, or print it through a shell command. The entrypoint already loads the saved run, so launching the writer needs no parent-side file edit. Apply this on retries too. Use background execution only when prefer_background is true. If the host has no custom-agent selector, use a named SupportPages.io task with task_brief.writer_instructions and the same model settings. The installed SupportPages.io coordination skill explicitly requests background delegation when the prepared run prefers it. Do not infer that delegation is disabled merely because the user did not separately request a subagent. If a host tool is missing, a session restriction forbids delegation, or launch fails, explain that specific limitation and run the same task brief in the foreground after stopping any launched writer. Do not silently substitute an unsupported model. Work in the existing directory, without a worktree or a separate agent CLI. The parent handles all MCP calls, previews, draft completion and publication consent; the writer only generates and validates files. Keep the parent's sandbox and permission controls.";
@@ -0,0 +1,27 @@
1
+ import { articleChatInstruction } from './article-link.js';
2
+ export const writerAgentName = 'SupportPages.io';
3
+ export const writerAgentType = 'supportpages-io';
4
+ /** Claude Code namespaces plugin agents as <plugin>:<agent>. The plugin's MCP
5
+ * configuration sets SUPPORTPAGES_PLUGIN to the plugin name. */
6
+ export const pluginName = process.env.SUPPORTPAGES_PLUGIN?.trim() || undefined;
7
+ export const writerSubagentType = pluginName ? `${pluginName}:${writerAgentType}` : writerAgentType;
8
+ export const writerPermissionInstruction = 'Permission requests take priority over concise reporting and article chat guidance; approval prompts must include the command and access needed. When an operation needs additional permission and the host policy allows requests, use the host native approval mechanism directly with the exact command and a clear reason. A sandbox restriction is not an explicit user denial: request approval rather than immediately reporting failure. Wait for the approval decision and continue only if granted. Do not send a request only to the parent when a native approval prompt is available. If approval is denied, policy forbids requesting it, or this host cannot surface it, stop the blocked action and report permission_blocked to the parent with the failed command, specific cause and recovery needed. Do not retry around a denial, weaken sandbox settings, enable YOLO, or bypass restrictions. Publication consent remains the parent responsibility.';
9
+ export const backgroundWriterInstruction = 'Background reporting: prioritize completing the article and resolving blockers over silence. After the entrypoint succeeds, notify the parent of startup with run_id and editor_url using the host messaging facility when available. Send concise milestone updates and report blockers immediately; include technical diagnostics needed for recovery instead of hiding them. Native approval prompts are allowed and must not be suppressed. Return a final result with run_id, status and editor_url. Report success only after the required finish command confirms delivery; otherwise report permission_blocked, delivery_pending, upload_failed or the specific failure. The parent handles the final user-facing response and publication consent.';
10
+ export const backgroundParentInstruction = 'For background articles, supervise the delegated writer until it finishes or needs user intervention. Pass the complete task brief directly to the writer, preserve its task identity and completion notification, and record the successful launch with supportpages_update_run. Show the editor link and say launched unless actual startup is confirmed. Keep the main turn active and use the host agent wait/message facilities to receive progress, approval requests and the final result; do not end the turn merely because launch succeeded. Use bounded waits and concise progress updates rather than rapid status polling. Allow the writer to request native approvals directly when host policy permits. Never treat a sandbox restriction as an explicit user denial. If a background writer cannot surface approval, confirm it has stopped, then continue the same article in the foreground using the MCP recovery instructions and normal approval mechanism; foreground execution does not grant extra permissions. If approval is denied or forbidden by policy, report the specific block and stop that action without bypassing it. Inspect the writer final result and saved run: a host Completed notification alone is not success. For a stopped writer that failed or is permission_blocked before generation finished, record event=failed with stopped=true via supportpages_update_run and show the cause and recovery with the editor link. For a successfully generated writer, call supportpages_complete_article and report the confirmed delivery once. Recover delivery_pending or upload_failed through complete_article without regenerating or marking the writer failed. Keep the writer and MCP session alive. If the host cannot supervise a delegated task, use the foreground fallback; do not launch a separate agent CLI. Honor an explicit user request to return immediately, but explain that approvals or completion may require another user turn on hosts that do not wake the parent.';
11
+ export function writerReportingInstruction(background) {
12
+ return (background ? backgroundWriterInstruction : 'Foreground reporting: include the supplied editor_url in your first progress report and your completion or failure report when available; keep the same link on retries. Keep progress concise and follow the article chat guidance.') + ' ' + writerPermissionInstruction;
13
+ }
14
+ // Shared by the persistent Claude agent and session-scoped --agents definition.
15
+ // Model and permissions inherit the session.
16
+ export const claudeWriterAgents = {
17
+ [writerAgentType]: {
18
+ description: 'SupportPages Writer agent for illustrated help articles. Use only after supportpages_prepare_article or supportpages_retry_article returns a task brief.',
19
+ model: 'inherit',
20
+ prompt: 'You are the SupportPages.io article writer. Execute the supplied task brief using its workspace, environment, output directory and installed skills. Always run task_brief.entrypoint.shell_command exactly as supplied before reading generation instructions or writing content. The launcher loads the saved run configuration; no environment exports are needed. Run subsequent generation, rendering and validation commands through task_brief.execution so each command gets the correct environment in a fresh shell. If no prepared task brief or entrypoint was supplied, or its check fails, return to the main agent without writing and ask it to call supportpages_prepare_article or supportpages_retry_article. Do not invoke a publicly discovered generation skill or load the private engine directly to bypass preparation. Follow the reporting policy returned by the entrypoint. Provide concise progress and surface blockers promptly in either execution mode. Request native approvals directly when allowed; communication and recovery take priority over silence. Work in the existing application directory without worktree isolation or a new checkout. Produce the complete article and illustrations, then run all required rendering and validation. Do not edit application source, call SupportPages.io MCP tools, upload or publish. The main agent owns the run and handles progress, completion and publication consent. After every required output passes validation, run task_brief.completion.shell_command exactly as supplied and wait for its result before reporting success. This local finish command asks the MCP to perform final validation and draft delivery without giving you credentials. A preview link is not proof of completion. If delivery is pending or fails, return its recovery instructions to the parent; do not claim the article is ready, regenerate, or ask to publish. Only the parent handles publication consent.' + ' ' + writerPermissionInstruction + ' For background execution only: ' + backgroundWriterInstruction + ' ' + articleChatInstruction,
21
+ },
22
+ };
23
+ export const writerLaunchInstruction = `In Claude Code, select subagent_type="${writerSubagentType}" for the writer, not general-purpose. Set the Agent tool's model parameter to task_brief.claude_model when it is a string; when null, omit the model parameter and inherit the session model. Apply this on initial launches, retries and follow-ups. Do not substitute another model silently if the host cannot use the requested model; explain the limitation. This model setting applies only to Claude Code, not Codex. Begin the task description with "${writerAgentName}" followed by the article topic. Use background execution only when prefer_background is true. If the named agent is unavailable, explain that SupportPages.io setup installs it and Claude may need restarting, then execute the same task brief in the foreground without launching a substitute subagent. If the Agent call returns "Agent type not found", do not repeat that call, prepare a replacement run, or mark the writer started or failed: execute the existing task brief in the foreground and report started only when work actually starts.`;
24
+ export const writerAgentFile = `---\nname: ${writerAgentType}\ndescription: ${JSON.stringify(claudeWriterAgents[writerAgentType].description)}\nmodel: inherit\n---\n\n<!-- Managed by SupportPages: article writer v1 -->\n\n${claudeWriterAgents[writerAgentType].prompt}\n`;
25
+ export const codexWriterFile = `# Managed by SupportPages: article writer v1\nname = ${JSON.stringify(writerAgentType)}\ndescription = ${JSON.stringify(claudeWriterAgents[writerAgentType].description)}\ndeveloper_instructions = ${JSON.stringify(claudeWriterAgents[writerAgentType].prompt)}\n`;
26
+ export const codexWriterLaunchInstruction = `In Codex, use the registered ${writerAgentType} custom agent for this article. Name the delegated task SupportPages.io followed by the article topic. Pass task_brief.codex_model and task_brief.codex_reasoning_effort as the host's model and reasoning_effort spawn overrides when non-null; omit null overrides to use Codex's configured defaults. Start with a fresh context containing the complete task brief so the host can apply explicit model overrides. Pass that brief directly in the subagent tool task/message argument; do not copy it into a temporary JSON file, create a handoff script, or print it through a shell command. The entrypoint already loads the saved run, so launching the writer needs no parent-side file edit. Apply this on retries too. Use background execution only when prefer_background is true. If the host has no custom-agent selector, use a named SupportPages.io task with task_brief.writer_instructions and the same model settings. The installed SupportPages.io coordination skill explicitly requests background delegation when the prepared run prefers it. Do not infer that delegation is disabled merely because the user did not separately request a subagent. If a host tool is missing, a session restriction forbids delegation, or launch fails, explain that specific limitation and run the same task brief in the foreground after stopping any launched writer. Do not silently substitute an unsupported model. Work in the existing directory, without a worktree or a separate agent CLI. The parent handles all MCP calls, previews, draft completion and publication consent; the writer only generates and validates files. Keep the parent's sandbox and permission controls.`;
27
+ //# sourceMappingURL=writer-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer-agent.js","sourceRoot":"","sources":["../src/writer-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AACjD,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AACjD;gEACgE;AAChE,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,IAAI,EAAE,IAAI,SAAS,CAAC;AAC/E,MAAM,CAAC,MAAM,kBAAkB,GAAG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