@bluelibs/runner-dev 6.2.0 → 6.4.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 (162) hide show
  1. package/README.md +131 -12
  2. package/dist/cli/generators/initUtils.js +1 -1
  3. package/dist/cli/generators/initUtils.js.map +1 -1
  4. package/dist/cli/generators/scaffold/templates/README.md.js +17 -4
  5. package/dist/cli/generators/scaffold/templates/README.md.js.map +1 -1
  6. package/dist/cli/generators/scaffold/templates/index.d.ts +2 -1
  7. package/dist/cli/generators/scaffold/templates/index.js +5 -3
  8. package/dist/cli/generators/scaffold/templates/index.js.map +1 -1
  9. package/dist/cli/generators/scaffold/templates/package.json.d.ts +7 -2
  10. package/dist/cli/generators/scaffold/templates/package.json.js +7 -2
  11. package/dist/cli/generators/scaffold/templates/package.json.js.map +1 -1
  12. package/dist/cli/generators/scaffold/templates/src/app.test.ts.d.ts +1 -0
  13. package/dist/cli/generators/scaffold/templates/src/app.test.ts.js +29 -0
  14. package/dist/cli/generators/scaffold/templates/src/app.test.ts.js.map +1 -0
  15. package/dist/cli/generators/scaffold/templates/src/app.ts.d.ts +1 -0
  16. package/dist/cli/generators/scaffold/templates/src/app.ts.js +15 -0
  17. package/dist/cli/generators/scaffold/templates/src/app.ts.js.map +1 -0
  18. package/dist/cli/generators/scaffold/templates/src/main.ts.js +3 -10
  19. package/dist/cli/generators/scaffold/templates/src/main.ts.js.map +1 -1
  20. package/dist/cli/generators/scaffold/templates/tsconfig.json.d.ts +4 -2
  21. package/dist/cli/generators/scaffold/templates/tsconfig.json.js +4 -2
  22. package/dist/cli/generators/scaffold/templates/tsconfig.json.js.map +1 -1
  23. package/dist/cli/generators/scaffold.js +2 -1
  24. package/dist/cli/generators/scaffold.js.map +1 -1
  25. package/dist/cli.js +0 -0
  26. package/dist/docs/packageDocs.d.ts +16 -0
  27. package/dist/docs/packageDocs.js +107 -0
  28. package/dist/docs/packageDocs.js.map +1 -0
  29. package/dist/exportDocs.d.ts +10 -0
  30. package/dist/exportDocs.js +98 -0
  31. package/dist/exportDocs.js.map +1 -0
  32. package/dist/generated/resolvers-types.d.ts +126 -178
  33. package/dist/index.d.ts +4 -1
  34. package/dist/index.js +3 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/mcp/env.d.ts +5 -0
  37. package/dist/mcp/env.js +30 -1
  38. package/dist/mcp/env.js.map +1 -1
  39. package/dist/mcp/help.d.ts +8 -1
  40. package/dist/mcp/help.js +30 -4
  41. package/dist/mcp/help.js.map +1 -1
  42. package/dist/mcp/http.js +10 -0
  43. package/dist/mcp/http.js.map +1 -1
  44. package/dist/mcp/projectOverview.js +13 -4
  45. package/dist/mcp/projectOverview.js.map +1 -1
  46. package/dist/mcp/snapshot.d.ts +22 -0
  47. package/dist/mcp/snapshot.js +344 -0
  48. package/dist/mcp/snapshot.js.map +1 -0
  49. package/dist/mcp/tools/graphql.mutation.js +4 -1
  50. package/dist/mcp/tools/graphql.mutation.js.map +1 -1
  51. package/dist/mcp/tools/graphql.ping.js +1 -1
  52. package/dist/mcp/tools/graphql.ping.js.map +1 -1
  53. package/dist/mcp/tools/graphql.query.js +1 -1
  54. package/dist/mcp/tools/graphql.query.js.map +1 -1
  55. package/dist/mcp/tools/help.read.js +7 -5
  56. package/dist/mcp/tools/help.read.js.map +1 -1
  57. package/dist/mcp/tools/help.runner.js +3 -1
  58. package/dist/mcp/tools/help.runner.js.map +1 -1
  59. package/dist/mcp/tools/help.runnerDev.js +4 -4
  60. package/dist/mcp/tools/help.runnerDev.js.map +1 -1
  61. package/dist/mcp.js +4 -9
  62. package/dist/mcp.js.map +1 -1
  63. package/dist/resources/docsPayload.d.ts +33 -0
  64. package/dist/resources/docsPayload.js +174 -0
  65. package/dist/resources/docsPayload.js.map +1 -0
  66. package/dist/resources/docsUiAssets.d.ts +27 -0
  67. package/dist/resources/docsUiAssets.js +150 -0
  68. package/dist/resources/docsUiAssets.js.map +1 -0
  69. package/dist/resources/graphql-accumulator.resource.d.ts +1 -0
  70. package/dist/resources/graphql-accumulator.resource.js +30 -26
  71. package/dist/resources/graphql-accumulator.resource.js.map +1 -1
  72. package/dist/resources/live.resource.d.ts +0 -2
  73. package/dist/resources/live.resource.js +1 -5
  74. package/dist/resources/live.resource.js.map +1 -1
  75. package/dist/resources/models/Introspector.d.ts +17 -0
  76. package/dist/resources/models/Introspector.js +61 -28
  77. package/dist/resources/models/Introspector.js.map +1 -1
  78. package/dist/resources/models/durable.runtime.d.ts +1 -5
  79. package/dist/resources/models/durable.runtime.js +0 -33
  80. package/dist/resources/models/durable.runtime.js.map +1 -1
  81. package/dist/resources/models/durable.tools.d.ts +10 -0
  82. package/dist/resources/models/durable.tools.js +21 -0
  83. package/dist/resources/models/durable.tools.js.map +1 -1
  84. package/dist/resources/models/initializeFromStore.js +5 -5
  85. package/dist/resources/models/initializeFromStore.js.map +1 -1
  86. package/dist/resources/models/initializeFromStore.utils.d.ts +2 -2
  87. package/dist/resources/models/initializeFromStore.utils.js +399 -68
  88. package/dist/resources/models/initializeFromStore.utils.js.map +1 -1
  89. package/dist/resources/models/introspector.tools.js +88 -4
  90. package/dist/resources/models/introspector.tools.js.map +1 -1
  91. package/dist/resources/routeHandlers/createDocsServeHandler.js +13 -37
  92. package/dist/resources/routeHandlers/createDocsServeHandler.js.map +1 -1
  93. package/dist/resources/routeHandlers/getDocsData.d.ts +1 -6
  94. package/dist/resources/routeHandlers/getDocsData.js +10 -168
  95. package/dist/resources/routeHandlers/getDocsData.js.map +1 -1
  96. package/dist/resources/server.resource.js +0 -1
  97. package/dist/resources/server.resource.js.map +1 -1
  98. package/dist/resources/ui.static.js +4 -9
  99. package/dist/resources/ui.static.js.map +1 -1
  100. package/dist/schema/model.d.ts +21 -13
  101. package/dist/schema/model.js +14 -0
  102. package/dist/schema/model.js.map +1 -1
  103. package/dist/schema/query.js +3 -3
  104. package/dist/schema/query.js.map +1 -1
  105. package/dist/schema/types/AllType.js +2 -21
  106. package/dist/schema/types/AllType.js.map +1 -1
  107. package/dist/schema/types/DurableFlowTypes.d.ts +2 -0
  108. package/dist/schema/types/DurableFlowTypes.js +51 -1
  109. package/dist/schema/types/DurableFlowTypes.js.map +1 -1
  110. package/dist/schema/types/ErrorType.js +1 -3
  111. package/dist/schema/types/ErrorType.js.map +1 -1
  112. package/dist/schema/types/EventType.js +6 -19
  113. package/dist/schema/types/EventType.js.map +1 -1
  114. package/dist/schema/types/HookType.js +4 -16
  115. package/dist/schema/types/HookType.js.map +1 -1
  116. package/dist/schema/types/ResourceType.js +60 -23
  117. package/dist/schema/types/ResourceType.js.map +1 -1
  118. package/dist/schema/types/TaskLikeCommon.js +2 -2
  119. package/dist/schema/types/TaskLikeCommon.js.map +1 -1
  120. package/dist/schema/types/TaskType.js +12 -31
  121. package/dist/schema/types/TaskType.js.map +1 -1
  122. package/dist/schema/types/index.d.ts +0 -1
  123. package/dist/schema/types/index.js +1 -10
  124. package/dist/schema/types/index.js.map +1 -1
  125. package/dist/schema/types/middleware/UsageTypes.d.ts +1 -0
  126. package/dist/schema/types/middleware/UsageTypes.js +16 -5
  127. package/dist/schema/types/middleware/UsageTypes.js.map +1 -1
  128. package/dist/schema/types/middleware/common.js +2 -2
  129. package/dist/schema/types/middleware/common.js.map +1 -1
  130. package/dist/ui/.vite/manifest.json +2 -2
  131. package/dist/ui/assets/docs-DaF8dCiE.css +1 -0
  132. package/dist/ui/assets/docs-DgcoUGlF.js +261 -0
  133. package/dist/ui/assets/docs-DgcoUGlF.js.map +1 -0
  134. package/dist/ui/docs/favicon.ico +0 -0
  135. package/dist/utils/lane-resources.d.ts +69 -0
  136. package/dist/utils/lane-resources.js +145 -0
  137. package/dist/utils/lane-resources.js.map +1 -1
  138. package/dist/utils/runner-namespace.d.ts +1 -0
  139. package/dist/utils/runner-namespace.js +9 -0
  140. package/dist/utils/runner-namespace.js.map +1 -0
  141. package/dist/utils/schemaFormat.d.ts +6 -0
  142. package/dist/utils/schemaFormat.js +244 -0
  143. package/dist/utils/schemaFormat.js.map +1 -0
  144. package/dist/utils/system-namespace.d.ts +1 -0
  145. package/dist/utils/system-namespace.js +9 -0
  146. package/dist/utils/system-namespace.js.map +1 -0
  147. package/dist/version.d.ts +1 -1
  148. package/dist/version.js +1 -1
  149. package/package.json +20 -4
  150. package/readmes/API_REFERENCE.md +352 -0
  151. package/readmes/COMPACT_GUIDE.md +254 -0
  152. package/skills/core/SKILL.md +27 -0
  153. package/skills/core/references/readmes/API_REFERENCE.md +352 -0
  154. package/skills/core/references/readmes/COMPACT_GUIDE.md +254 -0
  155. package/AI.md +0 -630
  156. package/dist/ui/assets/docs-CWJO6emS.css +0 -1
  157. package/dist/ui/assets/docs-Zej7hPlV.js +0 -302
  158. package/dist/ui/assets/docs-Zej7hPlV.js.map +0 -1
  159. package/readmes/runner-AI.md +0 -917
  160. package/readmes/runner-durable-workflows.md +0 -2247
  161. package/readmes/runner-full-guide.md +0 -6010
  162. package/readmes/runner-remote-lanes.md +0 -910
