@voiden/runner 0.1.0-beta.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 (66) hide show
  1. package/README.md +748 -0
  2. package/dist/blockSchemaRegistry.d.ts +49 -0
  3. package/dist/blockSchemaRegistry.d.ts.map +1 -0
  4. package/dist/blockSchemaRegistry.js +68 -0
  5. package/dist/blockSchemaRegistry.js.map +1 -0
  6. package/dist/cliElectron.d.ts +55 -0
  7. package/dist/cliElectron.d.ts.map +1 -0
  8. package/dist/cliElectron.js +120 -0
  9. package/dist/cliElectron.js.map +1 -0
  10. package/dist/headlessContext.d.ts +18 -0
  11. package/dist/headlessContext.d.ts.map +1 -0
  12. package/dist/headlessContext.js +85 -0
  13. package/dist/headlessContext.js.map +1 -0
  14. package/dist/index.d.ts +3 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +945 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/parser.d.ts +24 -0
  19. package/dist/parser.d.ts.map +1 -0
  20. package/dist/parser.js +87 -0
  21. package/dist/parser.js.map +1 -0
  22. package/dist/parserRegistry.d.ts +17 -0
  23. package/dist/parserRegistry.d.ts.map +1 -0
  24. package/dist/parserRegistry.js +27 -0
  25. package/dist/parserRegistry.js.map +1 -0
  26. package/dist/plugins/community.d.ts +42 -0
  27. package/dist/plugins/community.d.ts.map +1 -0
  28. package/dist/plugins/community.js +105 -0
  29. package/dist/plugins/community.js.map +1 -0
  30. package/dist/plugins/loader.d.ts +17 -0
  31. package/dist/plugins/loader.d.ts.map +1 -0
  32. package/dist/plugins/loader.js +120 -0
  33. package/dist/plugins/loader.js.map +1 -0
  34. package/dist/plugins/registry.d.ts +30 -0
  35. package/dist/plugins/registry.d.ts.map +1 -0
  36. package/dist/plugins/registry.js +52 -0
  37. package/dist/plugins/registry.js.map +1 -0
  38. package/dist/plugins/store.d.ts +19 -0
  39. package/dist/plugins/store.d.ts.map +1 -0
  40. package/dist/plugins/store.js +68 -0
  41. package/dist/plugins/store.js.map +1 -0
  42. package/dist/report/csv.d.ts +6 -0
  43. package/dist/report/csv.d.ts.map +1 -0
  44. package/dist/report/csv.js +71 -0
  45. package/dist/report/csv.js.map +1 -0
  46. package/dist/report/mail.d.ts +17 -0
  47. package/dist/report/mail.d.ts.map +1 -0
  48. package/dist/report/mail.js +84 -0
  49. package/dist/report/mail.js.map +1 -0
  50. package/dist/runner.d.ts +41 -0
  51. package/dist/runner.d.ts.map +1 -0
  52. package/dist/runner.js +193 -0
  53. package/dist/runner.js.map +1 -0
  54. package/dist/runtimeVars.d.ts +55 -0
  55. package/dist/runtimeVars.d.ts.map +1 -0
  56. package/dist/runtimeVars.js +248 -0
  57. package/dist/runtimeVars.js.map +1 -0
  58. package/dist/session.d.ts +10 -0
  59. package/dist/session.d.ts.map +1 -0
  60. package/dist/session.js +32 -0
  61. package/dist/session.js.map +1 -0
  62. package/dist/types.d.ts +45 -0
  63. package/dist/types.d.ts.map +1 -0
  64. package/dist/types.js +3 -0
  65. package/dist/types.js.map +1 -0
  66. package/package.json +43 -0
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Block Schema Registry — headless equivalent of TipTap node registration.
3
+ *
4
+ * In the electron app, plugins call context.registerVoidenExtension(tiptapNode)
5
+ * where the TipTap node's addAttributes() defines the block schema (attribute
6
+ * names and their default values). The editor uses that schema to normalise
7
+ * every block before handing it to request-building logic.
8
+ *
9
+ * In voiden-runner there is no TipTap / DOM, but we need the same normalisation
10
+ * so that:
11
+ * • Missing attrs are filled with their declared defaults (no more defensive
12
+ * `?.` chains scattered through every buildRequest implementation)
13
+ * • Block ownership is explicit — the runner knows which plugin owns which
14
+ * block type, matching the manifest.json capabilities.blocks.owns contract
15
+ *
16
+ * Plugins call context.registerBlockSchema() in their runner.ts onload().
17
+ * The runner normalises parsed blocks via normalizeBlocks() before passing
18
+ * them to any registered request builder.
19
+ */
20
+ /** Mirrors TipTap's Attribute definition — only the parts relevant headlessly. */
21
+ export interface BlockAttrDef {
22
+ default?: any;
23
+ }
24
+ /** Headless equivalent of a TipTap Node definition. */
25
+ export interface BlockSchemaDef {
26
+ /** Block type string, e.g. 'gqlquery'. Matches the YAML `type:` field. */
27
+ name: string;
28
+ /** Map of attribute name → definition. Only `default` is used at runtime. */
29
+ attrs: Record<string, BlockAttrDef>;
30
+ }
31
+ export declare function registerBlockSchema(def: BlockSchemaDef): void;
32
+ /**
33
+ * Apply registered schemas to a single block.
34
+ * Fills in any attrs that are missing from the YAML with their declared defaults.
35
+ * Blocks whose type has no registered schema are returned unchanged.
36
+ */
37
+ export declare function normalizeBlock(block: any): any;
38
+ /**
39
+ * Normalise an array of blocks (a full section) against all registered schemas.
40
+ * Recurses into nested content arrays so child blocks (e.g. url inside request)
41
+ * are also normalised.
42
+ */
43
+ export declare function normalizeBlocks(blocks: any[]): any[];
44
+ export declare function clearSchemas(): void;
45
+ /** Returns the registered schema for a block type, or undefined. */
46
+ export declare function getBlockSchema(type: string): BlockSchemaDef | undefined;
47
+ /** Returns all registered block type names — useful for debugging. */
48
+ export declare function getRegisteredBlockTypes(): string[];
49
+ //# sourceMappingURL=blockSchemaRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blockSchemaRegistry.d.ts","sourceRoot":"","sources":["../src/blockSchemaRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,GAAG,CAAA;CACd;AAED,uDAAuD;AACvD,MAAM,WAAW,cAAc;IAC7B,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAA;IACZ,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;CACpC;AAID,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,GAAG,CAe9C;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAQpD;AAED,wBAAgB,YAAY,IAAI,IAAI,CAEnC;AAED,oEAAoE;AACpE,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAEvE;AAED,sEAAsE;AACtE,wBAAgB,uBAAuB,IAAI,MAAM,EAAE,CAElD"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Block Schema Registry — headless equivalent of TipTap node registration.
3
+ *
4
+ * In the electron app, plugins call context.registerVoidenExtension(tiptapNode)
5
+ * where the TipTap node's addAttributes() defines the block schema (attribute
6
+ * names and their default values). The editor uses that schema to normalise
7
+ * every block before handing it to request-building logic.
8
+ *
9
+ * In voiden-runner there is no TipTap / DOM, but we need the same normalisation
10
+ * so that:
11
+ * • Missing attrs are filled with their declared defaults (no more defensive
12
+ * `?.` chains scattered through every buildRequest implementation)
13
+ * • Block ownership is explicit — the runner knows which plugin owns which
14
+ * block type, matching the manifest.json capabilities.blocks.owns contract
15
+ *
16
+ * Plugins call context.registerBlockSchema() in their runner.ts onload().
17
+ * The runner normalises parsed blocks via normalizeBlocks() before passing
18
+ * them to any registered request builder.
19
+ */
20
+ const schemas = new Map();
21
+ export function registerBlockSchema(def) {
22
+ schemas.set(def.name, def);
23
+ }
24
+ /**
25
+ * Apply registered schemas to a single block.
26
+ * Fills in any attrs that are missing from the YAML with their declared defaults.
27
+ * Blocks whose type has no registered schema are returned unchanged.
28
+ */
29
+ export function normalizeBlock(block) {
30
+ const schema = schemas.get(block.type);
31
+ if (!schema)
32
+ return block;
33
+ const normalizedAttrs = {};
34
+ // Apply declared defaults first, then overlay whatever the YAML provided
35
+ for (const [key, def] of Object.entries(schema.attrs)) {
36
+ normalizedAttrs[key] = def.default;
37
+ }
38
+ if (block.attrs && typeof block.attrs === 'object') {
39
+ Object.assign(normalizedAttrs, block.attrs);
40
+ }
41
+ return { ...block, attrs: normalizedAttrs };
42
+ }
43
+ /**
44
+ * Normalise an array of blocks (a full section) against all registered schemas.
45
+ * Recurses into nested content arrays so child blocks (e.g. url inside request)
46
+ * are also normalised.
47
+ */
48
+ export function normalizeBlocks(blocks) {
49
+ return blocks.map(block => {
50
+ const normalized = normalizeBlock(block);
51
+ if (Array.isArray(normalized.content)) {
52
+ return { ...normalized, content: normalizeBlocks(normalized.content) };
53
+ }
54
+ return normalized;
55
+ });
56
+ }
57
+ export function clearSchemas() {
58
+ schemas.clear();
59
+ }
60
+ /** Returns the registered schema for a block type, or undefined. */
61
+ export function getBlockSchema(type) {
62
+ return schemas.get(type);
63
+ }
64
+ /** Returns all registered block type names — useful for debugging. */
65
+ export function getRegisteredBlockTypes() {
66
+ return Array.from(schemas.keys());
67
+ }
68
+ //# sourceMappingURL=blockSchemaRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blockSchemaRegistry.js","sourceRoot":"","sources":["../src/blockSchemaRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAeH,MAAM,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAA;AAEjD,MAAM,UAAU,mBAAmB,CAAC,GAAmB;IACrD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAU;IACvC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACtC,IAAI,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IAEzB,MAAM,eAAe,GAAwB,EAAE,CAAA;IAE/C,yEAAyE;IACzE,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACtD,eAAe,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,OAAO,CAAA;IACpC,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QACnD,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IAC7C,CAAC;IAED,OAAO,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,CAAA;AAC7C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,MAAa;IAC3C,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QACxB,MAAM,UAAU,GAAG,cAAc,CAAC,KAAK,CAAC,CAAA;QACxC,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YACtC,OAAO,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,eAAe,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAA;QACxE,CAAC;QACD,OAAO,UAAU,CAAA;IACnB,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,CAAC,KAAK,EAAE,CAAA;AACjB,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAC1B,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,uBAAuB;IACrC,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;AACnC,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * cliElectron
3
+ *
4
+ * Mirrors the shape of window.electron that sendRequestHybrid expects, but
5
+ * runs entirely in Node.js — no IPC, no Electron main process involved.
6
+ *
7
+ * Electron side: sendRequestHybrid(..., window.electron)
8
+ * CLI side: sendRequestHybrid(..., createCliElectron(env))
9
+ *
10
+ * request.sendSecure → delegates to executeSecureRequest from @voiden/executors
11
+ * (same variable replacement + body building + HTTP execution)
12
+ * env.replaceVariables → replaceEnvVars() from the --env file
13
+ * state.get → returns a stub (no active project in CLI)
14
+ * runtime.* → stubs for UI-only hooks (preSend vars, linked blocks, etc.)
15
+ */
16
+ import type { RestApiRequestState } from '@voiden/sdk';
17
+ export declare function createCliElectron(env: Record<string, string>, runtimeVars?: Record<string, any>): {
18
+ isApp: boolean;
19
+ request: {
20
+ /**
21
+ * Drop-in replacement for window.electron.request.sendSecure.
22
+ * Injects __cliEnv so sendSecure can access the env map without
23
+ * changing the RestApiRequestState interface.
24
+ */
25
+ sendSecure: (requestState: RestApiRequestState, signalState?: any) => Promise<any>;
26
+ };
27
+ env: {
28
+ /** Drop-in for window.electron.env.replaceVariables (used in auth header building) */
29
+ replaceVariables: (text: string) => Promise<string>;
30
+ };
31
+ state: {
32
+ /** No active project in headless mode — callers guard with optional chaining */
33
+ get: () => Promise<{
34
+ activeDirectory: undefined;
35
+ }>;
36
+ };
37
+ runtime: {
38
+ /**
39
+ * preSendProcessHook equivalent — in UI this replaces {{process.xxx}} from
40
+ * .voiden/.process.env.json. In CLI we have no project dir, so just return
41
+ * the state as-is. Pass --env to cover the same variables.
42
+ */
43
+ preSendProcess: (state: RestApiRequestState) => Promise<any>;
44
+ /** replaceProcessVariablesInText equivalent — identity in CLI */
45
+ replaceVar: (text: string) => Promise<string>;
46
+ /** expandLinkedBlocksInDoc equivalent — no linked blocks in CLI */
47
+ expandLinkedBlocks: (json: any) => Promise<any>;
48
+ /** getRuntimeVariablesMap equivalent — no capture config in CLI */
49
+ getRuntimeVariables: (_json: any) => Promise<never[]>;
50
+ /** saveRuntimeVariables equivalent — no project dir to save to in CLI */
51
+ saveRuntimeVariables: () => Promise<void>;
52
+ };
53
+ };
54
+ export type CliElectron = ReturnType<typeof createCliElectron>;
55
+ //# sourceMappingURL=cliElectron.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cliElectron.d.ts","sourceRoot":"","sources":["../src/cliElectron.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AA8EtD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;;;QAK9F;;;;WAIG;mCACwB,mBAAmB,gBAAgB,GAAG;;;QAKjE,sFAAsF;iCAC7D,MAAM;;;QAI/B,gFAAgF;;;;;;QAKhF;;;;WAIG;gCACqB,mBAAmB;QAG3C,iEAAiE;2BAC9C,MAAM;QAEzB,mEAAmE;mCACxC,GAAG;QAE9B,mEAAmE;qCACtC,GAAG;QAEhC,yEAAyE;;;EAI9E;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAA"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * cliElectron
3
+ *
4
+ * Mirrors the shape of window.electron that sendRequestHybrid expects, but
5
+ * runs entirely in Node.js — no IPC, no Electron main process involved.
6
+ *
7
+ * Electron side: sendRequestHybrid(..., window.electron)
8
+ * CLI side: sendRequestHybrid(..., createCliElectron(env))
9
+ *
10
+ * request.sendSecure → delegates to executeSecureRequest from @voiden/executors
11
+ * (same variable replacement + body building + HTTP execution)
12
+ * env.replaceVariables → replaceEnvVars() from the --env file
13
+ * state.get → returns a stub (no active project in CLI)
14
+ * runtime.* → stubs for UI-only hooks (preSend vars, linked blocks, etc.)
15
+ */
16
+ import { replaceEnvVars, executeSecureRequest } from '@voiden/executors';
17
+ import { readFile } from 'node:fs/promises';
18
+ import { applyProcessVarsToState } from './runtimeVars.js';
19
+ // ─── Core sendSecure — delegates to the shared executor ───────────────────────
20
+ async function sendSecure(requestState, _signalState) {
21
+ const env = requestState.__cliEnv ?? {};
22
+ const adapter = {
23
+ replaceVar: (text) => Promise.resolve(replaceEnvVars(text, env)),
24
+ readFile: (filePath) => readFile(filePath),
25
+ // isElectron defaults to true — executeSecureRequest returns a handoff for
26
+ // WS/gRPC (same as the Electron app). The socket plugin's onProcessResponse
27
+ // hook handles the actual connection after receiving the handoff response.
28
+ };
29
+ try {
30
+ const result = await executeSecureRequest(requestState, adapter);
31
+ // WS / gRPC / GraphQL-subscription: executeSecureRequest returns a handoff
32
+ // (same as in the Electron app). The socket plugin's onProcessResponse hook
33
+ // handles the actual connection and updates the response.
34
+ if (result.kind === 'handoff') {
35
+ return {
36
+ // PipelineResponse shape (executor casts adapterResponse as PipelineResponse
37
+ // for isSpecialProtocol requests)
38
+ statusCode: 0,
39
+ statusMessage: 'Handoff',
40
+ headers: [],
41
+ contentType: null,
42
+ body: null,
43
+ url: result.resolvedUrl,
44
+ elapsedTime: 0,
45
+ bytesContent: 0,
46
+ protocol: result.protocol,
47
+ requestMeta: {
48
+ method: requestState.method,
49
+ url: result.resolvedUrl,
50
+ headers: Object.entries(result.resolvedHeaders).map(([key, value]) => ({ key, value })),
51
+ httpVersion: result.protocol.toUpperCase(),
52
+ },
53
+ // Plugin reads handoff data from here in its onProcessResponse handler
54
+ metadata: {
55
+ handoff: {
56
+ protocol: result.protocol,
57
+ url: result.resolvedUrl,
58
+ headers: result.resolvedHeaders,
59
+ grpc: result.requestState?.grpc,
60
+ body: result.resolvedBody,
61
+ },
62
+ },
63
+ };
64
+ }
65
+ return {
66
+ status: result.status,
67
+ statusText: result.statusText,
68
+ headers: result.headers,
69
+ body: result.body,
70
+ protocol: result.protocol,
71
+ operationType: result.operationType,
72
+ requestMeta: result.requestMeta,
73
+ };
74
+ }
75
+ catch (error) {
76
+ return {
77
+ statusText: error?.message || 'Request failed',
78
+ error: error?.message || 'Request failed',
79
+ };
80
+ }
81
+ }
82
+ // ─── Public factory ───────────────────────────────────────────────────────────
83
+ export function createCliElectron(env, runtimeVars = {}) {
84
+ return {
85
+ isApp: false,
86
+ request: {
87
+ /**
88
+ * Drop-in replacement for window.electron.request.sendSecure.
89
+ * Injects __cliEnv so sendSecure can access the env map without
90
+ * changing the RestApiRequestState interface.
91
+ */
92
+ sendSecure: (requestState, signalState) => sendSecure({ ...requestState, __cliEnv: env }, signalState),
93
+ },
94
+ env: {
95
+ /** Drop-in for window.electron.env.replaceVariables (used in auth header building) */
96
+ replaceVariables: (text) => Promise.resolve(replaceEnvVars(text, env)),
97
+ },
98
+ state: {
99
+ /** No active project in headless mode — callers guard with optional chaining */
100
+ get: () => Promise.resolve({ activeDirectory: undefined }),
101
+ },
102
+ runtime: {
103
+ /**
104
+ * preSendProcessHook equivalent — in UI this replaces {{process.xxx}} from
105
+ * .voiden/.process.env.json. In CLI we have no project dir, so just return
106
+ * the state as-is. Pass --env to cover the same variables.
107
+ */
108
+ preSendProcess: (state) => Promise.resolve(applyProcessVarsToState(state, runtimeVars)),
109
+ /** replaceProcessVariablesInText equivalent — identity in CLI */
110
+ replaceVar: (text) => Promise.resolve(text),
111
+ /** expandLinkedBlocksInDoc equivalent — no linked blocks in CLI */
112
+ expandLinkedBlocks: (json) => Promise.resolve(json),
113
+ /** getRuntimeVariablesMap equivalent — no capture config in CLI */
114
+ getRuntimeVariables: (_json) => Promise.resolve([]),
115
+ /** saveRuntimeVariables equivalent — no project dir to save to in CLI */
116
+ saveRuntimeVariables: () => Promise.resolve(),
117
+ },
118
+ };
119
+ }
120
+ //# sourceMappingURL=cliElectron.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cliElectron.js","sourceRoot":"","sources":["../src/cliElectron.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAGxE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAE1D,iFAAiF;AAEjF,KAAK,UAAU,UAAU,CACvB,YAAiC,EACjC,YAA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AAC,OAAO,CAAC,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC;SAC3D;QAED,OAAO,EAAE;YACP;;;;eAIG;YACH,cAAc,EAAE,CAAC,KAA0B,EAAE,EAAE,CAC7C,OAAO,CAAC,OAAO,CAAC,uBAAuB,CAAC,KAAK,EAAE,WAAW,CAAwB,CAAC;YAErF,iEAAiE;YACjE,UAAU,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;YAEnD,mEAAmE;YACnE,kBAAkB,EAAE,CAAC,IAAS,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;YAExD,mEAAmE;YACnE,mBAAmB,EAAE,CAAC,KAAU,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAExD,yEAAyE;YACzE,oBAAoB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE;SAC9C;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * createHeadlessPluginContext
3
+ *
4
+ * Returns a plugin context that can be passed to a core-extension's plugin.ts
5
+ * `onload()` in a headless Node.js environment (voiden-runner CLI).
6
+ *
7
+ * • All UI-related methods (registerVoidenExtension, registerSidebarTab, …)
8
+ * are no-ops — plugin.ts guards UI setup behind `if (context.ui?.components)`.
9
+ * • pipeline.registerHook wires directly into the shared hookRegistry from
10
+ * @voiden/executors so that hooks fire when executeRequestPipeline runs.
11
+ * • onBuildRequest / onProcessResponse wire into the shared requestOrchestrator
12
+ * from @voiden/executors — the same orchestration path used by the Electron app.
13
+ * If a plugin is disabled its handlers are never registered, so requests
14
+ * that require that plugin fail gracefully (same behaviour as the app).
15
+ */
16
+ import type { RunnerContext } from '@voiden/sdk/runner';
17
+ export declare function createHeadlessPluginContext(extensionId: string, verbose?: boolean): RunnerContext;
18
+ //# sourceMappingURL=headlessContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headlessContext.d.ts","sourceRoot":"","sources":["../src/headlessContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,KAAK,EAAE,aAAa,EAA+C,MAAM,oBAAoB,CAAA;AAEpG,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,OAAe,GACvB,aAAa,CA0Ef"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * createHeadlessPluginContext
3
+ *
4
+ * Returns a plugin context that can be passed to a core-extension's plugin.ts
5
+ * `onload()` in a headless Node.js environment (voiden-runner CLI).
6
+ *
7
+ * • All UI-related methods (registerVoidenExtension, registerSidebarTab, …)
8
+ * are no-ops — plugin.ts guards UI setup behind `if (context.ui?.components)`.
9
+ * • pipeline.registerHook wires directly into the shared hookRegistry from
10
+ * @voiden/executors so that hooks fire when executeRequestPipeline runs.
11
+ * • onBuildRequest / onProcessResponse wire into the shared requestOrchestrator
12
+ * from @voiden/executors — the same orchestration path used by the Electron app.
13
+ * If a plugin is disabled its handlers are never registered, so requests
14
+ * that require that plugin fail gracefully (same behaviour as the app).
15
+ */
16
+ import { hookRegistry, requestOrchestrator, executeWebSocket, executeGrpc } from '@voiden/executors';
17
+ import { registerBlockSchema } from './blockSchemaRegistry.js';
18
+ export function createHeadlessPluginContext(extensionId, verbose = false) {
19
+ return {
20
+ // ── Pipeline hook registration (for hook plugins: scripting, auth, etc.) ─
21
+ pipeline: {
22
+ registerHook: (stage, handler, priority) => {
23
+ hookRegistry.registerHook(extensionId, stage, handler, priority ?? 100);
24
+ },
25
+ },
26
+ // ── Request builder registration (for parser plugins: graphql, sockets, rest) ─
27
+ // Parser plugins call this in their runner.ts onload() to register their
28
+ // block→request conversion function with the shared orchestrator.
29
+ // The SDK expects (request, blocks), but orchestrator uses (request, editor).
30
+ onBuildRequest: (handler) => {
31
+ requestOrchestrator.onBuildRequest(async (request, editor) => {
32
+ const blocks = editor.getJSON()?.content ?? [];
33
+ return (await handler(request, blocks)) ?? request;
34
+ });
35
+ },
36
+ // Backward-compat alias: old compiled dist/*/runner.js files call
37
+ // context.registerRequestBuilder(fn) where fn takes (blocks[]) directly.
38
+ registerRequestBuilder: (fn) => {
39
+ requestOrchestrator.onBuildRequest(async (request, editor) => {
40
+ const blocks = editor.getJSON()?.content ?? [];
41
+ const built = await fn(blocks);
42
+ return built ?? request;
43
+ });
44
+ },
45
+ // ── Response handler registration ──────────────────────────────────────
46
+ onProcessResponse: (handler) => {
47
+ requestOrchestrator.onProcessResponse(async (response, editor, request) => {
48
+ const blocks = editor.getJSON()?.content ?? [];
49
+ await handler(response, blocks, request);
50
+ });
51
+ },
52
+ // ── Block schema registration (headless equivalent of registerVoidenExtension) ─
53
+ registerBlockSchema: (def) => {
54
+ registerBlockSchema(def);
55
+ },
56
+ // ── Protocol executors (for socket plugins) ───────────────────────────
57
+ protocols: {
58
+ executeWebSocket: (req) => executeWebSocket(req),
59
+ executeGrpc: (req) => executeGrpc(req),
60
+ },
61
+ // ── Verbosity ────────────────────────────────────────────────────────
62
+ verbose,
63
+ // ── Reporting ────────────────────────────────────────────────────────
64
+ report: {
65
+ add: (_entry) => {
66
+ // Runner implementation handles report aggregation via metadata.reportEntries
67
+ // for now. This can be expanded to a dedicated report collector.
68
+ },
69
+ getEntries: () => [],
70
+ },
71
+ // ── UI stubs (all no-ops to satisfy type system if needed) ───────────
72
+ ...{
73
+ registerVoidenExtension: () => { },
74
+ registerCodemirrorExtension: () => { },
75
+ registerLinkableNodeTypes: () => { },
76
+ registerNodeDisplayNames: () => { },
77
+ registerSidebarTab: () => { },
78
+ addVoidenSlashGroup: () => { },
79
+ exposeHelpers: () => { },
80
+ paste: { registerBlockOwner: () => { } },
81
+ project: { openFile: () => { } },
82
+ },
83
+ };
84
+ }
85
+ //# sourceMappingURL=headlessContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"headlessContext.js","sourceRoot":"","sources":["../src/headlessContext.ts"],"names":[],"mappings":"AAAA;;;;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E,GAAG,EAAE,GAAE,CAAC,EAAE;SACxB;KACV,CAAA;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}