@causyne/agent 1.12.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,108 @@
1
+ import path from 'node:path';
2
+ // PDF inspection, page rendering, text extraction, assembly and editing engine for Causyne Agent.
3
+ // Headless document renderer, rasterizer, merger, splitter and audit tool.
4
+ // Operates deterministically via clean CLI subcommands.
5
+ const TIMEOUTS = {
6
+ status: 10_000,
7
+ catalog: 30_000,
8
+ describe: 30_000,
9
+ inspect: 60_000,
10
+ execute: 180_000,
11
+ batch: 600_000,
12
+ export: 300_000,
13
+ render: 300_000,
14
+ probe: 60_000,
15
+ install: 600_000
16
+ };
17
+ function positional(value) {
18
+ return value.startsWith('-') ? `.${path.sep}${value}` : value;
19
+ }
20
+ function requireProject(context, action) {
21
+ if (!context.project)
22
+ throw new Error(`${action} requires project`);
23
+ return positional(context.project);
24
+ }
25
+ function commandArgs(steps) {
26
+ const args = [];
27
+ for (const step of steps) {
28
+ args.push(step.id);
29
+ if (step.params && Object.keys(step.params).length > 0) {
30
+ for (const [key, val] of Object.entries(step.params)) {
31
+ args.push(`${key}=${typeof val === 'string' ? val : JSON.stringify(val)}`);
32
+ }
33
+ }
34
+ }
35
+ return args;
36
+ }
37
+ export const pdfEngine = {
38
+ id: 'pdf',
39
+ label: 'Causyne PDF Engine',
40
+ envVar: 'CAUSYNE_ENGINE_PDF',
41
+ binaryName: 'causyne-engine-pdf',
42
+ actions: ['catalog', 'describe', 'inspect', 'execute', 'batch', 'export', 'render', 'probe'],
43
+ invoke(request, context) {
44
+ let args;
45
+ let artifacts = [];
46
+ switch (request.action) {
47
+ case 'status':
48
+ args = ['--help'];
49
+ break;
50
+ case 'catalog':
51
+ args = ['tools'];
52
+ break;
53
+ case 'describe':
54
+ args = ['tools'];
55
+ break;
56
+ case 'inspect':
57
+ args = ['info', requireProject(context, 'inspect')];
58
+ break;
59
+ case 'probe':
60
+ args = ['info', positional(request.query ?? '')];
61
+ break;
62
+ case 'execute':
63
+ case 'batch': {
64
+ const steps = request.action === 'execute'
65
+ ? [{ id: request.command ?? '', ...(request.params ? { params: request.params } : {}) }]
66
+ : (request.steps ?? []);
67
+ args = ['run', ...commandArgs(steps)];
68
+ if (context.saveAs) {
69
+ args.push('--out', context.saveAs);
70
+ artifacts.push(context.saveAs);
71
+ }
72
+ else if (context.save && context.project) {
73
+ args.push('--out', context.project);
74
+ artifacts.push(context.project);
75
+ }
76
+ break;
77
+ }
78
+ case 'render': {
79
+ const output = request.output ?? '';
80
+ const page = request.start ?? (typeof request.params?.page === 'number' ? request.params.page : 1);
81
+ args = ['render', requireProject(context, 'render'), '--page', String(page), '--out', positional(output)];
82
+ const dpi = request.quality ?? (typeof request.params?.dpi === 'number' ? request.params.dpi : undefined);
83
+ if (dpi) {
84
+ args.push('--dpi', String(dpi));
85
+ }
86
+ artifacts = [output];
87
+ break;
88
+ }
89
+ case 'export': {
90
+ const output = request.output ?? '';
91
+ args = ['extract', requireProject(context, 'export'), '--out', positional(output)];
92
+ const pages = typeof request.params?.pages === 'string' ? request.params.pages : Array.isArray(request.params?.pages) ? request.params.pages.join(',') : undefined;
93
+ if (pages) {
94
+ args.push('--pages', String(pages));
95
+ }
96
+ artifacts = [output];
97
+ break;
98
+ }
99
+ default:
100
+ throw new Error(`Unsupported pdf engine action: ${request.action}`);
101
+ }
102
+ return {
103
+ args,
104
+ artifacts,
105
+ timeoutMs: TIMEOUTS[request.action] ?? 60_000
106
+ };
107
+ }
108
+ };
@@ -0,0 +1,124 @@
1
+ import path from 'node:path';
2
+ import type {
3
+ NativeEngineAction,
4
+ NativeEngineAdapter,
5
+ NativeEngineContext,
6
+ NativeEngineInvocation,
7
+ NativeEngineRequest,
8
+ NativeEngineStep
9
+ } from './types.js';
10
+
11
+ // PDF inspection, page rendering, text extraction, assembly and editing engine for Causyne Agent.
12
+ // Headless document renderer, rasterizer, merger, splitter and audit tool.
13
+ // Operates deterministically via clean CLI subcommands.
14
+
15
+ const TIMEOUTS: Record<NativeEngineAction, number> = {
16
+ status: 10_000,
17
+ catalog: 30_000,
18
+ describe: 30_000,
19
+ inspect: 60_000,
20
+ execute: 180_000,
21
+ batch: 600_000,
22
+ export: 300_000,
23
+ render: 300_000,
24
+ probe: 60_000,
25
+ install: 600_000
26
+ };
27
+
28
+ function positional(value: string): string {
29
+ return value.startsWith('-') ? `.${path.sep}${value}` : value;
30
+ }
31
+
32
+ function requireProject(context: NativeEngineContext, action: string): string {
33
+ if (!context.project) throw new Error(`${action} requires project`);
34
+ return positional(context.project);
35
+ }
36
+
37
+ function commandArgs(steps: NativeEngineStep[]): string[] {
38
+ const args: string[] = [];
39
+ for (const step of steps) {
40
+ args.push(step.id);
41
+ if (step.params && Object.keys(step.params).length > 0) {
42
+ for (const [key, val] of Object.entries(step.params)) {
43
+ args.push(`${key}=${typeof val === 'string' ? val : JSON.stringify(val)}`);
44
+ }
45
+ }
46
+ }
47
+ return args;
48
+ }
49
+
50
+ export const pdfEngine: NativeEngineAdapter = {
51
+ id: 'pdf',
52
+ label: 'Causyne PDF Engine',
53
+ envVar: 'CAUSYNE_ENGINE_PDF',
54
+ binaryName: 'causyne-engine-pdf',
55
+ actions: ['catalog', 'describe', 'inspect', 'execute', 'batch', 'export', 'render', 'probe'],
56
+ invoke(request: NativeEngineRequest, context: NativeEngineContext): NativeEngineInvocation {
57
+ let args: string[];
58
+ let artifacts: string[] = [];
59
+
60
+ switch (request.action) {
61
+ case 'status':
62
+ args = ['--help'];
63
+ break;
64
+ case 'catalog':
65
+ args = ['tools'];
66
+ break;
67
+ case 'describe':
68
+ args = ['tools'];
69
+ break;
70
+ case 'inspect':
71
+ args = ['info', requireProject(context, 'inspect')];
72
+ break;
73
+ case 'probe':
74
+ args = ['info', positional(request.query ?? '')];
75
+ break;
76
+ case 'execute':
77
+ case 'batch': {
78
+ const steps: NativeEngineStep[] = request.action === 'execute'
79
+ ? [{ id: request.command ?? '', ...(request.params ? { params: request.params } : {}) }]
80
+ : (request.steps ?? []);
81
+
82
+ args = ['run', ...commandArgs(steps)];
83
+
84
+ if (context.saveAs) {
85
+ args.push('--out', context.saveAs);
86
+ artifacts.push(context.saveAs);
87
+ } else if (context.save && context.project) {
88
+ args.push('--out', context.project);
89
+ artifacts.push(context.project);
90
+ }
91
+ break;
92
+ }
93
+ case 'render': {
94
+ const output = request.output ?? '';
95
+ const page = request.start ?? (typeof request.params?.page === 'number' ? request.params.page : 1);
96
+ args = ['render', requireProject(context, 'render'), '--page', String(page), '--out', positional(output)];
97
+ const dpi = request.quality ?? (typeof request.params?.dpi === 'number' ? request.params.dpi : undefined);
98
+ if (dpi) {
99
+ args.push('--dpi', String(dpi));
100
+ }
101
+ artifacts = [output];
102
+ break;
103
+ }
104
+ case 'export': {
105
+ const output = request.output ?? '';
106
+ args = ['extract', requireProject(context, 'export'), '--out', positional(output)];
107
+ const pages = typeof request.params?.pages === 'string' ? request.params.pages : Array.isArray(request.params?.pages) ? request.params.pages.join(',') : undefined;
108
+ if (pages) {
109
+ args.push('--pages', String(pages));
110
+ }
111
+ artifacts = [output];
112
+ break;
113
+ }
114
+ default:
115
+ throw new Error(`Unsupported pdf engine action: ${request.action}`);
116
+ }
117
+
118
+ return {
119
+ args,
120
+ artifacts,
121
+ timeoutMs: TIMEOUTS[request.action] ?? 60_000
122
+ };
123
+ }
124
+ };
@@ -3,16 +3,30 @@ import path from 'node:path';
3
3
  import { spawn } from 'node:child_process';
