@causyne/agent 1.10.21 → 1.12.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 (82) hide show
  1. package/docs/THIRD_PARTY_NOTICES.md +12 -0
  2. package/native-skills/media/professional-document-publishing/SKILL.md +44 -0
  3. package/native-skills/media/screenplay-and-shotlist-forge/SKILL.md +42 -0
  4. package/package.json +1 -1
  5. package/src/acp/client.js +235 -0
  6. package/src/acp/client.ts +282 -0
  7. package/src/acp/peerProfiles.js +122 -0
  8. package/src/acp/peerProfiles.ts +128 -0
  9. package/src/acp/protocol.js +55 -0
  10. package/src/acp/protocol.ts +456 -0
  11. package/src/acp/server.js +746 -0
  12. package/src/acp/server.ts +822 -0
  13. package/src/agentLoop.d.ts +64 -0
  14. package/src/agentLoop.js +156 -12
  15. package/src/approvalGrants.js +33 -0
  16. package/src/approvalGrants.ts +50 -0
  17. package/src/commands.js +203 -0
  18. package/src/compiledSkills.js +10 -0
  19. package/src/decisionPolicy.js +2 -0
  20. package/src/decisionPolicy.ts +1 -0
  21. package/src/documentEngine/antiSlopAuditor.js +156 -0
  22. package/src/documentEngine/antiSlopAuditor.ts +221 -0
  23. package/src/documentEngine/documentForge.js +443 -0
  24. package/src/documentEngine/documentForge.ts +519 -0
  25. package/src/documentEngine/screenplayFormatter.js +336 -0
  26. package/src/documentEngine/screenplayFormatter.ts +407 -0
  27. package/src/engines/cad.js +113 -0
  28. package/src/engines/cad.ts +128 -0
  29. package/src/engines/film.js +108 -0
  30. package/src/engines/film.ts +104 -0
  31. package/src/engines/installer.js +226 -0
  32. package/src/engines/installer.ts +248 -0
  33. package/src/engines/photo.js +126 -0
  34. package/src/engines/photo.ts +137 -0
  35. package/src/engines/registry.js +186 -0
  36. package/src/engines/registry.ts +185 -0
  37. package/src/engines/sound.js +117 -0
  38. package/src/engines/sound.ts +130 -0
  39. package/src/engines/types.js +1 -0
  40. package/src/engines/types.ts +73 -0
  41. package/src/entrypoint.js +13 -0
  42. package/src/execSafe.js +10 -13
  43. package/src/execSafe.ts +25 -0
  44. package/src/memoryManager.js +9 -3
  45. package/src/modelRouter.js +56 -123
  46. package/src/modelRouter.ts +134 -0
  47. package/src/observer/advisory.js +164 -0
  48. package/src/observer/advisory.ts +171 -0
  49. package/src/observer/coldObserver.js +462 -0
  50. package/src/observer/coldObserver.ts +540 -0
  51. package/src/observer/evidence.js +435 -0
  52. package/src/observer/evidence.ts +499 -0
  53. package/src/perception.js +303 -118
  54. package/src/perception.ts +387 -0
  55. package/src/procSignal.js +15 -16
  56. package/src/procSignal.ts +31 -0
  57. package/src/promptMentions.js +170 -0
  58. package/src/promptMentions.ts +212 -0
  59. package/src/sandbox.js +9 -1
  60. package/src/sessionJournal.js +12 -2
  61. package/src/sessionJournal.ts +12 -2
  62. package/src/textDiff.js +117 -109
  63. package/src/textDiff.ts +169 -0
  64. package/src/toolPacks.js +19 -8
  65. package/src/tools/documentForge.js +215 -0
  66. package/src/tools/documentForge.ts +265 -0
  67. package/src/tools/generateMediaViaApi.js +1 -1
  68. package/src/tools/nativeEngine.js +464 -0
  69. package/src/tools/nativeEngine.ts +433 -0
  70. package/src/tools/openSourceToolProvisioner.js +510 -0
  71. package/src/tools/openSourceToolProvisioner.ts +590 -0
  72. package/src/tools/peerAgent.js +102 -0
  73. package/src/tools/peerAgent.ts +116 -0
  74. package/src/tools/registry.js +6 -1
  75. package/src/tui/completion.js +98 -42
  76. package/src/tui/prompt.js +17 -17
  77. package/src/uncertainty.js +93 -205
  78. package/src/uncertainty.ts +255 -0
  79. package/src/utils/paths.js +15 -18
  80. package/src/utils/paths.ts +36 -0
  81. package/src/vfeTracker.js +122 -181
  82. package/src/vfeTracker.ts +242 -0
