astro-tractstack 2.2.0 → 2.2.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-tractstack",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "Astro integration for TractStack - the free web press by At Risk Media",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -162,6 +162,7 @@ export const Node = memo((props: NodeProps) => {
162
162
  <ConfigPanePanel
163
163
  nodeId={props.nodeId}
164
164
  isHtmlAstPane={isHtmlAstPane}
165
+ isSandboxMode={props.isSandboxMode || false}
165
166
  />
166
167
  <PanelVisibilityWrapper
167
168
  nodeId={props.nodeId}
@@ -203,12 +203,9 @@ const StoryKeepHeader = ({
203
203
  console.log('Total Nodes in Store:', allNodesArray.length);
204
204
  console.log('Full Nodes Map:', allNodesMap);
205
205
 
206
- // Specifically audit Creative Panes for large htmlAst payloads
207
- // Using type guards/property checks to handle the BaseNode vs PaneNode distinction
208
206
  const creativePanes = allNodesArray.filter(
209
207
  (n) => n.nodeType === 'Pane' && 'htmlAst' in n
210
208
  );
211
-
212
209
  if (creativePanes.length > 0) {
213
210
  console.group('Creative Panes Detail (htmlAst Audit)');
214
211
  creativePanes.forEach((pane) => {
@@ -229,7 +226,7 @@ const StoryKeepHeader = ({
229
226
  }}
230
227
  className="rounded-md bg-myblue px-3.5 py-1.5 font-action font-bold text-white hover:bg-myorange"
231
228
  >
232
- Inspect
229
+ Nodes Dump
233
230
  </button>
234
231
  )}
235
232
 
@@ -7,75 +7,13 @@ import SparklesIcon from '@heroicons/react/24/outline/SparklesIcon';
7
7
  import { getCtx } from '@/stores/nodes';
8
8
  import { selectionStore } from '@/stores/selection';
9
9
  import { renderedPreviews } from '@/stores/previews';
10
- import { sandboxTokenStore } from '@/stores/storykeep';
11
10
  import { AiDesignStep, type AiDesignConfig } from './steps/AiDesignStep';
12
11
  import { AiRefineDesignStep } from './steps/AiRefineDesignStep';
13
12
  import prompts from '@/constants/prompts.json';
14
- import { TractStackAPI } from '@/utils/api';
15
13
  import { parseAiPane } from '@/utils/compositor/aiPaneParser';
14
+ import { callAskLemurAPI } from '@/utils/compositor/aiGeneration';
16
15
  import type { PaneNode, TemplatePane } from '@/types/compositorTypes';
17
16
 
18
- const callAskLemurAPI = async (
19
- prompt: string,
20
- context: string,
21
- expectJson: boolean,
22
- isSandboxMode: boolean
23
- ): Promise<string> => {
24
- const tenantId =
25
- (window as any).TRACTSTACK_CONFIG?.tenantId ||
26
- import.meta.env.PUBLIC_TENANTID ||
27
- 'default';
28
- const api = new TractStackAPI(tenantId);
29
-
30
- const requestBody = {
31
- prompt,
32
- input_text: context,
33
- final_model: '',
34
- temperature: 0.5,
35
- max_tokens: 6000,
36
- };
37
-
38
- let resultData: any;
39
-
40
- if (isSandboxMode) {
41
- const token = sandboxTokenStore.get();
42
- const response = await fetch(`/api/sandbox`, {
43
- method: 'POST',
44
- headers: {
45
- 'Content-Type': 'application/json',
46
- 'X-Tenant-ID': tenantId,
47
- 'X-Sandbox-Token': token || '',
48
- },
49
- credentials: 'include',
50
- body: JSON.stringify({ action: 'askLemur', payload: requestBody }),
51
- });
52
-
53
- if (!response.ok) {
54
- const errorText = await response.text();
55
- throw new Error(`Sandbox API failed: ${response.status} ${errorText}`);
56
- }
57
-
58
- const json = await response.json();
59
- if (!json.success) {
60
- throw new Error(json.error || 'Sandbox generation failed');
61
- }
62
- resultData = json.data;
63
- } else {
64
- const response = await api.post('/api/v1/aai/askLemur', requestBody);
65
- if (!response.success || !response.data?.response) {
66
- throw new Error(response.error || 'AI generation failed');
67
- }
68
- resultData = response.data;
69
- }
70
-
71
- let raw = resultData.response;
72
- if (typeof raw === 'string') {
73
- if (raw.startsWith('```json')) raw = raw.slice(7, -3).trim();
74
- }
75
- if (expectJson && typeof raw === 'object') return JSON.stringify(raw);
76
- return raw;
77
- };
78
-
79
17
  interface AiRestylePaneModalProps {
80
18
  isSandboxMode?: boolean;
81
19
  }
@@ -149,12 +87,12 @@ export const AiRestylePaneModal = ({
149
87
  .replace('{{COPY_INPUT}}', 'A generic content section')
150
88
  .replace('{{LAYOUT_TYPE}}', 'Text Only');
151
89
 
152
- const resultStr = await callAskLemurAPI(
153
- formattedPrompt,
154
- shellPromptDetails.system || '',
155
- true,
156
- isSandboxMode
157
- );
90
+ const resultStr = await callAskLemurAPI({
91
+ prompt: formattedPrompt,
92
+ context: shellPromptDetails.system || '',
93
+ expectJson: true,
94
+ isSandboxMode,
95
+ });
158
96
 
159
97
  let dummyCopy: string | string[] = '';
160
98
  if (isGrid) {
@@ -92,8 +92,8 @@ export const AiCreativeDesignStep = ({
92
92
  context: systemPrompt,
93
93
  expectJson: false,
94
94
  isSandboxMode,
95
- maxTokens: 6000,
96
95
  temperature: 0.5,
96
+ maxTokens: 20000,
97
97
  });
98
98
 
99
99
  const htmlAst = await htmlToHtmlAst(rawHtml, '');
@@ -59,8 +59,8 @@ export const AiRefineDesignStep = ({
59
59
  context: systemPrompt,
60
60
  expectJson: false,
61
61
  isSandboxMode,
62
- maxTokens: 4000,
63
62
  temperature: 0.5,
63
+ maxTokens: 8000,
64
64
  });
65
65
 
66
66
  // 2. Generate AST immediately
@@ -15,7 +15,7 @@ export const callAskLemurAPI = async ({
15
15
  context,
16
16
  expectJson,
17
17
  isSandboxMode,
18
- maxTokens = 2000,
18
+ maxTokens = 5000,
19
19
  temperature = 0.5,
20
20
  }: AiGenerationOptions): Promise<string> => {
21
21
  const tenantId =