astrocode-workflow 0.1.57 → 0.1.58

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.
@@ -178,6 +178,11 @@ export declare const AstrocodeConfigSchema: z.ZodDefault<z.ZodObject<{
178
178
  type_allowlist: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
179
179
  max_per_turn: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
180
180
  }, z.core.$strip>>>;
181
+ debug: z.ZodOptional<z.ZodDefault<z.ZodObject<{
182
+ telemetry: z.ZodOptional<z.ZodDefault<z.ZodObject<{
183
+ enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
184
+ }, z.core.$strip>>>;
185
+ }, z.core.$strip>>>;
181
186
  }, z.core.$strip>>;
182
187
  export type AstrocodeConfig = z.infer<typeof AstrocodeConfigSchema>;
183
188
  export {};
@@ -170,6 +170,17 @@ const InjectSchema = z
170
170
  })
171
171
  .partial()
172
172
  .default({});
173
+ const DebugSchema = z
174
+ .object({
175
+ telemetry: z
176
+ .object({
177
+ enabled: z.boolean().default(false),
178
+ })
179
+ .partial()
180
+ .default({}),
181
+ })
182
+ .partial()
183
+ .default({});
173
184
  const UiSchema = z
174
185
  .object({
175
186
  toasts: ToastsSchema,
@@ -206,4 +217,5 @@ export const AstrocodeConfigSchema = z.object({
206
217
  git: GitSchema,
207
218
  ui: UiSchema,
208
219
  inject: InjectSchema,
220
+ debug: DebugSchema,
209
221
  }).partial().default({});
@@ -65,6 +65,7 @@ export function createInjectProvider(opts) {
65
65
  // Get allowlists from config or defaults
66
66
  const scopeAllowlist = config.inject?.scope_allowlist ?? ["repo", "global"];
67
67
  const typeAllowlist = config.inject?.type_allowlist ?? ["note", "policy"];
68
+ const EMIT_TELEMETRY = config.debug?.telemetry?.enabled ?? false;
68
69
  // Get diagnostic data
69
70
  const diagnostics = getInjectionDiagnostics(now, scopeAllowlist, typeAllowlist);
70
71
  const eligibleInjects = selectEligibleInjects(db, {
@@ -77,7 +78,10 @@ export function createInjectProvider(opts) {
77
78
  let skippedDeduped = 0;
78
79
  if (eligibleInjects.length === 0) {
79
80
  // Log when no injects are eligible
80
- console.log(`[Astrocode:inject] ${now} selected=${diagnostics.selected_eligible} injected=0 skipped={expired:${diagnostics.skipped.expired} scope:${diagnostics.skipped.scope} type:${diagnostics.skipped.type} deduped:0}`);
81
+ if (EMIT_TELEMETRY) {
82
+ // eslint-disable-next-line no-console
83
+ console.log(`[Astrocode:inject] ${now} selected=${diagnostics.selected_eligible} injected=0 skipped={expired:${diagnostics.skipped.expired} scope:${diagnostics.skipped.scope} type:${diagnostics.skipped.type} deduped:0}`);
84
+ }
81
85
  return;
82
86
  }
83
87
  // Inject each eligible inject, skipping recently injected ones
@@ -98,7 +102,10 @@ export function createInjectProvider(opts) {
98
102
  markInjected(inject.inject_id, nowMs);
99
103
  }
100
104
  // Log diagnostic summary
101
- console.log(`[Astrocode:inject] ${now} selected=${diagnostics.selected_eligible} injected=${injected} skipped={expired:${diagnostics.skipped.expired} scope:${diagnostics.skipped.scope} type:${diagnostics.skipped.type} deduped:${skippedDeduped}}`);
105
+ if (EMIT_TELEMETRY) {
106
+ // eslint-disable-next-line no-console
107
+ console.log(`[Astrocode:inject] ${now} selected=${diagnostics.selected_eligible} injected=${injected} skipped={expired:${diagnostics.skipped.expired} scope:${diagnostics.skipped.scope} type:${diagnostics.skipped.type} deduped:${skippedDeduped}}`);
108
+ }
102
109
  }
103
110
  // Public hook handlers
104
111
  return {
@@ -236,7 +236,10 @@ export function createAstroWorkflowProceedTool(opts) {
236
236
  withTx(db, () => {
237
237
  startStage(db, active.run_id, next.stage_key, { subagent_type: agentName });
238
238
  // Log delegation observability
239
- console.log(`[Astrocode:delegate] run_id=${active.run_id} stage=${next.stage_key} agent=${agentName} fallback=${agentName !== resolveAgentName(next.stage_key, config, agents) ? 'yes' : 'no'}`);
239
+ if (config.debug?.telemetry?.enabled) {
240
+ // eslint-disable-next-line no-console
241
+ console.log(`[Astrocode:delegate] run_id=${active.run_id} stage=${next.stage_key} agent=${agentName} fallback=${agentName !== resolveAgentName(next.stage_key, config, agents) ? 'yes' : 'no'}`);
242
+ }
240
243
  });
241
244
  if (config.ui.toasts.enabled && config.ui.toasts.show_stage_started) {
242
245
  await toasts.show({ title: "Astrocode", message: `Stage started: ${next.stage_key}`, variant: "info" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astrocode-workflow",
3
- "version": "0.1.57",
3
+ "version": "0.1.58",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -204,6 +204,18 @@ const InjectSchema = z
204
204
  .partial()
205
205
  .default({});
206
206
 
207
+ const DebugSchema = z
208
+ .object({
209
+ telemetry: z
210
+ .object({
211
+ enabled: z.boolean().default(false),
212
+ })
213
+ .partial()
214
+ .default({}),
215
+ })
216
+ .partial()
217
+ .default({});
218
+
207
219
  const UiSchema = z
208
220
  .object({
209
221
  toasts: ToastsSchema,
@@ -243,6 +255,7 @@ export const AstrocodeConfigSchema = z.object({
243
255
  git: GitSchema,
244
256
  ui: UiSchema,
245
257
  inject: InjectSchema,
258
+ debug: DebugSchema,
246
259
  }).partial().default({});
247
260
 
248
261
  export type AstrocodeConfig = z.infer<typeof AstrocodeConfigSchema>;
@@ -89,6 +89,7 @@ export function createInjectProvider(opts: {
89
89
  // Get allowlists from config or defaults
90
90
  const scopeAllowlist = config.inject?.scope_allowlist ?? ["repo", "global"];
91
91
  const typeAllowlist = config.inject?.type_allowlist ?? ["note", "policy"];
92
+ const EMIT_TELEMETRY = config.debug?.telemetry?.enabled ?? false;
92
93
 
93
94
  // Get diagnostic data
94
95
  const diagnostics = getInjectionDiagnostics(now, scopeAllowlist, typeAllowlist);
@@ -105,7 +106,10 @@ export function createInjectProvider(opts: {
105
106
 
106
107
  if (eligibleInjects.length === 0) {
107
108
  // Log when no injects are eligible
108
- console.log(`[Astrocode:inject] ${now} selected=${diagnostics.selected_eligible} injected=0 skipped={expired:${diagnostics.skipped.expired} scope:${diagnostics.skipped.scope} type:${diagnostics.skipped.type} deduped:0}`);
109
+ if (EMIT_TELEMETRY) {
110
+ // eslint-disable-next-line no-console
111
+ console.log(`[Astrocode:inject] ${now} selected=${diagnostics.selected_eligible} injected=0 skipped={expired:${diagnostics.skipped.expired} scope:${diagnostics.skipped.scope} type:${diagnostics.skipped.type} deduped:0}`);
112
+ }
109
113
  return;
110
114
  }
111
115
 
@@ -131,7 +135,10 @@ export function createInjectProvider(opts: {
131
135
  }
132
136
 
133
137
  // Log diagnostic summary
134
- console.log(`[Astrocode:inject] ${now} selected=${diagnostics.selected_eligible} injected=${injected} skipped={expired:${diagnostics.skipped.expired} scope:${diagnostics.skipped.scope} type:${diagnostics.skipped.type} deduped:${skippedDeduped}}`);
138
+ if (EMIT_TELEMETRY) {
139
+ // eslint-disable-next-line no-console
140
+ console.log(`[Astrocode:inject] ${now} selected=${diagnostics.selected_eligible} injected=${injected} skipped={expired:${diagnostics.skipped.expired} scope:${diagnostics.skipped.scope} type:${diagnostics.skipped.type} deduped:${skippedDeduped}}`);
141
+ }
135
142
  }
136
143
 
137
144
  // Public hook handlers
@@ -281,7 +281,10 @@ export function createAstroWorkflowProceedTool(opts: { ctx: any; config: Astroco
281
281
  startStage(db, active.run_id, next.stage_key, { subagent_type: agentName });
282
282
 
283
283
  // Log delegation observability
284
- console.log(`[Astrocode:delegate] run_id=${active.run_id} stage=${next.stage_key} agent=${agentName} fallback=${agentName !== resolveAgentName(next.stage_key, config, agents) ? 'yes' : 'no'}`);
284
+ if (config.debug?.telemetry?.enabled) {
285
+ // eslint-disable-next-line no-console
286
+ console.log(`[Astrocode:delegate] run_id=${active.run_id} stage=${next.stage_key} agent=${agentName} fallback=${agentName !== resolveAgentName(next.stage_key, config, agents) ? 'yes' : 'no'}`);
287
+ }
285
288
  });
286
289
 
287
290
  if (config.ui.toasts.enabled && config.ui.toasts.show_stage_started) {