astrocode-workflow 0.1.16 → 0.1.18
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/index.js +3 -3
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +2 -2
- package/dist/tools/workflow.d.ts +2 -0
- package/dist/tools/workflow.js +19 -4
- package/package.json +2 -2
- package/src/index.ts +3 -3
- package/src/tools/index.ts +5 -3
- package/src/tools/workflow.ts +23 -5
package/dist/index.js
CHANGED
|
@@ -29,7 +29,7 @@ const Astrocode = async (ctx) => {
|
|
|
29
29
|
ensureSchema(db, { allowAutoMigrate: pluginConfig.db.allow_auto_migrate, failOnDowngrade: pluginConfig.db.fail_on_downgrade });
|
|
30
30
|
// Database initialized successfully
|
|
31
31
|
configHandler = createConfigHandler({ pluginConfig });
|
|
32
|
-
tools = createAstroTools({ ctx, config: pluginConfig, db });
|
|
32
|
+
tools = createAstroTools({ ctx, config: pluginConfig, db, agents });
|
|
33
33
|
continuation = createContinuationEnforcer({ ctx, config: pluginConfig, db });
|
|
34
34
|
truncatorHook = createToolOutputTruncatorHook({ ctx, config: pluginConfig, db });
|
|
35
35
|
toasts = createToastManager({ ctx, throttleMs: pluginConfig.ui.toasts.throttle_ms });
|
|
@@ -44,7 +44,7 @@ const Astrocode = async (ctx) => {
|
|
|
44
44
|
// Create limited functionality
|
|
45
45
|
db = null;
|
|
46
46
|
configHandler = createConfigHandler({ pluginConfig });
|
|
47
|
-
tools = createAstroTools({ ctx, config: pluginConfig, db });
|
|
47
|
+
tools = createAstroTools({ ctx, config: pluginConfig, db, agents });
|
|
48
48
|
continuation = null;
|
|
49
49
|
truncatorHook = null;
|
|
50
50
|
toasts = null;
|
|
@@ -56,7 +56,7 @@ const Astrocode = async (ctx) => {
|
|
|
56
56
|
// Merge agents + slash commands into system config
|
|
57
57
|
config: configHandler,
|
|
58
58
|
// Register tools
|
|
59
|
-
tool:
|
|
59
|
+
tool: createAstroTools({ ctx, config: pluginConfig, db, agents }),
|
|
60
60
|
// Limit created subagents from spawning more subagents (OMO-style).
|
|
61
61
|
"tool.execute.before": async (input, output) => {
|
|
62
62
|
if (!pluginConfig.permissions.enforce_task_tool_restrictions)
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ToolDefinition } from "@opencode-ai/plugin/tool";
|
|
2
2
|
import type { AstrocodeConfig } from "../config/schema";
|
|
3
3
|
import type { SqliteDb } from "../state/db";
|
|
4
|
+
import { AgentConfig } from "@opencode-ai/sdk";
|
|
4
5
|
export declare function createAstroTools(opts: {
|
|
5
6
|
ctx: any;
|
|
6
7
|
config: AstrocodeConfig;
|
|
7
8
|
db: SqliteDb;
|
|
9
|
+
agents?: Record<string, AgentConfig>;
|
|
8
10
|
}): Record<string, ToolDefinition>;
|
package/dist/tools/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { createAstroArtifactPutTool, createAstroArtifactListTool, createAstroArt
|
|
|
9
9
|
import { createAstroInjectPutTool, createAstroInjectListTool, createAstroInjectSearchTool, createAstroInjectGetTool } from "./injects";
|
|
10
10
|
import { createAstroRepairTool } from "./repair";
|
|
11
11
|
export function createAstroTools(opts) {
|
|
12
|
-
const { ctx, config, db } = opts;
|
|
12
|
+
const { ctx, config, db, agents } = opts;
|
|
13
13
|
const hasDatabase = !!db;
|
|
14
14
|
const tools = {};
|
|
15
15
|
// Always available tools
|
|
@@ -27,7 +27,7 @@ export function createAstroTools(opts) {
|
|
|
27
27
|
tools.astro_spec_set = createAstroSpecSetTool({ ctx, config, db });
|
|
28
28
|
tools.astro_run_get = createAstroRunGetTool({ ctx, config, db });
|
|
29
29
|
tools.astro_run_abort = createAstroRunAbortTool({ ctx, config, db });
|
|
30
|
-
tools.astro_workflow_proceed = createAstroWorkflowProceedTool({ ctx, config, db });
|
|
30
|
+
tools.astro_workflow_proceed = createAstroWorkflowProceedTool({ ctx, config, db, agents });
|
|
31
31
|
tools.astro_stage_start = createAstroStageStartTool({ ctx, config, db });
|
|
32
32
|
tools.astro_stage_complete = createAstroStageCompleteTool({ ctx, config, db });
|
|
33
33
|
tools.astro_stage_fail = createAstroStageFailTool({ ctx, config, db });
|
package/dist/tools/workflow.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type ToolDefinition } from "@opencode-ai/plugin/tool";
|
|
2
2
|
import type { AstrocodeConfig } from "../config/schema";
|
|
3
3
|
import type { SqliteDb } from "../state/db";
|
|
4
|
+
import { AgentConfig } from "@opencode-ai/sdk";
|
|
4
5
|
export declare function createAstroWorkflowProceedTool(opts: {
|
|
5
6
|
ctx: any;
|
|
6
7
|
config: AstrocodeConfig;
|
|
7
8
|
db: SqliteDb;
|
|
9
|
+
agents?: Record<string, AgentConfig>;
|
|
8
10
|
}): ToolDefinition;
|
package/dist/tools/workflow.js
CHANGED
|
@@ -83,7 +83,7 @@ function buildDelegationPrompt(opts) {
|
|
|
83
83
|
].join("\n").trim();
|
|
84
84
|
}
|
|
85
85
|
export function createAstroWorkflowProceedTool(opts) {
|
|
86
|
-
const { ctx, config, db } = opts;
|
|
86
|
+
const { ctx, config, db, agents } = opts;
|
|
87
87
|
const toasts = createToastManager({ ctx, throttleMs: config.ui.toasts.throttle_ms });
|
|
88
88
|
return tool({
|
|
89
89
|
description: "Deterministic harness: advances the DB-driven pipeline by one step (or loops bounded). Stops when LLM work is required (delegation/await).",
|
|
@@ -134,15 +134,30 @@ export function createAstroWorkflowProceedTool(opts) {
|
|
|
134
134
|
console.log(`[Astrocode] Available agents:`, Object.keys(config.agent || {}));
|
|
135
135
|
// Validate agent availability with fallback chain
|
|
136
136
|
const systemConfig = config;
|
|
137
|
-
|
|
137
|
+
// Check both the system config agent map (if present) OR the local agents map passed to the tool
|
|
138
|
+
const agentExists = (name) => {
|
|
139
|
+
// Check local agents map first (populated from src/index.ts)
|
|
140
|
+
if (agents && agents[name]) {
|
|
141
|
+
console.log(`[Astrocode] Found agent ${name} in local agents map`);
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
// Check system config agent map
|
|
145
|
+
if (systemConfig.agent && systemConfig.agent[name]) {
|
|
146
|
+
console.log(`[Astrocode] Found agent ${name} in systemConfig.agent`);
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
console.log(`[Astrocode] Agent ${name} NOT found in local map (keys: ${Object.keys(agents || {}).join(",")}) or systemConfig`);
|
|
150
|
+
return false;
|
|
151
|
+
};
|
|
152
|
+
if (!agentExists(agentName)) {
|
|
138
153
|
console.warn(`[Astrocode] Agent ${agentName} not found in config. Falling back to General.`);
|
|
139
154
|
console.warn(`[Astrocode] Agent check: config.agent exists: ${!!systemConfig.agent}, agentName in config: ${systemConfig.agent ? agentName in systemConfig.agent : 'N/A'}`);
|
|
140
155
|
agentName = "General";
|
|
141
156
|
// Second fallback to orchestrator if General also unavailable
|
|
142
|
-
if (!
|
|
157
|
+
if (!agentExists(agentName)) {
|
|
143
158
|
console.warn(`[Astrocode] General agent also unavailable. Falling back to orchestrator.`);
|
|
144
159
|
agentName = config.agents?.orchestrator_name || "Astro";
|
|
145
|
-
if (!
|
|
160
|
+
if (!agentExists(agentName)) {
|
|
146
161
|
throw new Error(`Critical: No agents available for delegation. Primary: ${resolveAgentName(next.stage_key, config)}, General, Orchestrator: ${agentName}`);
|
|
147
162
|
}
|
|
148
163
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astrocode-workflow",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@opencode-ai/plugin": "^1.1.19",
|
|
20
20
|
"@opencode-ai/sdk": "^1.1.19",
|
|
21
|
-
"astrocode-workflow": "^0.1.
|
|
21
|
+
"astrocode-workflow": "^0.1.17",
|
|
22
22
|
"jsonc-parser": "^3.2.0",
|
|
23
23
|
"zod": "4.1.8"
|
|
24
24
|
},
|
package/src/index.ts
CHANGED
|
@@ -40,7 +40,7 @@ const Astrocode: Plugin = async (ctx) => {
|
|
|
40
40
|
|
|
41
41
|
// Database initialized successfully
|
|
42
42
|
configHandler = createConfigHandler({ pluginConfig });
|
|
43
|
-
tools = createAstroTools({ ctx, config: pluginConfig, db });
|
|
43
|
+
tools = createAstroTools({ ctx, config: pluginConfig, db, agents });
|
|
44
44
|
continuation = createContinuationEnforcer({ ctx, config: pluginConfig, db });
|
|
45
45
|
truncatorHook = createToolOutputTruncatorHook({ ctx, config: pluginConfig, db });
|
|
46
46
|
toasts = createToastManager({ ctx, throttleMs: pluginConfig.ui.toasts.throttle_ms });
|
|
@@ -57,7 +57,7 @@ const Astrocode: Plugin = async (ctx) => {
|
|
|
57
57
|
// Create limited functionality
|
|
58
58
|
db = null;
|
|
59
59
|
configHandler = createConfigHandler({ pluginConfig });
|
|
60
|
-
tools = createAstroTools({ ctx, config: pluginConfig, db });
|
|
60
|
+
tools = createAstroTools({ ctx, config: pluginConfig, db, agents });
|
|
61
61
|
continuation = null;
|
|
62
62
|
truncatorHook = null;
|
|
63
63
|
toasts = null;
|
|
@@ -73,7 +73,7 @@ const Astrocode: Plugin = async (ctx) => {
|
|
|
73
73
|
config: configHandler,
|
|
74
74
|
|
|
75
75
|
// Register tools
|
|
76
|
-
tool:
|
|
76
|
+
tool: createAstroTools({ ctx, config: pluginConfig, db, agents }),
|
|
77
77
|
|
|
78
78
|
// Limit created subagents from spawning more subagents (OMO-style).
|
|
79
79
|
"tool.execute.before": async (input: any, output: any) => {
|
package/src/tools/index.ts
CHANGED
|
@@ -13,8 +13,10 @@ import { createAstroArtifactPutTool, createAstroArtifactListTool, createAstroArt
|
|
|
13
13
|
import { createAstroInjectPutTool, createAstroInjectListTool, createAstroInjectSearchTool, createAstroInjectGetTool } from "./injects";
|
|
14
14
|
import { createAstroRepairTool } from "./repair";
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
import { AgentConfig } from "@opencode-ai/sdk";
|
|
17
|
+
|
|
18
|
+
export function createAstroTools(opts: { ctx: any; config: AstrocodeConfig; db: SqliteDb; agents?: Record<string, AgentConfig> }): Record<string, ToolDefinition> {
|
|
19
|
+
const { ctx, config, db, agents } = opts;
|
|
18
20
|
const hasDatabase = !!db;
|
|
19
21
|
|
|
20
22
|
const tools: Record<string, ToolDefinition> = {};
|
|
@@ -36,7 +38,7 @@ export function createAstroTools(opts: { ctx: any; config: AstrocodeConfig; db:
|
|
|
36
38
|
tools.astro_spec_set = createAstroSpecSetTool({ ctx, config, db });
|
|
37
39
|
tools.astro_run_get = createAstroRunGetTool({ ctx, config, db });
|
|
38
40
|
tools.astro_run_abort = createAstroRunAbortTool({ ctx, config, db });
|
|
39
|
-
tools.astro_workflow_proceed = createAstroWorkflowProceedTool({ ctx, config, db });
|
|
41
|
+
tools.astro_workflow_proceed = createAstroWorkflowProceedTool({ ctx, config, db, agents });
|
|
40
42
|
tools.astro_stage_start = createAstroStageStartTool({ ctx, config, db });
|
|
41
43
|
tools.astro_stage_complete = createAstroStageCompleteTool({ ctx, config, db });
|
|
42
44
|
tools.astro_stage_fail = createAstroStageFailTool({ ctx, config, db });
|
package/src/tools/workflow.ts
CHANGED
|
@@ -99,8 +99,10 @@ function buildDelegationPrompt(opts: {
|
|
|
99
99
|
].join("\n").trim();
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
import { AgentConfig } from "@opencode-ai/sdk";
|
|
103
|
+
|
|
104
|
+
export function createAstroWorkflowProceedTool(opts: { ctx: any; config: AstrocodeConfig; db: SqliteDb; agents?: Record<string, AgentConfig> }): ToolDefinition {
|
|
105
|
+
const { ctx, config, db, agents } = opts;
|
|
104
106
|
const toasts = createToastManager({ ctx, throttleMs: config.ui.toasts.throttle_ms });
|
|
105
107
|
|
|
106
108
|
return tool({
|
|
@@ -163,15 +165,31 @@ export function createAstroWorkflowProceedTool(opts: { ctx: any; config: Astroco
|
|
|
163
165
|
|
|
164
166
|
// Validate agent availability with fallback chain
|
|
165
167
|
const systemConfig = config as any;
|
|
166
|
-
|
|
168
|
+
// Check both the system config agent map (if present) OR the local agents map passed to the tool
|
|
169
|
+
const agentExists = (name: string) => {
|
|
170
|
+
// Check local agents map first (populated from src/index.ts)
|
|
171
|
+
if (agents && agents[name]) {
|
|
172
|
+
console.log(`[Astrocode] Found agent ${name} in local agents map`);
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
// Check system config agent map
|
|
176
|
+
if (systemConfig.agent && systemConfig.agent[name]) {
|
|
177
|
+
console.log(`[Astrocode] Found agent ${name} in systemConfig.agent`);
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
console.log(`[Astrocode] Agent ${name} NOT found in local map (keys: ${Object.keys(agents || {}).join(",")}) or systemConfig`);
|
|
181
|
+
return false;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
if (!agentExists(agentName)) {
|
|
167
185
|
console.warn(`[Astrocode] Agent ${agentName} not found in config. Falling back to General.`);
|
|
168
186
|
console.warn(`[Astrocode] Agent check: config.agent exists: ${!!systemConfig.agent}, agentName in config: ${systemConfig.agent ? agentName in systemConfig.agent : 'N/A'}`);
|
|
169
187
|
agentName = "General";
|
|
170
188
|
// Second fallback to orchestrator if General also unavailable
|
|
171
|
-
if (!
|
|
189
|
+
if (!agentExists(agentName)) {
|
|
172
190
|
console.warn(`[Astrocode] General agent also unavailable. Falling back to orchestrator.`);
|
|
173
191
|
agentName = config.agents?.orchestrator_name || "Astro";
|
|
174
|
-
if (!
|
|
192
|
+
if (!agentExists(agentName)) {
|
|
175
193
|
throw new Error(`Critical: No agents available for delegation. Primary: ${resolveAgentName(next.stage_key, config)}, General, Orchestrator: ${agentName}`);
|
|
176
194
|
}
|
|
177
195
|
}
|