4
4
  import { causyneHome, resolveUserPath } from '../utils/paths.js';
5
5
  import { filmEngine } from './film.js';
6
+ import { deckEngine } from './deck.js';
6
7
  import { photoEngine } from './photo.js';
7
8
  import { soundEngine } from './sound.js';
8
9
  import { cadEngine } from './cad.js';
10
+ import { designEngine } from './design.js';
11
+ import { wordEngine } from './word.js';
12
+ import { gridEngine } from './grid.js';
13
+ import { lightEngine } from './light.js';
14
+ import { pdfEngine } from './pdf.js';
15
+ import { effectEngine } from './effect.js';
9
16
  const MAX_STDOUT = 8 * 1024 * 1024;
10
17
  const MAX_STDERR = 1024 * 1024;
11
18
  export const NATIVE_ENGINES = {
12
19
  [filmEngine.id]: filmEngine,
20
+ [deckEngine.id]: deckEngine,
13
21
  [photoEngine.id]: photoEngine,
14
22
  [soundEngine.id]: soundEngine,
15
- [cadEngine.id]: cadEngine
23
+ [cadEngine.id]: cadEngine,
24
+ [designEngine.id]: designEngine,
25
+ [wordEngine.id]: wordEngine,
26
+ [gridEngine.id]: gridEngine,
27
+ [lightEngine.id]: lightEngine,
28
+ [pdfEngine.id]: pdfEngine,
29
+ [effectEngine.id]: effectEngine
16
30
  };