@@ -0,0 +1,265 @@
1
+ /*
2
+ * Copyright (c) 2026 Causyne.
3
+ * SPDX-License-Identifier: BUSL-1.1
4
+ *
5
+ * Causyne Document Forge Tool Wrapper.
6
+ * Bridges HTML/CSS-first publishing, headless PDF compilation, visual page QA,
7
+ * anti-slop compliance auditing, and Hollywood screenplay & shot list generation.
8
+ */
9
+
10
+ import fs from 'node:fs';
11
+ import path from 'node:path';
12
+ import {
13
+ compileDocumentHtml,
14
+ renderHtmlToPdf,
15
+ inspectPdfPages,
16
+ type FormalDocumentSpec
17
+ } from '../documentEngine/documentForge.js';
18
+ import {
19
+ formatScreenplayHtml,
20
+ formatShotListHtml,
21
+ analyzeVoiceOverTiming,
22
+ type ScreenplaySpec,
23
+ type ProductionShot,
24
+ type VoBlock
25
+ } from '../documentEngine/screenplayFormatter.js';
26
+ import {
27
+ auditTextContent,
28
+ auditBudgetArithmetic,
29
+ type ArithmeticBudgetSpec
30
+ } from '../documentEngine/antiSlopAuditor.js';
31
+ import { resolveUserPath } from '../utils/paths.js';
32
+
33
+ export interface DocumentForgeArgs {
34
+ action?:
35
+ | 'compile_document'
36
+ | 'render_pdf'
37
+ | 'inspect_pages'
38
+ | 'audit_text'
39
+ | 'audit_budget'
40
+ | 'format_screenplay'
41
+ | 'format_shotlist'
42
+ | 'analyze_vo';
43
+ documentSpec?: FormalDocumentSpec;
44
+ screenplaySpec?: ScreenplaySpec;
45
+ shotList?: { title: string; shots: ProductionShot[] };
46
+ voBlocks?: VoBlock[];
47
+ budgetSpec?: ArithmeticBudgetSpec;
48
+ textContent?: string;
49
+ sourceHtmlPath?: string;
50
+ outputPdfPath?: string;
51
+ outputPath?: string;
52
+ inspectImagesDir?: string;
53
+ }
54
+
55
+ export const documentForgeTool = {
56
+ schema: {
57
+ name: 'document_forge',
58
+ description: 'Causyne Document Forge: Professional document & media production harness. Generates pixel-perfect A4/Letter publications via HTML/CSS-First Paged Media and Headless Chrome, renders vector PDFs (<2MB compliant), extracts page images for visual QA ("Lihat Hasilnya"), audits anti-slop and math integrity, formats Hollywood Courier 12pt screenplays, creates production shot lists, and times VO narration.',
59
+ parameters: {
60
+ type: 'object',
61
+ properties: {
62
+ action: {
63
+ type: 'string',
64
+ enum: [
65
+ 'compile_document',
66
+ 'render_pdf',
67
+ 'inspect_pages',
68
+ 'audit_text',
69
+ 'audit_budget',
70
+ 'format_screenplay',
71
+ 'format_shotlist',
72
+ 'analyze_vo'
73
+ ],
74
+ description: 'Action to execute.'
75
+ },
76
+ documentSpec: {
77
+ type: 'object',
78
+ properties: {
79
+ title: { type: 'string' },
80
+ subtitle: { type: 'string' },
81
+ categoryOrKicker: { type: 'string' },
82
+ authorOrProposer: { type: 'string' },
83
+ palette: { type: 'string', enum: ['corporate', 'editorial_dair', 'minimal_clean'] },
84
+ includeCover: { type: 'boolean' }
85
+ },
86
+ description: 'Formal publication spec with sections, tables, and palette (corporate, editorial_dair, minimal_clean).'
87
+ },
88
+ screenplaySpec: {
89
+ type: 'object',
90
+ properties: {
91
+ title: { type: 'string' },
92
+ author: { type: 'string' },
93
+ contact: { type: 'string' }
94
+ },
95
+ description: 'Hollywood screenplay spec with scene headings, action, characters, dialogue, and transitions.'
96
+ },
97
+ shotList: {
98
+ type: 'object',
99
+ properties: {
100
+ title: { type: 'string' },
101
+ shots: {
102
+ type: 'array',
103
+ items: {
104
+ type: 'object',
105
+ properties: {
106
+ shotNumber: { type: 'number' },
107
+ framing: { type: 'string' },
108
+ subject: { type: 'string' },
109
+ action: { type: 'string' },
110
+ durationSeconds: { type: 'number' }
111
+ }
112
+ }
113
+ }
114
+ },
115
+ description: 'Director production shot list with framing, lenses, camera movements, and audio cues.'
116
+ },
117
+ voBlocks: {
118
+ type: 'array',
119
+ items: {
120
+ type: 'object',
121
+ properties: {
122
+ id: { type: 'string' },
123
+ timecode: { type: 'string' },
124
+ text: { type: 'string' },
125
+ targetDurationSeconds: { type: 'number' }
126
+ }
127
+ },
128
+ description: 'Voiceover blocks with timecode and target durations for WPM pacing analysis.'
129
+ },
130
+ budgetSpec: {
131
+ type: 'object',
132
+ properties: {
133
+ grossUpTaxRate: { type: 'number' },
134
+ targetGross: { type: 'number' }
135
+ },
136
+ description: 'Budget specification for arithmetic validation and tax gross-up verification.'
137
+ },
138
+ textContent: {
139
+ type: 'string',
140
+ description: 'Raw text or HTML content to audit for AI tropes, long em-dashes, and placeholder brackets.'
141
+ },
142
+ sourceHtmlPath: {
143
+ type: 'string',
144
+ description: 'Path to HTML file to render into PDF via Headless Chrome.'
145
+ },
146
+ outputPdfPath: {
147
+ type: 'string',
148
+ description: 'Destination PDF file path.'
149
+ },
150
+ outputPath: {
151
+ type: 'string',
152
+ description: 'Destination HTML or JSON output file path.'
153
+ },
154
+ inspectImagesDir: {
155
+ type: 'string',
156
+ description: 'Directory to save extracted page images for visual inspection.'
157
+ }
158
+ }
159
+ }
160
+ },
161
+
162
+ async execute(args: DocumentForgeArgs = {}, _context: any = {}): Promise<{ success: boolean; [key: string]: any }> {
163
+ const action = args.action || 'compile_document';
164
+
165
+ switch (action) {
166
+ case 'compile_document': {
167
+ if (!args.documentSpec) {
168
+ return { success: false, error: 'compile_document requires documentSpec.' };
169
+ }
170
+ const compiled = compileDocumentHtml(args.documentSpec);
171
+ if (args.outputPath) {
172
+ const target = resolveUserPath(args.outputPath);
173
+ fs.mkdirSync(path.dirname(target), { recursive: true });
174
+ fs.writeFileSync(target, compiled.html, 'utf8');
175
+ }
176
+ return {
177
+ success: true,
178
+ html: compiled.html,
179
+ outputPath: args.outputPath ? resolveUserPath(args.outputPath) : undefined
180
+ };
181
+ }
182
+
183
+ case 'render_pdf': {
184
+ if (!args.sourceHtmlPath || !args.outputPdfPath) {
185
+ return { success: false, error: 'render_pdf requires sourceHtmlPath and outputPdfPath.' };
186
+ }
187
+ const src = resolveUserPath(args.sourceHtmlPath);
188
+ const out = resolveUserPath(args.outputPdfPath);
189
+ const res = await renderHtmlToPdf(src, out);
190
+ return res;
191
+ }
192
+
193
+ case 'inspect_pages': {
194
+ if (!args.outputPdfPath) {
195
+ return { success: false, error: 'inspect_pages requires outputPdfPath.' };
196
+ }
197
+ const pdf = resolveUserPath(args.outputPdfPath);
198
+ const imgDir = args.inspectImagesDir ? resolveUserPath(args.inspectImagesDir) : undefined;
199
+ const res = await inspectPdfPages(pdf, imgDir);
200
+ return res;
201
+ }
202
+
203
+ case 'audit_text': {
204
+ if (!args.textContent) {
205
+ return { success: false, error: 'audit_text requires textContent parameter.' };
206
+ }
207
+ const res = auditTextContent(args.textContent);
208
+ return { success: true, ...res };
209
+ }
210
+
211
+ case 'audit_budget': {
212
+ if (!args.budgetSpec) {
213
+ return { success: false, error: 'audit_budget requires budgetSpec parameter.' };
214
+ }
215
+ const res = auditBudgetArithmetic(args.budgetSpec);
216
+ return { success: true, ...res };
217
+ }
218
+
219
+ case 'format_screenplay': {
220
+ if (!args.screenplaySpec) {
221
+ return { success: false, error: 'format_screenplay requires screenplaySpec.' };
222
+ }
223
+ const formatted = formatScreenplayHtml(args.screenplaySpec);
224
+ if (args.outputPath) {
225
+ const target = resolveUserPath(args.outputPath);
226
+ fs.mkdirSync(path.dirname(target), { recursive: true });
227
+ fs.writeFileSync(target, formatted.html, 'utf8');
228
+ }
229
+ return {
230
+ success: true,
231
+ html: formatted.html,
232
+ outputPath: args.outputPath ? resolveUserPath(args.outputPath) : undefined
233
+ };
234
+ }
235
+
236
+ case 'format_shotlist': {
237
+ if (!args.shotList) {
238
+ return { success: false, error: 'format_shotlist requires shotList parameter.' };
239
+ }
240
+ const formatted = formatShotListHtml(args.shotList.title, args.shotList.shots);
241
+ if (args.outputPath) {
242
+ const target = resolveUserPath(args.outputPath);
243
+ fs.mkdirSync(path.dirname(target), { recursive: true });
244
+ fs.writeFileSync(target, formatted.html, 'utf8');
245
+ }
246
+ return {
247
+ success: true,
248
+ html: formatted.html,
249
+ outputPath: args.outputPath ? resolveUserPath(args.outputPath) : undefined
250
+ };
251
+ }
252
+
253
+ case 'analyze_vo': {
254
+ if (!args.voBlocks || !Array.isArray(args.voBlocks)) {
255
+ return { success: false, error: 'analyze_vo requires voBlocks array.' };
256
+ }
257
+ const res = analyzeVoiceOverTiming(args.voBlocks);
258
+ return { success: true, analysis: res };
259
+ }
260
+
261
+ default:
262
+ return { success: false, error: `Unsupported document_forge action: ${action}` };
263
+ }
264
+ }
265
+ };
@@ -119,7 +119,7 @@ async function routeMultimediaRequest(args, config, sandbox, tokenTracker) {
119
119
  return {
120
120
  success: true,
121
121
  mode: 'Fallback (Stage 2 / Stage 4 / Stage 5)',
122
- message: `User denied Stage 1 paid API switch ($${estimatedCost.toFixed(2)}). Stage 2 Fallback: Please invoke 'check_system_specs' right now. If RAM >= 8GB and Disk > 10GB, propose local processing via 'manage_local_ai_dependencies' (e.g., Kokoro TTS/diffusers/whisper.cpp). If hardware is insufficient or user prefers no local downloads, transition to Stage 4 (web_search for existing royalty-free assets) or Stage 5 (execute_procedural_media Mode A).`
122
+ message: `User denied Stage 1 paid API switch ($${estimatedCost.toFixed(2)}). Stage 2 Fallback: Please invoke 'open_source_tool_provisioner' (or 'check_system_specs') right now. It checks local hardware (RAM, Apple Silicon Metal/CUDA, disk space), discovers top open-source tools matching the intent (e.g., F5-TTS/Kokoro for voice cloning, Whisper for transcription), and provides compute specs with mandatory Human-In-The-Loop approval before installation.`
123
123
  };
124
124
  }
125
125
  }