package/AI.md DELETED
@@ -1,630 +0,0 @@
1
- # Runner-Dev AI Assistant Guide
2
-
3
- This document provides AI assistants with comprehensive guidance on using Runner-Dev's introspection and development tools.
4
-
5
- ## What is Runner-Dev?
6
-
7
- Runner-Dev is a powerful development toolkit for applications built with the **@bluelibs/runner** framework. It provides:
8
-
9
- - **Live Introspection**: Query your running application's architecture
10
- - **Hot-Swapping**: Modify tasks at runtime with TypeScript/JavaScript
11
- - **Real-time Telemetry**: Monitor logs, events, errors, and performance
12
- - **GraphQL API**: Comprehensive query interface for all system data
13
- - **MCP Integration**: AI-native development environment
14
- - **Tags (first-class)**: Discover Tag objects and reverse usage via GraphQL (`tags`, `tag(id)`).
15
- - **Documentation UI Overviews**: Sortable and searchable overview tables with a `Used By` counter column for faster cross-element inspection.
16
- - **Visibility Awareness**: Every element exposes `isPrivate` (based on Runner `isolate()` boundaries), and resources expose `isolation`.
17
- - **Subtree Governance Awareness**: Resources expose normalized `subtree` policy summaries (middleware and validator counts per branch).
18
- - **Lifecycle Awareness**: Resources expose `cooldown` support and run options expose `lifecycleMode`, `disposeBudgetMs`, `disposeDrainBudgetMs`.
19
- - **Lane Awareness**: Events expose optional `eventLane` summaries (`globals.tags.eventLane`) and both tasks and events expose optional `rpcLane` summaries (`globals.tags.rpcLane`).
20
- - **Isolation Wildcard Explorer**: Wildcard isolation rules can be clicked to inspect all matching resources in a searchable modal list.
21
- - **Tag Handlers**: Tag views separate direct tag usages from handler elements that depend on the tag id.
22
- - **Task Interceptor Introspection**: Tasks expose `interceptorCount` and `hasInterceptors` for runtime `task.intercept(...)` registrations.
23
- - **Schema Export Compatibility**: Schema fields prefer `toJSONSchema()` exporters (including matcher-normalized schemas), with `zod` conversion as compatibility fallback.
24
-
25
- ## Runner 6.0 Migration Notes
26
-
27
- | Before | After (hard switch) |
28
- | --------------------- | --------------------------------------------------------- |
29
- | `Resource.exports` | `Resource.isolation { deny, only, exports, exportsMode }` |
30
- | `Middleware.global` | `Middleware.autoApply { enabled, scope, hasPredicate }` |
31
- | `Tag.middlewares` | `Tag.taskMiddlewares` + `Tag.resourceMiddlewares` |
32
- | N/A | `Tag.errors`, `Tag.targets` |
33
- | `RunOptions.initMode` | `RunOptions.lifecycleMode` (+ disposal budgets) |
34
- | `Resource.tunnelInfo` | Removed (hard switch to Event Lane + RPC Lane surfaces) |
35
-
36
- ## Runner 6.1 Migration Notes
37
-
38
- - Temporal middleware now supports per-key partitioning through `keyBuilder(taskId, input)` on `rateLimit`, `debounce`, and `throttle`.
39
- - User resources are no longer transparent:
40
- - root resources can register tasks/resources/middleware directly and be passed to `run(...)`
41
- - canonical runtime ids retain each user resource segment
42
- - `runtime-framework-root` is reserved for internal Runner use
43
- - `resource.subtree(...)` may now receive a policy array; runner-dev merges those policies into one summarized subtree view.
44
- - `gateway: true` has been removed from user resources, so any references that skipped a user resource segment need to be updated.
45
- - Advanced Node integrations should now use `runner.node.rpcLanes` for the internal RPC lanes resource id.
46
-
47
- ## Runner 6.2 Migration Notes
48
-
49
- - Built-in async contexts now include `asyncContexts.tenant`, and `IAsyncContext` officially exposes safe probe helpers via `tryUse()` and `has()`.
50
- - Built-in task middleware such as `cache`, `concurrency`, and `rateLimit` can partition internal state per tenant via `tenantScope`.
51
- - Lazy resource initialization now fails fast once shutdown begins; runner-dev will surface the new typed shutdown errors through normal error introspection.
52
- - Subtree middleware conflicts now fail fast inside Runner instead of remaining a post-compose diagnostic concern.
53
- - The internal framework root is now described as the synthetic framework root, with clearer internal `runner` and `system` namespace resources.
54
-
55
- ## Available GraphQL Queries
56
-
57
- ### System Architecture Queries
58
-
59
- ```graphql
60
- # Get all elements (tasks, resources, events, middleware, hooks)
61
- query SystemOverview {
62
- all {
63
- id
64
- isPrivate
65
- meta {
66
- title
67
- description
68
- }
69
- filePath
70
- }
71
- runOptions {
72
- mode
73
- debug
74
- debugMode
75
- logsEnabled
76
- logsPrintThreshold
77
- logsPrintStrategy
78
- logsBuffer
79
- errorBoundary
80
- shutdownHooks
81
- dryRun
82
- lazy
83
- lifecycleMode
84
- runtimeEventCycleDetection
85
- hasOnUnhandledError
86
- rootId
87
- }
88
- }
89
-
90
- # Get specific element types
91
- query Architecture {
92
- tasks {
93
- id
94
- isPrivate
95
- interceptorCount
96
- hasInterceptors
97
- meta {
98
- title
99
- description
100
- }
101
- tags {
102
- id
103
- }
104
- dependsOn
105
- emits
106
- }
107
- resources {
108
- id
109
- isPrivate
110
- isolation {
111
- deny
112
- only
113
- exports
114
- exportsMode
115
- }
116
- meta {
117
- title
118
- description
119
- }
120
- tags {
121
- id
122
- }
123
- dependsOn
124
- registers
125
- overrides
126
- usedBy
127
- }
128
- events {
129
- id
130
- tags {
131
- id
132
- }
133
- emittedBy
134
- listenedToBy
135
- }
136
- middlewares {
137
- id
138
- meta {
139
- title
140
- description
141
- }
142
- tags {
143
- id
144
- }
145
- usedByTasks
146
- }
147
- hooks {
148
- id
149
- meta {
150
- title
151
- description
152
- }
153
- tags {
154
- id
155
- }
156
- event
157
- }
158
- }
159
- ```
160
-
161
- ### Live Telemetry Queries
162
-
163
- ```graphql
164
- # Real-time system monitoring
165
- query LiveTelemetry {
166
- live {
167
- memory {
168
- heapUsed
169
- heapTotal
170
- rss
171
- }
172
- cpu {
173
- usage
174
- loadAverage
175
- }
176
- eventLoop {
177
- lag
178
- }
179
- gc {
180
- collections
181
- duration
182
- }
183
-
184
- # Recent activity (use 'last' parameter to limit)
185
- logs(last: 10) {
186
- timestampMs
187
- level
188
- message
189
- correlationId
190
- }
191
- emissions(last: 10) {
192
- timestampMs
193
- eventId
194
- emitterId
195
- correlationId
196
- }
197
- errors(last: 10) {
198
- timestampMs
199
- sourceKind
200
- message
201
- correlationId
202
- }
203
- runs(last: 10) {
204
- timestampMs
205
- nodeId
206
- nodeKind
207
- durationMs
208
- ok
209
- correlationId
210
- }
211
- }
212
- }
213
- ```
214
-
215
- ### SSE Live Streaming
216
-
217
- Server-Sent Events endpoint at `GET /live/stream` for near-instant push instead of polling:
218
-
219
- - **`telemetry`** event: `{ logs, emissions, errors, runs }` pushed ~100ms after each record (debounced)
220
- - **`health`** event: `{ memory, cpu, eventLoop, gc }` every 2s
221
- - Heartbeat comment every 15s to keep proxies alive
222
- - `Live.onRecord(callback)` fires synchronously on each `record*` call; returns an unsubscribe function
223
- - The built-in Live Panel auto-uses SSE and falls back to configurable-interval polling (500ms–10s)
224
-
225
- ### Correlation ID Trace View
226
-
227
- The Live Panel includes a built-in **Trace View** — a unified timeline showing every log, event emission, error, and task run sharing a single `correlationId`, ordered chronologically. Click any correlationId badge (shown on logs, events, errors, and runs) to open the trace modal. This provides an in-process "distributed tracing" experience (like Jaeger).
228
-
229
- ### Unified Modal System
230
-
231
- All UI modals (CodeModal, ExecuteModal, TraceView, RecentLogs, OverviewStatsPanel) are built on a shared `BaseModal` primitive (`src/ui/src/components/Documentation/components/modals/`). It provides:
232
-
233
- - **Stacking**: A `ModalStackContext` tracks open modals and assigns ascending z-indexes (base 10 000 + 10 per layer). Global Escape closes the topmost modal first.
234
- - **Consistent UX**: Portal to `document.body`, backdrop blur, scroll lock, focus trap, slide-up animation, ARIA `role="dialog"`.
235
- - **Sizes**: `sm | md | lg | xl | fullscreen` with responsive fallback to fullscreen on small viewports.
236
-
237
- ### Diagnostics & Health
238
-
239
- ```graphql
240
- # System diagnostics and issues
241
- query SystemHealth {
242
- diagnostics {
243
- severity
244
- code
245
- message
246
- nodeId
247
- nodeKind
248
- }
249
- }
250
- ```
251
-
252
- ## Available GraphQL Mutations
253
-
254
- ### Hot-Swapping Tasks
255
-
256
- ```graphql
257
- # Swap a task's implementation at runtime
258
- mutation SwapTask($taskId: ID!, $runCode: String!) {
259
- swapTask(taskId: $taskId, runCode: $runCode) {
260
- success
261
- error
262
- taskId
263
- }
264
- }
265
-
266
- # Restore original implementation
267
- mutation UnswapTask($taskId: ID!) {
268
- unswapTask(taskId: $taskId) {
269
- success
270
- error
271
- taskId
272
- }
273
- }
274
-
275
- # Restore all tasks
276
- mutation UnswapAllTasks {
277
- unswapAllTasks {
278
- success
279
- error
280
- taskId
281
- }
282
- }
283
- ```
284
-
285
- ### Task Invocation
286
-
287
- ```graphql
288
- # Invoke a task remotely
289
- mutation InvokeTask(
290
- $taskId: ID!
291
- $inputJson: String
292
- $pure: Boolean
293
- $evalInput: Boolean
294
- ) {
295
- invokeTask(
296
- taskId: $taskId
297
- inputJson: $inputJson
298
- pure: $pure # bypass middleware
299
- evalInput: $evalInput # evaluate input as JavaScript
300
- ) {
301
- success
302
- error
303
- result
304
- executionTimeMs
305
- invocationId
306
- }
307
- }
308
- ```
309
-
310
- ### Code Evaluation
311
-
312
- ```graphql
313
- # Execute arbitrary code on the server (DEV ONLY)
314
- mutation EvalCode($code: String!, $inputJson: String, $evalInput: Boolean) {
315
- eval(code: $code, inputJson: $inputJson, evalInput: $evalInput) {
316
- success
317
- error
318
- result
319
- executionTimeMs
320
- invocationId
321
- }
322
- }
323
- ```
324
-
325
- ## MCP Tools Available
326
-
327
- - `graphql.query` - Execute read-only GraphQL queries
328
- - `graphql.mutation` - Execute GraphQL mutations (if ALLOW_MUTATIONS=true)
329
- - `graphql.introspect` - Get full schema introspection
330
- - `graphql.ping` - Test connectivity
331
- - `project.overview` - Generate dynamic project overview aggregated from the API
332
-
333
- ## Direct CLI Usage
334
-
335
- Beyond MCP, Runner-Dev offers a powerful standalone CLI for direct interaction from your terminal. This is ideal for scripting, quick checks, or when not operating within an MCP-enabled AI assistant.
336
-
337
- ### Prerequisites
338
-
339
- - Your app must be running with the Dev server enabled (for remote mode).
340
- - The `@bluelibs/runner-dev` package should be installed.
341
-
342
- ### Create a New Project
343
-
344
- You can scaffold a new Runner project directly from the CLI.
345
-
346
- ```bash
347
- # Create a new Runner project
348
- npx @bluelibs/runner-dev new <project-name>
349
-
350
- # Example
351
- npx @bluelibs/runner-dev new my-awesome-app
352
- ```
353
-
354
- This command creates a new Runner project with a complete TypeScript setup, `tsx watch` for development, Vitest for testing, and all necessary dependencies.
355
-
356
- Key flags for `new`:
357
-
358
- - `--install`: Install dependencies after scaffolding.
359
- - `--run-tests`: Run the generated test suite after installation.
360
- - `--run`: Start the dev server after installation.
361
-
362
- ### Common Commands
363
-
364
- All commands can be prefixed with environment variables like `ENDPOINT` and `HEADERS`.
365
-
366
- **Ping the server:**
367
-
368
- ```bash
369
- ENDPOINT=http://localhost:1337/graphql npx @bluelibs/runner-dev ping
370
- ```
371
-
372
- **Execute a GraphQL query (Remote Mode):**
373
-
374
- ```bash
375
- # Simple query
376
- ENDPOINT=http://localhost:1337/graphql npx @bluelibs/runner-dev query 'query { tasks { id } }'
377
-
378
- # Query with variables and pretty formatting
379
- ENDPOINT=http://localhost:1337/graphql \
380
- npx @bluelibs/runner-dev query \
381
- 'query Q($ns: ID){ tasks(idIncludes: $ns) { id } }' \
382
- --variables '{"ns":"task."}' \
383
- --format pretty
384
- ```
385
-
386
- **Execute a GraphQL query (Dry-Run Mode):**
387
-
388
- Run queries against a TypeScript entry file without needing a running server.
389
-
390
- ```bash
391
- # Using a TS entry file default export
392
- npx @bluelibs/runner-dev query 'query { tasks { id } }' \
393
- --entry-file ./src/main.ts
394
-
395
- # Using a named export (e.g., exported as `app`)
396
- npx @bluelibs/runner-dev query 'query { tasks { id } }' \
397
- --entry-file ./src/main.ts --export app
398
- ```
399
-
400
- Selection logic:
401
-
402
- - If `--entry-file` is provided, dry-run mode is used (no server; requires ts-node).
403
- - Otherwise, the CLI uses a remote endpoint via `--endpoint` or `ENDPOINT/GRAPHQL_ENDPOINT`.
404
- - If neither is provided, the command errors.
405
-
406
- **Generate a project overview:**
407
-
408
- ```bash
409
- ENDPOINT=http://localhost:1337/graphql npx @bluelibs/runner-dev overview --details 10
410
- ```
411
-
412
- **Fetch GraphQL schema:**
413
-
414
- ```bash
415
- # As SDL
416
- ENDPOINT=http://localhost:1337/graphql npx @bluelibs/runner-dev schema sdl
417
-
418
- # As JSON
419
- ENDPOINT=http://localhost:1337/graphql npx @bluelibs/runner-dev schema json
420
- ```
421
-
422
- ### Key Flags
423
-
424
- - `--endpoint <url>`: GraphQL endpoint URL for remote mode.
425
- - `--headers '<json>'`: JSON for extra headers.
426
- - `--variables '<json>'`: JSON variables for a query.
427
- - `--format data|json|pretty`: Output format.
428
- - `--namespace <str>`: A filter to inject `idIncludes` on top-level fields.
429
- - `--entry-file <path>`: TypeScript entry file for dry-run mode (no server).
430
- - `--export <name>`: Named export to use from the entry file (default export is preferred).
431
- - `--operation <name>`: Operation name for documents with multiple operations.
432
- - `--raw`: Print the full GraphQL envelope including errors.
433
-
434
- This direct CLI access provides a powerful way for AI assistants with shell access to script complex interactions, perform detailed introspection, and validate application state without relying on MCP tools.
435
-
436
- ## Common Use Cases
437
-
438
- ### 1. Understanding System Architecture
439
-
440
- ```graphql
441
- query UnderstandSystem {
442
- tasks {
443
- id
444
- meta {
445
- title
446
- description
447
- }
448
- dependsOn
449
- emits
450
- filePath
451
- }
452
- resources {
453
- id
454
- meta {
455
- title
456
- description
457
- }
458
- registers
459
- filePath
460
- }
461
- }
462
- ```
463
-
464
- ### 2. Debugging Issues
465
-
466
- ```graphql
467
- query DebuggingInfo {
468
- diagnostics {
469
- severity
470
- code
471
- message
472
- nodeId
473
- }
474
- live {
475
- errors(last: 20) {
476
- timestampMs
477
- sourceKind
478
- message
479
- stack
480
- correlationId
481
- }
482
- }
483
- }
484
- ```
485
-
486
- ### 3. Performance Monitoring
487
-
488
- ```graphql
489
- query Performance {
490
- live {
491
- memory {
492
- heapUsed
493
- heapTotal
494
- rss
495
- }
496
- cpu {
497
- usage
498
- loadAverage
499
- }
500
- eventLoop {
501
- lag
502
- }
503
- runs(last: 50, filter: { ok: false }) {
504
- nodeId
505
- durationMs
506
- error
507
- timestampMs
508
- }
509
- }
510
- }
511
- ```
512
-
513
- ### 4. Hot Development Workflow
514
-
515
- ```graphql
516
- # 1. Check current swapped tasks
517
- query CheckSwapped {
518
- swappedTasks {
519
- taskId
520
- swappedAt
521
- }
522
- }
523
-
524
- # 2. Swap a task
525
- mutation DevSwap {
526
- swapTask(
527
- taskId: "my.task"
528
- runCode: "async function run(input, deps) { return { message: 'Updated!' }; }"
529
- ) {
530
- success
531
- error
532
- }
533
- }
534
-
535
- # 3. Test the task
536
- mutation TestTask {
537
- invokeTask(taskId: "my.task", inputJson: "{\"test\": true}", pure: true) {
538
- success
539
- result
540
- executionTimeMs
541
- }
542
- }
543
- ```
544
-
545
- ### 5. Durable Workflow Introspection (Node)
546
-
547
- Durable workflows are regular Runner tasks tagged with `durableWorkflowTag` from `@bluelibs/runner/node`.
548
- Runner-Dev exposes durable metadata directly on tasks:
549
-
550
- - `isDurable`
551
- - `durableResource`
552
- - `flowShape` (checkpoint structure from `durable.describe(...)`)
553
-
554
- ```graphql
555
- query DurableTasks {
556
- tasks {
557
- id
558
- isDurable
559
- durableResource {
560
- id
561
- }
562
- flowShape {
563
- nodes {
564
- __typename
565
- }
566
- }
567
- }
568
- }
569
- ```
570
-
571
- Minimal workflow setup pattern:
572
-
573
- ```ts
574
- import { r } from "@bluelibs/runner";
575
- import {
576
- durableWorkflowTag,
577
- memoryDurableResource,
578
- } from "@bluelibs/runner/node";
579
-
580
- const durable = memoryDurableResource.fork("app.durable");
581
- const durableRegistration = durable.with({});
582
-
583
- const workflow = r
584
- .task("app.tasks.orderWorkflow")
585
- .dependencies({ durable })
586
- .tags([durableWorkflowTag])
587
- .run(async (input, { durable }) => {
588
- const ctx = durable.use();
589
- await ctx.step("validate", async () => ({ ok: true }));
590
- await ctx.sleep(250, { stepId: "cooldown" });
591
- return { ok: true };
592
- })
593
- .build();
594
-
595
- const app = r.resource("app").register([durableRegistration, workflow]).build();
596
- ```
597
-
598
- ## Best Practices for AI Assistants
599
-
600
- ### Documentation & Information Gathering
601
-
602
- 1. **Use Array-Based Heading Filters**: Get comprehensive context efficiently with `headingIncludes: ["topic1", "topic2", "topic3"]`
603
- 2. **Start with TOC**: Use `toc: true` to understand document structure before diving deep
604
- 3. **Choose Right Documentation Tool**:
605
- - `help.runner` for framework concepts
606
- - `help.runner-dev` for application-specific features
607
- - `help.read` for custom package docs
608
- 4. **Combine Related Topics**: Instead of multiple calls, use arrays like `["tasks", "resources", "events"]`
609
-
610
- ### System Operations
611
-
612
- 5. **Start with Overview**: Use `project.overview` to understand the system
613
- 6. **Use Correlation IDs**: Track related operations across logs/runs/errors
614
- 7. **Limit Results**: Always use `last` parameter for live queries to avoid overwhelming responses
615
- 8. **Check Diagnostics**: Look for warnings/errors that might indicate issues
616
- 9. **Use Markdown Format**: Request `format: "markdown"` for better readability
617
- 10. **Hot-Swap Safely**: Test swapped code with `pure: true` before production use
618
-
619
- ## Environment Variables
620
-
621
- - `ENDPOINT` - GraphQL endpoint (default: http://localhost:1337/graphql)
622
- - `ALLOW_MUTATIONS` - Enable mutations in MCP (default: false)
623
- - `RUNNER_DEV_EVAL` - Enable eval mutation (default: false, DEV ONLY)
624
-
625
- ## Security Notes
626
-
627
- - Mutations are disabled by default in production
628
- - Eval is extremely dangerous and should only be used in development
629
- - Hot-swapping affects the running system - use with caution
630
- - All operations are logged with correlation IDs for traceability