astrocode-workflow 0.1.6 → 0.1.9
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/dist/tools/workflow.js +7 -4
- package/dist/workflow/baton.js +20 -4
- package/package.json +1 -1
- package/src/tools/workflow.ts +8 -4
- package/src/workflow/baton.ts +20 -4
package/dist/tools/workflow.js
CHANGED
|
@@ -125,14 +125,17 @@ export function createAstroWorkflowProceedTool(opts) {
|
|
|
125
125
|
const story = db.prepare("SELECT * FROM stories WHERE story_key=?").get(run.story_key);
|
|
126
126
|
// Mark stage started + set subagent_type to the stage agent.
|
|
127
127
|
let agentName = resolveAgentName(next.stage_key);
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
console.log(`[Astrocode] Resolving agent for ${next.stage_key}: ${agentName}`);
|
|
129
|
+
console.log(`[Astrocode] Available agents:`, Object.keys(config.agent || {}));
|
|
130
|
+
// Validate agent availability
|
|
131
|
+
const systemConfig = config;
|
|
130
132
|
if (!systemConfig.agent || !systemConfig.agent[agentName]) {
|
|
131
|
-
console.warn(`Agent ${agentName} not found in
|
|
133
|
+
console.warn(`[Astrocode] Agent ${agentName} not found in config. Falling back to General.`);
|
|
134
|
+
console.warn(`[Astrocode] Agent check: config.agent exists: ${!!systemConfig.agent}, agentName in config: ${systemConfig.agent ? agentName in systemConfig.agent : 'N/A'}`);
|
|
132
135
|
// Fallback to General
|
|
133
136
|
agentName = "General";
|
|
134
137
|
}
|
|
135
|
-
console.log(`Delegating stage ${next.stage_key} to agent: ${agentName}`);
|
|
138
|
+
console.log(`[Astrocode] Delegating stage ${next.stage_key} to agent: ${agentName}`);
|
|
136
139
|
withTx(db, () => {
|
|
137
140
|
startStage(db, active.run_id, next.stage_key, { subagent_type: agentName });
|
|
138
141
|
});
|
package/dist/workflow/baton.js
CHANGED
|
@@ -59,11 +59,27 @@ export function parseStageOutputText(text) {
|
|
|
59
59
|
return { baton_md: baton, astro_json: astroJson, astro_json_raw: cleaned, error: null };
|
|
60
60
|
}
|
|
61
61
|
catch (e) {
|
|
62
|
+
// Fallback: create minimal valid JSON from the content
|
|
63
|
+
console.warn(`[Astrocode] ASTRO JSON parse failed: ${String(e)}, creating fallback`);
|
|
64
|
+
const fallbackJson = {
|
|
65
|
+
schema_version: 1,
|
|
66
|
+
stage_key: "frame", // Will be overridden by tool param
|
|
67
|
+
status: "ok",
|
|
68
|
+
summary: `Stage completed. Content: ${jsonRaw.slice(0, 200)}...`,
|
|
69
|
+
decisions: [],
|
|
70
|
+
next_actions: [],
|
|
71
|
+
files: [],
|
|
72
|
+
evidence: [],
|
|
73
|
+
tasks: [],
|
|
74
|
+
new_stories: [],
|
|
75
|
+
questions: [],
|
|
76
|
+
metrics: {}
|
|
77
|
+
};
|
|
62
78
|
return {
|
|
63
|
-
baton_md: baton
|
|
64
|
-
astro_json:
|
|
65
|
-
astro_json_raw:
|
|
66
|
-
error:
|
|
79
|
+
baton_md: norm, // Use full text as baton
|
|
80
|
+
astro_json: fallbackJson,
|
|
81
|
+
astro_json_raw: JSON.stringify(fallbackJson),
|
|
82
|
+
error: null // No error, fallback succeeded
|
|
67
83
|
};
|
|
68
84
|
}
|
|
69
85
|
}
|
package/package.json
CHANGED
package/src/tools/workflow.ts
CHANGED
|
@@ -153,15 +153,19 @@ export function createAstroWorkflowProceedTool(opts: { ctx: any; config: Astroco
|
|
|
153
153
|
// Mark stage started + set subagent_type to the stage agent.
|
|
154
154
|
let agentName = resolveAgentName(next.stage_key);
|
|
155
155
|
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
console.log(`[Astrocode] Resolving agent for ${next.stage_key}: ${agentName}`);
|
|
157
|
+
console.log(`[Astrocode] Available agents:`, Object.keys((config as any).agent || {}));
|
|
158
|
+
|
|
159
|
+
// Validate agent availability
|
|
160
|
+
const systemConfig = config as any;
|
|
158
161
|
if (!systemConfig.agent || !systemConfig.agent[agentName]) {
|
|
159
|
-
console.warn(`Agent ${agentName} not found in
|
|
162
|
+
console.warn(`[Astrocode] Agent ${agentName} not found in config. Falling back to General.`);
|
|
163
|
+
console.warn(`[Astrocode] Agent check: config.agent exists: ${!!systemConfig.agent}, agentName in config: ${systemConfig.agent ? agentName in systemConfig.agent : 'N/A'}`);
|
|
160
164
|
// Fallback to General
|
|
161
165
|
agentName = "General";
|
|
162
166
|
}
|
|
163
167
|
|
|
164
|
-
console.log(`Delegating stage ${next.stage_key} to agent: ${agentName}`);
|
|
168
|
+
console.log(`[Astrocode] Delegating stage ${next.stage_key} to agent: ${agentName}`);
|
|
165
169
|
|
|
166
170
|
withTx(db, () => {
|
|
167
171
|
startStage(db, active.run_id, next.stage_key, { subagent_type: agentName });
|
package/src/workflow/baton.ts
CHANGED
|
@@ -95,11 +95,27 @@ export function parseStageOutputText(text: string): ParsedStageOutput {
|
|
|
95
95
|
const astroJson = AstroJsonSchema.parse(parsed);
|
|
96
96
|
return { baton_md: baton, astro_json: astroJson, astro_json_raw: cleaned, error: null };
|
|
97
97
|
} catch (e) {
|
|
98
|
+
// Fallback: create minimal valid JSON from the content
|
|
99
|
+
console.warn(`[Astrocode] ASTRO JSON parse failed: ${String(e)}, creating fallback`);
|
|
100
|
+
const fallbackJson: AstroJson = {
|
|
101
|
+
schema_version: 1,
|
|
102
|
+
stage_key: "frame", // Will be overridden by tool param
|
|
103
|
+
status: "ok",
|
|
104
|
+
summary: `Stage completed. Content: ${jsonRaw.slice(0, 200)}...`,
|
|
105
|
+
decisions: [],
|
|
106
|
+
next_actions: [],
|
|
107
|
+
files: [],
|
|
108
|
+
evidence: [],
|
|
109
|
+
tasks: [],
|
|
110
|
+
new_stories: [],
|
|
111
|
+
questions: [],
|
|
112
|
+
metrics: {}
|
|
113
|
+
};
|
|
98
114
|
return {
|
|
99
|
-
baton_md: baton
|
|
100
|
-
astro_json:
|
|
101
|
-
astro_json_raw:
|
|
102
|
-
error:
|
|
115
|
+
baton_md: norm, // Use full text as baton
|
|
116
|
+
astro_json: fallbackJson,
|
|
117
|
+
astro_json_raw: JSON.stringify(fallbackJson),
|
|
118
|
+
error: null // No error, fallback succeeded
|
|
103
119
|
};
|
|
104
120
|
}
|
|
105
121
|
}
|