17
31
  export function nativeEngine(id) {
18
32
  return NATIVE_ENGINES[id] ?? null;
@@ -3,9 +3,16 @@ import path from 'node:path';
3
3
  import { spawn } from 'node:child_process';
4
4
  import { causyneHome, resolveUserPath } from '../utils/paths.js';
5
5
  import { filmEngine } from './film.js';
6
+ import { deckEngine } from './deck.js';
6
7
  import { photoEngine } from './photo.js';
7
8
  import { soundEngine } from './sound.js';
8
9
  import { cadEngine } from './cad.js';
10
+ import { designEngine } from './design.js';
11
+ import { wordEngine } from './word.js';
12
+ import { gridEngine } from './grid.js';
13
+ import { lightEngine } from './light.js';
14
+ import { pdfEngine } from './pdf.js';
15
+ import { effectEngine } from './effect.js';
9
16
  import type { NativeEngineAdapter, NativeEngineRun } from './types.js';
10
17
 
11
18
  const MAX_STDOUT = 8 * 1024 * 1024;
@@ -13,9 +20,16 @@ const MAX_STDERR = 1024 * 1024;
13
20
 
14
21
  export const NATIVE_ENGINES: Record<string, NativeEngineAdapter> = {
15
22
  [filmEngine.id]: filmEngine,
23
+ [deckEngine.id]: deckEngine,
16
24
  [photoEngine.id]: photoEngine,
17
25
  [soundEngine.id]: soundEngine,
18
- [cadEngine.id]: cadEngine
26
+ [cadEngine.id]: cadEngine,
27
+ [designEngine.id]: designEngine,
28
+ [wordEngine.id]: wordEngine,
29
+ [gridEngine.id]: gridEngine,
30
+ [lightEngine.id]: lightEngine,
31
+ [pdfEngine.id]: pdfEngine,
32
+ [effectEngine.id]: effectEngine
19
33
  };
20
34
 
21
35
  export function nativeEngine(id: string): NativeEngineAdapter | null {
@@ -0,0 +1,112 @@
1
+ import path from 'node:path';
2
+ // Document typesetting, DOCX/PDF formatting, and text processing engine for Causyne Agent.
3
+ // Headless word processor, document structural inspector, and batch runner.
4
+ // Operates deterministically via clean CLI subcommands.
5
+ const TIMEOUTS = {
6
+ status: 10_000,
7
+ catalog: 30_000,
8
+ describe: 30_000,
9
+ inspect: 60_000,
10
+ execute: 180_000,
11
+ batch: 600_000,
12
+ export: 300_000,
13
+ render: 300_000,
14
+ probe: 60_000,
15
+ install: 600_000
16
+ };
17
+ function positional(value) {
18
+ return value.startsWith('-') ? `.${path.sep}${value}` : value;
19
+ }
20
+ function requireProject(context, action) {
21
+ if (!context.project)
22
+ throw new Error(`${action} requires project`);
23
+ return positional(context.project);
24
+ }
25
+ function commandArgs(steps) {
26
+ const args = [];
27
+ for (const step of steps) {
28
+ if (step.params && Object.keys(step.params).length > 0) {
29
+ args.push('--cmd', `${step.id}=${JSON.stringify(step.params)}`);
30
+ }
31
+ else {
32
+ args.push('--cmd', step.id);
33
+ }
34
+ }
35
+ return args;
36
+ }
37
+ export const wordEngine = {
38
+ id: 'word',
39
+ label: 'Causyne Word Engine',
40
+ envVar: 'CAUSYNE_ENGINE_WORD',
41
+ binaryName: 'causyne-engine-word',
42
+ actions: ['catalog', 'describe', 'inspect', 'execute', 'batch', 'export', 'render', 'probe'],
43
+ invoke(request, context) {
44
+ let args;
45
+ let artifacts = [];
46
+ switch (request.action) {
47
+ case 'status':
48
+ args = ['--version'];
49
+ break;
50
+ case 'catalog':
51
+ args = ['commands', '--json'];
52
+ break;
53
+ case 'describe':
54
+ args = ['commands', '--json'];
55
+ break;
56
+ case 'inspect':
57
+ args = ['info', requireProject(context, 'inspect')];
58
+ break;
59
+ case 'probe':
60
+ args = ['info', positional(request.query ?? '')];
61
+ break;
62
+ case 'execute':
63
+ case 'batch': {
64
+ const steps = request.action === 'execute'
65
+ ? [{ id: request.command ?? '', ...(request.params ? { params: request.params } : {}) }]
66
+ : (request.steps ?? []);
67
+ args = ['run'];
68
+ if (context.project) {
69
+ args.push('--file', positional(context.project));
70
+ }
71
+ else if (context.demo) {
72
+ args.push('--template', 'blank');
73
+ }
74
+ args.push(...commandArgs(steps));
75
+ if (context.saveAs) {
76
+ args.push('--save', context.saveAs);
77
+ artifacts.push(context.saveAs);
78
+ }
79
+ else if (context.save && context.project) {
80
+ args.push('--save', context.project);
81
+ artifacts.push(context.project);
82
+ }
83
+ break;
84
+ }
85
+ case 'export': {
86
+ const output = request.output ?? '';
87
+ args = ['convert', requireProject(context, 'export'), positional(output)];
88
+ artifacts = [output];
89
+ break;
90
+ }
91
+ case 'render': {
92
+ const output = request.output ?? '';
93
+ args = ['render', requireProject(context, 'render'), positional(output)];
94
+ if (request.range) {
95
+ args.push('--page', request.range);
96
+ }
97
+ if (request.scale !== undefined) {
98
+ args.push('--scale', String(request.scale));
99
+ }
100
+ artifacts = [output];
101
+ break;
102
+ }
103
+ default:
104
+ throw new Error(`Unsupported word engine action: ${request.action}`);
105
+ }
106
+ return {
107
+ args,
108
+ artifacts,
109
+ timeoutMs: TIMEOUTS[request.action] ?? 60_000
110
+ };
111
+ }
112
+ };
@@ -0,0 +1,127 @@
1
+ import path from 'node:path';
2
+ import type {
3
+ NativeEngineAction,
4
+ NativeEngineAdapter,
5
+ NativeEngineContext,
6
+ NativeEngineInvocation,
7
+ NativeEngineRequest,
8
+ NativeEngineStep
9
+ } from './types.js';
10
+
11
+ // Document typesetting, DOCX/PDF formatting, and text processing engine for Causyne Agent.
12
+ // Headless word processor, document structural inspector, and batch runner.
13
+ // Operates deterministically via clean CLI subcommands.
14
+
15
+ const TIMEOUTS: Record<NativeEngineAction, number> = {
16
+ status: 10_000,
17
+ catalog: 30_000,
18
+ describe: 30_000,
19
+ inspect: 60_000,
20
+ execute: 180_000,
21
+ batch: 600_000,
22
+ export: 300_000,
23
+ render: 300_000,
24
+ probe: 60_000,
25
+ install: 600_000
26
+ };
27
+
28
+ function positional(value: string): string {
29
+ return value.startsWith('-') ? `.${path.sep}${value}` : value;
30
+ }
31
+
32
+ function requireProject(context: NativeEngineContext, action: string): string {
33
+ if (!context.project) throw new Error(`${action} requires project`);
34
+ return positional(context.project);
35
+ }
36
+
37
+ function commandArgs(steps: NativeEngineStep[]): string[] {
38
+ const args: string[] = [];
39
+ for (const step of steps) {
40
+ if (step.params && Object.keys(step.params).length > 0) {
41
+ args.push('--cmd', `${step.id}=${JSON.stringify(step.params)}`);
42
+ } else {
43
+ args.push('--cmd', step.id);
44
+ }
45
+ }
46
+ return args;
47
+ }
48
+
49
+ export const wordEngine: NativeEngineAdapter = {
50
+ id: 'word',
51
+ label: 'Causyne Word Engine',
52
+ envVar: 'CAUSYNE_ENGINE_WORD',
53
+ binaryName: 'causyne-engine-word',
54
+ actions: ['catalog', 'describe', 'inspect', 'execute', 'batch', 'export', 'render', 'probe'],
55
+ invoke(request: NativeEngineRequest, context: NativeEngineContext): NativeEngineInvocation {
56
+ let args: string[];
57
+ let artifacts: string[] = [];
58
+
59
+ switch (request.action) {
60
+ case 'status':
61
+ args = ['--version'];
62
+ break;
63
+ case 'catalog':
64
+ args = ['commands', '--json'];
65
+ break;
66
+ case 'describe':
67
+ args = ['commands', '--json'];
68
+ break;
69
+ case 'inspect':
70
+ args = ['info', requireProject(context, 'inspect')];
71
+ break;
72
+ case 'probe':
73
+ args = ['info', positional(request.query ?? '')];
74
+ break;
75
+ case 'execute':
76
+ case 'batch': {
77
+ const steps: NativeEngineStep[] = request.action === 'execute'
78
+ ? [{ id: request.command ?? '', ...(request.params ? { params: request.params } : {}) }]
79
+ : (request.steps ?? []);
80
+
81
+ args = ['run'];
82
+ if (context.project) {
83
+ args.push('--file', positional(context.project));
84
+ } else if (context.demo) {
85
+ args.push('--template', 'blank');
86
+ }
87
+
88
+ args.push(...commandArgs(steps));
89
+
90
+ if (context.saveAs) {
91
+ args.push('--save', context.saveAs);
92
+ artifacts.push(context.saveAs);
93
+ } else if (context.save && context.project) {
94
+ args.push('--save', context.project);
95
+ artifacts.push(context.project);
96
+ }
97
+ break;
98
+ }
99
+ case 'export': {
100
+ const output = request.output ?? '';
101
+ args = ['convert', requireProject(context, 'export'), positional(output)];
102
+ artifacts = [output];
103
+ break;
104
+ }
105
+ case 'render': {
106
+ const output = request.output ?? '';
107
+ args = ['render', requireProject(context, 'render'), positional(output)];
108
+ if (request.range) {
109
+ args.push('--page', request.range);
110
+ }
111
+ if (request.scale !== undefined) {
112
+ args.push('--scale', String(request.scale));
113
+ }
114
+ artifacts = [output];
115
+ break;
116
+ }
117
+ default:
118
+ throw new Error(`Unsupported word engine action: ${request.action}`);
119
+ }
120
+
121
+ return {
122
+ args,
123
+ artifacts,
124
+ timeoutMs: TIMEOUTS[request.action] ?? 60_000
125
+ };
126
+ }
127
+ };