squads-cli 0.2.0 → 0.2.1
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/README.md +521 -288
- package/dist/auth-YW3UPFSB.js +23 -0
- package/dist/auth-YW3UPFSB.js.map +1 -0
- package/dist/autonomy-PSVZVX7A.js +105 -0
- package/dist/autonomy-PSVZVX7A.js.map +1 -0
- package/dist/chunk-67RO2HKR.js +174 -0
- package/dist/chunk-67RO2HKR.js.map +1 -0
- package/dist/chunk-7OCVIDC7.js +12 -0
- package/dist/chunk-7OCVIDC7.js.map +1 -0
- package/dist/chunk-BODLDQY7.js +452 -0
- package/dist/chunk-BODLDQY7.js.map +1 -0
- package/dist/chunk-EHQJHRIW.js +103 -0
- package/dist/chunk-EHQJHRIW.js.map +1 -0
- package/dist/chunk-FFFCFZ6A.js +121 -0
- package/dist/chunk-FFFCFZ6A.js.map +1 -0
- package/dist/chunk-FIWT2NMM.js +165 -0
- package/dist/chunk-FIWT2NMM.js.map +1 -0
- package/dist/chunk-HF4WR7RA.js +154 -0
- package/dist/chunk-HF4WR7RA.js.map +1 -0
- package/dist/chunk-J6QF4ZQX.js +230 -0
- package/dist/chunk-J6QF4ZQX.js.map +1 -0
- package/dist/chunk-LOA3KWYJ.js +294 -0
- package/dist/chunk-LOA3KWYJ.js.map +1 -0
- package/dist/chunk-M5FXNY6Y.js +384 -0
- package/dist/chunk-M5FXNY6Y.js.map +1 -0
- package/dist/chunk-QHNUMM4V.js +87 -0
- package/dist/chunk-QHNUMM4V.js.map +1 -0
- package/dist/chunk-QJ7C7CMB.js +223 -0
- package/dist/chunk-QJ7C7CMB.js.map +1 -0
- package/dist/chunk-RM6BWILN.js +74 -0
- package/dist/chunk-RM6BWILN.js.map +1 -0
- package/dist/chunk-TYFTF53O.js +613 -0
- package/dist/chunk-TYFTF53O.js.map +1 -0
- package/dist/chunk-TZXD6WFN.js +420 -0
- package/dist/chunk-TZXD6WFN.js.map +1 -0
- package/dist/chunk-WVOIY5GW.js +621 -0
- package/dist/chunk-WVOIY5GW.js.map +1 -0
- package/dist/chunk-Z2UKDBNL.js +162 -0
- package/dist/chunk-Z2UKDBNL.js.map +1 -0
- package/dist/chunk-ZTQ7ISUR.js +338 -0
- package/dist/chunk-ZTQ7ISUR.js.map +1 -0
- package/dist/cli.js +2483 -5902
- package/dist/cli.js.map +1 -1
- package/dist/context-GWPF4SEY.js +291 -0
- package/dist/context-GWPF4SEY.js.map +1 -0
- package/dist/context-feed-AJGVAR6H.js +394 -0
- package/dist/context-feed-AJGVAR6H.js.map +1 -0
- package/dist/cost-XBCDJ7XC.js +275 -0
- package/dist/cost-XBCDJ7XC.js.map +1 -0
- package/dist/create-BLFGG6PF.js +286 -0
- package/dist/create-BLFGG6PF.js.map +1 -0
- package/dist/dashboard-LGT2B2BL.js +951 -0
- package/dist/dashboard-LGT2B2BL.js.map +1 -0
- package/dist/dashboard-RMK2BOD2.js +794 -0
- package/dist/dashboard-RMK2BOD2.js.map +1 -0
- package/dist/doctor-XPUIIBHJ.js +374 -0
- package/dist/doctor-XPUIIBHJ.js.map +1 -0
- package/dist/env-config-SQEI3Y7Y.js +21 -0
- package/dist/env-config-SQEI3Y7Y.js.map +1 -0
- package/dist/exec-OUXM7JBF.js +223 -0
- package/dist/exec-OUXM7JBF.js.map +1 -0
- package/dist/feedback-KNAOG5QK.js +229 -0
- package/dist/feedback-KNAOG5QK.js.map +1 -0
- package/dist/github-UQTM5KMS.js +23 -0
- package/dist/github-UQTM5KMS.js.map +1 -0
- package/dist/goal-BVHV5573.js +168 -0
- package/dist/goal-BVHV5573.js.map +1 -0
- package/dist/health-4UXN44PF.js +218 -0
- package/dist/health-4UXN44PF.js.map +1 -0
- package/dist/history-ILH3SWHB.js +232 -0
- package/dist/history-ILH3SWHB.js.map +1 -0
- package/dist/index.d.ts +736 -8
- package/dist/index.js +1312 -6
- package/dist/index.js.map +1 -1
- package/dist/init-XQZ7BOGT.js +812 -0
- package/dist/init-XQZ7BOGT.js.map +1 -0
- package/dist/kpi-RQIU7WGK.js +413 -0
- package/dist/kpi-RQIU7WGK.js.map +1 -0
- package/dist/learn-OIFUVZAS.js +269 -0
- package/dist/learn-OIFUVZAS.js.map +1 -0
- package/dist/login-DXZANWZY.js +155 -0
- package/dist/login-DXZANWZY.js.map +1 -0
- package/dist/memory-T3ACCS7E.js +560 -0
- package/dist/memory-T3ACCS7E.js.map +1 -0
- package/dist/memory-VNF2VFRB.js +23 -0
- package/dist/memory-VNF2VFRB.js.map +1 -0
- package/dist/progress-DAUZMT3N.js +202 -0
- package/dist/progress-DAUZMT3N.js.map +1 -0
- package/dist/providers-3P5D2XL5.js +65 -0
- package/dist/providers-3P5D2XL5.js.map +1 -0
- package/dist/results-UECWGLTB.js +224 -0
- package/dist/results-UECWGLTB.js.map +1 -0
- package/dist/run-I6KAXU6U.js +4049 -0
- package/dist/run-I6KAXU6U.js.map +1 -0
- package/dist/session-HBU6KZOD.js +64 -0
- package/dist/session-HBU6KZOD.js.map +1 -0
- package/dist/sessions-CK25VGPL.js +333 -0
- package/dist/sessions-CK25VGPL.js.map +1 -0
- package/dist/squad-parser-DCG65BJS.js +35 -0
- package/dist/squad-parser-DCG65BJS.js.map +1 -0
- package/dist/stats-G6NAU5BD.js +334 -0
- package/dist/stats-G6NAU5BD.js.map +1 -0
- package/dist/status-AQNLDZVN.js +352 -0
- package/dist/status-AQNLDZVN.js.map +1 -0
- package/dist/sync-ZI3MHA4G.js +836 -0
- package/dist/sync-ZI3MHA4G.js.map +1 -0
- package/dist/templates/core/AGENTS.md.template +51 -0
- package/dist/templates/core/BUSINESS_BRIEF.md.template +29 -0
- package/dist/templates/core/CLAUDE.md.template +48 -0
- package/dist/templates/core/provider.yaml.template +5 -0
- package/dist/templates/first-squad/SQUAD.md.template +23 -0
- package/dist/templates/first-squad/lead.md.template +44 -0
- package/dist/templates/memory/getting-started/state.md.template +19 -0
- package/dist/templates/seed/BUSINESS_BRIEF.md.template +27 -0
- package/dist/templates/seed/CLAUDE.md.template +119 -0
- package/dist/templates/seed/README.md.template +42 -0
- package/dist/templates/seed/config/SYSTEM.md +52 -0
- package/dist/templates/seed/config/provider.yaml +4 -0
- package/dist/templates/seed/hooks/settings.json.template +31 -0
- package/dist/templates/seed/memory/company/directives.md +37 -0
- package/dist/templates/seed/memory/company/manager/state.md +16 -0
- package/dist/templates/seed/memory/engineering/issue-solver/state.md +12 -0
- package/dist/templates/seed/memory/intelligence/intel-lead/state.md +9 -0
- package/dist/templates/seed/memory/marketing/content-drafter/state.md +12 -0
- package/dist/templates/seed/memory/operations/ops-lead/state.md +12 -0
- package/dist/templates/seed/memory/product/lead/state.md +14 -0
- package/dist/templates/seed/memory/research/lead/state.md +14 -0
- package/dist/templates/seed/skills/gh/SKILL.md +57 -0
- package/dist/templates/seed/skills/squads-cli/SKILL.md +84 -0
- package/dist/templates/seed/squads/company/SQUAD.md +51 -0
- package/dist/templates/seed/squads/company/company-critic.md +49 -0
- package/dist/templates/seed/squads/company/company-eval.md +49 -0
- package/dist/templates/seed/squads/company/event-dispatcher.md +43 -0
- package/dist/templates/seed/squads/company/goal-tracker.md +43 -0
- package/dist/templates/seed/squads/company/manager.md +54 -0
- package/dist/templates/seed/squads/engineering/SQUAD.md +48 -0
- package/dist/templates/seed/squads/engineering/code-reviewer.md +57 -0
- package/dist/templates/seed/squads/engineering/issue-solver.md +58 -0
- package/dist/templates/seed/squads/engineering/test-writer.md +50 -0
- package/dist/templates/seed/squads/intelligence/SQUAD.md +38 -0
- package/dist/templates/seed/squads/intelligence/intel-critic.md +36 -0
- package/dist/templates/seed/squads/intelligence/intel-eval.md +31 -0
- package/dist/templates/seed/squads/intelligence/intel-lead.md +71 -0
- package/dist/templates/seed/squads/marketing/SQUAD.md +47 -0
- package/dist/templates/seed/squads/marketing/content-drafter.md +71 -0
- package/dist/templates/seed/squads/marketing/growth-analyst.md +49 -0
- package/dist/templates/seed/squads/marketing/social-poster.md +44 -0
- package/dist/templates/seed/squads/operations/SQUAD.md +45 -0
- package/dist/templates/seed/squads/operations/finance-tracker.md +47 -0
- package/dist/templates/seed/squads/operations/goal-tracker.md +48 -0
- package/dist/templates/seed/squads/operations/ops-lead.md +58 -0
- package/dist/templates/seed/squads/product/SQUAD.md +41 -0
- package/dist/templates/seed/squads/product/lead.md +56 -0
- package/dist/templates/seed/squads/product/scanner.md +50 -0
- package/dist/templates/seed/squads/product/worker.md +55 -0
- package/dist/templates/seed/squads/research/SQUAD.md +38 -0
- package/dist/templates/seed/squads/research/analyst.md +50 -0
- package/dist/templates/seed/squads/research/lead.md +52 -0
- package/dist/templates/seed/squads/research/synthesizer.md +59 -0
- package/dist/templates/skills/squads-learn/SKILL.md +86 -0
- package/dist/templates/skills/squads-workflow/instruction.md +70 -0
- package/dist/terminal-FBQFQTKZ.js +55 -0
- package/dist/terminal-FBQFQTKZ.js.map +1 -0
- package/dist/update-D7CGIZ3M.js +18 -0
- package/dist/update-D7CGIZ3M.js.map +1 -0
- package/dist/update-STU276HR.js +83 -0
- package/dist/update-STU276HR.js.map +1 -0
- package/package.json +31 -13
- package/templates/core/AGENTS.md.template +51 -0
- package/templates/core/BUSINESS_BRIEF.md.template +29 -0
- package/templates/core/CLAUDE.md.template +48 -0
- package/templates/core/provider.yaml.template +5 -0
- package/templates/first-squad/SQUAD.md.template +23 -0
- package/templates/first-squad/lead.md.template +44 -0
- package/templates/memory/getting-started/state.md.template +19 -0
- package/templates/seed/BUSINESS_BRIEF.md.template +27 -0
- package/templates/seed/CLAUDE.md.template +119 -0
- package/templates/seed/README.md.template +42 -0
- package/templates/seed/config/SYSTEM.md +52 -0
- package/templates/seed/config/provider.yaml +4 -0
- package/templates/seed/hooks/settings.json.template +31 -0
- package/templates/seed/memory/company/directives.md +37 -0
- package/templates/seed/memory/company/manager/state.md +16 -0
- package/templates/seed/memory/engineering/issue-solver/state.md +12 -0
- package/templates/seed/memory/intelligence/intel-lead/state.md +9 -0
- package/templates/seed/memory/marketing/content-drafter/state.md +12 -0
- package/templates/seed/memory/operations/ops-lead/state.md +12 -0
- package/templates/seed/memory/product/lead/state.md +14 -0
- package/templates/seed/memory/research/lead/state.md +14 -0
- package/templates/seed/skills/gh/SKILL.md +57 -0
- package/templates/seed/skills/squads-cli/SKILL.md +84 -0
- package/templates/seed/squads/company/SQUAD.md +51 -0
- package/templates/seed/squads/company/company-critic.md +49 -0
- package/templates/seed/squads/company/company-eval.md +49 -0
- package/templates/seed/squads/company/event-dispatcher.md +43 -0
- package/templates/seed/squads/company/goal-tracker.md +43 -0
- package/templates/seed/squads/company/manager.md +54 -0
- package/templates/seed/squads/engineering/SQUAD.md +48 -0
- package/templates/seed/squads/engineering/code-reviewer.md +57 -0
- package/templates/seed/squads/engineering/issue-solver.md +58 -0
- package/templates/seed/squads/engineering/test-writer.md +50 -0
- package/templates/seed/squads/intelligence/SQUAD.md +38 -0
- package/templates/seed/squads/intelligence/intel-critic.md +36 -0
- package/templates/seed/squads/intelligence/intel-eval.md +31 -0
- package/templates/seed/squads/intelligence/intel-lead.md +71 -0
- package/templates/seed/squads/marketing/SQUAD.md +47 -0
- package/templates/seed/squads/marketing/content-drafter.md +71 -0
- package/templates/seed/squads/marketing/growth-analyst.md +49 -0
- package/templates/seed/squads/marketing/social-poster.md +44 -0
- package/templates/seed/squads/operations/SQUAD.md +45 -0
- package/templates/seed/squads/operations/finance-tracker.md +47 -0
- package/templates/seed/squads/operations/goal-tracker.md +48 -0
- package/templates/seed/squads/operations/ops-lead.md +58 -0
- package/templates/seed/squads/product/SQUAD.md +41 -0
- package/templates/seed/squads/product/lead.md +56 -0
- package/templates/seed/squads/product/scanner.md +50 -0
- package/templates/seed/squads/product/worker.md +55 -0
- package/templates/seed/squads/research/SQUAD.md +38 -0
- package/templates/seed/squads/research/analyst.md +50 -0
- package/templates/seed/squads/research/lead.md +52 -0
- package/templates/seed/squads/research/synthesizer.md +59 -0
- package/templates/skills/squads-learn/SKILL.md +86 -0
- package/templates/skills/squads-workflow/instruction.md +70 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
clearSession,
|
|
4
|
+
getEmailDomain,
|
|
5
|
+
isLoggedIn,
|
|
6
|
+
isPersonalEmail,
|
|
7
|
+
loadSession,
|
|
8
|
+
saveSession,
|
|
9
|
+
startAuthCallbackServer,
|
|
10
|
+
verifyToken
|
|
11
|
+
} from "./chunk-Z2UKDBNL.js";
|
|
12
|
+
import "./chunk-7OCVIDC7.js";
|
|
13
|
+
export {
|
|
14
|
+
clearSession,
|
|
15
|
+
getEmailDomain,
|
|
16
|
+
isLoggedIn,
|
|
17
|
+
isPersonalEmail,
|
|
18
|
+
loadSession,
|
|
19
|
+
saveSession,
|
|
20
|
+
startAuthCallbackServer,
|
|
21
|
+
verifyToken
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=auth-YW3UPFSB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
getEnv
|
|
4
|
+
} from "./chunk-EHQJHRIW.js";
|
|
5
|
+
import {
|
|
6
|
+
Events,
|
|
7
|
+
track
|
|
8
|
+
} from "./chunk-QJ7C7CMB.js";
|
|
9
|
+
import {
|
|
10
|
+
RESET,
|
|
11
|
+
bold,
|
|
12
|
+
colors,
|
|
13
|
+
gradient,
|
|
14
|
+
icons,
|
|
15
|
+
writeLine
|
|
16
|
+
} from "./chunk-M5FXNY6Y.js";
|
|
17
|
+
import "./chunk-7OCVIDC7.js";
|
|
18
|
+
|
|
19
|
+
// src/commands/autonomy.ts
|
|
20
|
+
async function autonomyCommand(options = {}) {
|
|
21
|
+
const bridgeUrl = getEnv().bridge_url;
|
|
22
|
+
const period = options.period || "today";
|
|
23
|
+
await track(Events.CLI_STATUS, { command: "autonomy", period, squad: options.squad });
|
|
24
|
+
try {
|
|
25
|
+
const params = new URLSearchParams({ period });
|
|
26
|
+
if (options.squad) params.append("squad", options.squad);
|
|
27
|
+
const response = await fetch(`${bridgeUrl}/api/autonomy/score?${params}`);
|
|
28
|
+
const data = await response.json();
|
|
29
|
+
if (options.json) {
|
|
30
|
+
console.log(JSON.stringify(data, null, 2));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
writeLine();
|
|
34
|
+
writeLine(` ${gradient("squads")} ${colors.dim}autonomy${RESET}`);
|
|
35
|
+
writeLine();
|
|
36
|
+
const score = data.overall_score;
|
|
37
|
+
const confidence = data.confidence_level;
|
|
38
|
+
const scoreColor = score >= 75 ? colors.green : score >= 50 ? colors.yellow : colors.red;
|
|
39
|
+
const confidenceIcon = confidence === "high" ? icons.success : confidence === "medium" ? icons.warning : icons.error;
|
|
40
|
+
writeLine(` ${bold}Overall Score${RESET} ${scoreColor}${score}%${RESET} ${confidenceIcon} ${confidence} confidence`);
|
|
41
|
+
writeLine();
|
|
42
|
+
const barWidth = 40;
|
|
43
|
+
const filled = Math.round(score / 100 * barWidth);
|
|
44
|
+
const bar = `${scoreColor}${"\u2588".repeat(filled)}${colors.dim}${"\u2591".repeat(barWidth - filled)}${RESET}`;
|
|
45
|
+
writeLine(` ${bar}`);
|
|
46
|
+
writeLine();
|
|
47
|
+
writeLine(` ${bold}Components${RESET}`);
|
|
48
|
+
writeLine();
|
|
49
|
+
const components = [
|
|
50
|
+
{ name: "Quota Compliance", score: data.components.quota_compliance, weight: "25%" },
|
|
51
|
+
{ name: "Success Rate", score: data.components.success_rate, weight: "25%" },
|
|
52
|
+
{ name: "Quality Score", score: data.components.quality_score, weight: "20%" },
|
|
53
|
+
{ name: "Cooldown Compliance", score: data.components.cooldown_compliance, weight: "15%" },
|
|
54
|
+
{ name: "Learning Utilization", score: data.components.learning_utilization, weight: "15%" }
|
|
55
|
+
];
|
|
56
|
+
for (const comp of components) {
|
|
57
|
+
const compColor = comp.score >= 75 ? colors.green : comp.score >= 50 ? colors.yellow : colors.red;
|
|
58
|
+
const compBar = `${compColor}${"\u2588".repeat(Math.round(comp.score / 5))}${colors.dim}${"\u2591".repeat(20 - Math.round(comp.score / 5))}${RESET}`;
|
|
59
|
+
writeLine(` ${comp.name.padEnd(22)} ${compBar} ${compColor}${comp.score}%${RESET} ${colors.dim}(${comp.weight})${RESET}`);
|
|
60
|
+
}
|
|
61
|
+
writeLine();
|
|
62
|
+
writeLine(` ${bold}Stats${RESET} ${colors.dim}(${period})${RESET}`);
|
|
63
|
+
writeLine();
|
|
64
|
+
writeLine(` ${colors.dim}Tasks:${RESET} ${data.execution_stats.successful_tasks}/${data.execution_stats.total_tasks} successful`);
|
|
65
|
+
writeLine(` ${colors.dim}Quota:${RESET} $${data.execution_stats.monthly_used}/$${data.execution_stats.monthly_quota}/mo (${data.execution_stats.quota_pct}%)`);
|
|
66
|
+
writeLine(` ${colors.dim}Learnings:${RESET} ${data.execution_stats.learning_count} captured`);
|
|
67
|
+
if (options.squad) {
|
|
68
|
+
writeLine(` ${colors.dim}Squad:${RESET} ${options.squad}`);
|
|
69
|
+
}
|
|
70
|
+
writeLine();
|
|
71
|
+
if (score < 75) {
|
|
72
|
+
writeLine(` ${bold}Recommendations${RESET}`);
|
|
73
|
+
writeLine();
|
|
74
|
+
if (data.components.learning_utilization < 50) {
|
|
75
|
+
writeLine(` ${icons.empty} Capture more learnings: ${colors.dim}squads learn "..."${RESET}`);
|
|
76
|
+
}
|
|
77
|
+
if (data.components.quality_score < 70) {
|
|
78
|
+
writeLine(` ${icons.empty} Add feedback after runs: ${colors.dim}squads feedback add <squad> <1-5>${RESET}`);
|
|
79
|
+
}
|
|
80
|
+
if (data.components.quota_compliance < 80) {
|
|
81
|
+
writeLine(` ${icons.empty} Approaching monthly quota limit - consider upgrading plan`);
|
|
82
|
+
}
|
|
83
|
+
if (data.execution_stats.total_tasks === 0) {
|
|
84
|
+
writeLine(` ${icons.empty} Run some agents: ${colors.dim}squads run <squad> --execute${RESET}`);
|
|
85
|
+
}
|
|
86
|
+
writeLine();
|
|
87
|
+
}
|
|
88
|
+
writeLine(` ${colors.dim}$${RESET} squads autonomy --period=week ${colors.dim}Weekly view${RESET}`);
|
|
89
|
+
writeLine(` ${colors.dim}$${RESET} squads memory sync --dimensions ${colors.dim}Sync to Postgres${RESET}`);
|
|
90
|
+
writeLine();
|
|
91
|
+
} catch (error) {
|
|
92
|
+
writeLine();
|
|
93
|
+
writeLine(` ${gradient("squads")} ${colors.dim}autonomy${RESET}`);
|
|
94
|
+
writeLine();
|
|
95
|
+
writeLine(` ${icons.error} ${colors.red}Failed to fetch autonomy score${RESET}`);
|
|
96
|
+
writeLine(` ${colors.dim}${error}${RESET}`);
|
|
97
|
+
writeLine();
|
|
98
|
+
writeLine(` ${colors.dim}API unavailable. Run \`squads login\` to connect.${RESET}`);
|
|
99
|
+
writeLine();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
autonomyCommand
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=autonomy-PSVZVX7A.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/autonomy.ts"],"sourcesContent":["import {\n colors,\n RESET,\n gradient,\n icons,\n writeLine,\n bold,\n} from '../lib/terminal.js';\nimport { track, Events } from '../lib/telemetry.js';\nimport { getEnv } from '../lib/env-config.js';\n\ninterface AutonomyOptions {\n squad?: string;\n period?: 'today' | 'week' | 'month';\n json?: boolean;\n}\n\ninterface AutonomyScore {\n overall_score: number;\n confidence_level: string;\n period: string;\n squad: string | null;\n components: {\n quota_compliance: number;\n cooldown_compliance: number;\n quality_score: number;\n success_rate: number;\n learning_utilization: number;\n };\n execution_stats: {\n total_tasks: number;\n successful_tasks: number;\n monthly_used: number;\n monthly_quota: number;\n quota_pct: number;\n learning_count: number;\n };\n error?: string;\n}\n\n/**\n * Display autonomy score and confidence metrics.\n * Shows how ready the system is for autonomous operation.\n */\nexport async function autonomyCommand(options: AutonomyOptions = {}): Promise<void> {\n const bridgeUrl = getEnv().bridge_url;\n const period = options.period || 'today';\n\n await track(Events.CLI_STATUS, { command: 'autonomy', period, squad: options.squad });\n\n try {\n const params = new URLSearchParams({ period });\n if (options.squad) params.append('squad', options.squad);\n\n const response = await fetch(`${bridgeUrl}/api/autonomy/score?${params}`);\n const data = await response.json() as AutonomyScore;\n\n if (options.json) {\n console.log(JSON.stringify(data, null, 2));\n return;\n }\n\n writeLine();\n writeLine(` ${gradient('squads')} ${colors.dim}autonomy${RESET}`);\n writeLine();\n\n // Overall score with visual indicator\n const score = data.overall_score;\n const confidence = data.confidence_level;\n const scoreColor = score >= 75 ? colors.green : score >= 50 ? colors.yellow : colors.red;\n const confidenceIcon = confidence === 'high' ? icons.success : confidence === 'medium' ? icons.warning : icons.error;\n\n writeLine(` ${bold}Overall Score${RESET} ${scoreColor}${score}%${RESET} ${confidenceIcon} ${confidence} confidence`);\n writeLine();\n\n // Progress bar\n const barWidth = 40;\n const filled = Math.round((score / 100) * barWidth);\n const bar = `${scoreColor}${'█'.repeat(filled)}${colors.dim}${'░'.repeat(barWidth - filled)}${RESET}`;\n writeLine(` ${bar}`);\n writeLine();\n\n // Component scores\n writeLine(` ${bold}Components${RESET}`);\n writeLine();\n\n const components = [\n { name: 'Quota Compliance', score: data.components.quota_compliance, weight: '25%' },\n { name: 'Success Rate', score: data.components.success_rate, weight: '25%' },\n { name: 'Quality Score', score: data.components.quality_score, weight: '20%' },\n { name: 'Cooldown Compliance', score: data.components.cooldown_compliance, weight: '15%' },\n { name: 'Learning Utilization', score: data.components.learning_utilization, weight: '15%' },\n ];\n\n for (const comp of components) {\n const compColor = comp.score >= 75 ? colors.green : comp.score >= 50 ? colors.yellow : colors.red;\n const compBar = `${compColor}${'█'.repeat(Math.round(comp.score / 5))}${colors.dim}${'░'.repeat(20 - Math.round(comp.score / 5))}${RESET}`;\n writeLine(` ${comp.name.padEnd(22)} ${compBar} ${compColor}${comp.score}%${RESET} ${colors.dim}(${comp.weight})${RESET}`);\n }\n\n writeLine();\n\n // Execution stats\n writeLine(` ${bold}Stats${RESET} ${colors.dim}(${period})${RESET}`);\n writeLine();\n writeLine(` ${colors.dim}Tasks:${RESET} ${data.execution_stats.successful_tasks}/${data.execution_stats.total_tasks} successful`);\n writeLine(` ${colors.dim}Quota:${RESET} $${data.execution_stats.monthly_used}/$${data.execution_stats.monthly_quota}/mo (${data.execution_stats.quota_pct}%)`);\n writeLine(` ${colors.dim}Learnings:${RESET} ${data.execution_stats.learning_count} captured`);\n\n if (options.squad) {\n writeLine(` ${colors.dim}Squad:${RESET} ${options.squad}`);\n }\n\n writeLine();\n\n // Recommendations\n if (score < 75) {\n writeLine(` ${bold}Recommendations${RESET}`);\n writeLine();\n\n if (data.components.learning_utilization < 50) {\n writeLine(` ${icons.empty} Capture more learnings: ${colors.dim}squads learn \"...\"${RESET}`);\n }\n if (data.components.quality_score < 70) {\n writeLine(` ${icons.empty} Add feedback after runs: ${colors.dim}squads feedback add <squad> <1-5>${RESET}`);\n }\n if (data.components.quota_compliance < 80) {\n writeLine(` ${icons.empty} Approaching monthly quota limit - consider upgrading plan`);\n }\n if (data.execution_stats.total_tasks === 0) {\n writeLine(` ${icons.empty} Run some agents: ${colors.dim}squads run <squad> --execute${RESET}`);\n }\n\n writeLine();\n }\n\n // Next steps\n writeLine(` ${colors.dim}$${RESET} squads autonomy --period=week ${colors.dim}Weekly view${RESET}`);\n writeLine(` ${colors.dim}$${RESET} squads memory sync --dimensions ${colors.dim}Sync to Postgres${RESET}`);\n writeLine();\n\n } catch (error) {\n writeLine();\n writeLine(` ${gradient('squads')} ${colors.dim}autonomy${RESET}`);\n writeLine();\n writeLine(` ${icons.error} ${colors.red}Failed to fetch autonomy score${RESET}`);\n writeLine(` ${colors.dim}${error}${RESET}`);\n writeLine();\n writeLine(` ${colors.dim}API unavailable. Run \\`squads login\\` to connect.${RESET}`);\n writeLine();\n }\n}\n"],"mappings":";;;;;;;;;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,EACZ;AACF;","names":[]}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
findMemoryDir
|
|
4
|
+
} from "./chunk-ZTQ7ISUR.js";
|
|
5
|
+
|
|
6
|
+
// src/lib/executions.ts
|
|
7
|
+
import { readFileSync, existsSync, readdirSync } from "fs";
|
|
8
|
+
import { join } from "path";
|
|
9
|
+
function parseExecutionEntry(content, squad, agent) {
|
|
10
|
+
const idMatch = content.match(/<!-- exec:(\S+) -->/);
|
|
11
|
+
if (!idMatch) return null;
|
|
12
|
+
const id = idMatch[1];
|
|
13
|
+
const headerMatch = content.match(/\*\*([^*]+)\*\* \| Status: (\w+)/);
|
|
14
|
+
if (!headerMatch) return null;
|
|
15
|
+
const startTime = headerMatch[1].trim();
|
|
16
|
+
const status = headerMatch[2];
|
|
17
|
+
const triggerMatch = content.match(/- Trigger: (\w+)/);
|
|
18
|
+
const taskTypeMatch = content.match(/- Task Type: (\w+)/);
|
|
19
|
+
const completedMatch = content.match(/- Completed: ([^\n]+)/);
|
|
20
|
+
const durationMatch = content.match(/- Duration: ([^\n]+)/);
|
|
21
|
+
const outcomeMatch = content.match(/- Outcome: ([^\n]+)/);
|
|
22
|
+
const errorMatch = content.match(/- Error: ([^\n]+)/);
|
|
23
|
+
let durationMs;
|
|
24
|
+
if (durationMatch) {
|
|
25
|
+
const durationStr = durationMatch[1].trim();
|
|
26
|
+
const secMatch = durationStr.match(/^([\d.]+)s$/);
|
|
27
|
+
if (secMatch) {
|
|
28
|
+
durationMs = parseFloat(secMatch[1]) * 1e3;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
id,
|
|
33
|
+
squad,
|
|
34
|
+
agent,
|
|
35
|
+
startTime,
|
|
36
|
+
endTime: completedMatch?.[1]?.trim(),
|
|
37
|
+
durationMs,
|
|
38
|
+
status,
|
|
39
|
+
trigger: triggerMatch?.[1] || "manual",
|
|
40
|
+
taskType: taskTypeMatch?.[1] || "execution",
|
|
41
|
+
outcome: outcomeMatch?.[1]?.trim(),
|
|
42
|
+
error: errorMatch?.[1]?.trim()
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function parseExecutionLog(filePath, squad, agent) {
|
|
46
|
+
if (!existsSync(filePath)) return [];
|
|
47
|
+
const content = readFileSync(filePath, "utf-8");
|
|
48
|
+
const executions = [];
|
|
49
|
+
const entries = content.split(/\n---\n/);
|
|
50
|
+
for (const entry of entries) {
|
|
51
|
+
if (!entry.includes("<!-- exec:")) continue;
|
|
52
|
+
const execution = parseExecutionEntry(entry, squad, agent);
|
|
53
|
+
if (execution) {
|
|
54
|
+
executions.push(execution);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
for (const entry of entries) {
|
|
58
|
+
if (entry.includes("<!-- exec:")) continue;
|
|
59
|
+
const headerMatch = entry.match(/\*\*([^*]+)\*\* \| Status: (\w+)/);
|
|
60
|
+
if (!headerMatch) continue;
|
|
61
|
+
const startTime = headerMatch[1].trim();
|
|
62
|
+
const status = headerMatch[2];
|
|
63
|
+
const legacyId = `legacy_${startTime.replace(/[^a-z0-9]/gi, "")}`;
|
|
64
|
+
if (executions.some((e) => e.startTime === startTime)) continue;
|
|
65
|
+
executions.push({
|
|
66
|
+
id: legacyId,
|
|
67
|
+
squad,
|
|
68
|
+
agent,
|
|
69
|
+
startTime,
|
|
70
|
+
status,
|
|
71
|
+
trigger: "manual",
|
|
72
|
+
taskType: "execution"
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return executions;
|
|
76
|
+
}
|
|
77
|
+
function listExecutions(options = {}) {
|
|
78
|
+
const memoryDir = findMemoryDir();
|
|
79
|
+
if (!memoryDir) return [];
|
|
80
|
+
const executions = [];
|
|
81
|
+
const { squad: filterSquad, agent: filterAgent, status: filterStatus, limit, since } = options;
|
|
82
|
+
const squads = readdirSync(memoryDir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
83
|
+
for (const squad of squads) {
|
|
84
|
+
if (filterSquad && squad !== filterSquad) continue;
|
|
85
|
+
const squadPath = join(memoryDir, squad);
|
|
86
|
+
const agents = readdirSync(squadPath, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
87
|
+
for (const agent of agents) {
|
|
88
|
+
if (filterAgent && agent !== filterAgent) continue;
|
|
89
|
+
const logPath = join(squadPath, agent, "executions.md");
|
|
90
|
+
const agentExecutions = parseExecutionLog(logPath, squad, agent);
|
|
91
|
+
executions.push(...agentExecutions);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
let filtered = filterStatus ? executions.filter((e) => e.status === filterStatus) : executions;
|
|
95
|
+
if (since) {
|
|
96
|
+
const sinceMs = since.getTime();
|
|
97
|
+
filtered = filtered.filter((e) => {
|
|
98
|
+
const execDate = new Date(e.startTime).getTime();
|
|
99
|
+
return !isNaN(execDate) && execDate >= sinceMs;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
filtered.sort((a, b) => {
|
|
103
|
+
const aTime = new Date(a.startTime).getTime();
|
|
104
|
+
const bTime = new Date(b.startTime).getTime();
|
|
105
|
+
if (isNaN(aTime) || isNaN(bTime)) return 0;
|
|
106
|
+
return bTime - aTime;
|
|
107
|
+
});
|
|
108
|
+
if (limit && limit > 0) {
|
|
109
|
+
filtered = filtered.slice(0, limit);
|
|
110
|
+
}
|
|
111
|
+
return filtered;
|
|
112
|
+
}
|
|
113
|
+
function getExecutionStats(options = {}) {
|
|
114
|
+
const executions = listExecutions(options);
|
|
115
|
+
const running = executions.filter((e) => e.status === "running").length;
|
|
116
|
+
const completed = executions.filter((e) => e.status === "completed").length;
|
|
117
|
+
const failed = executions.filter((e) => e.status === "failed").length;
|
|
118
|
+
const durations = executions.filter((e) => e.status === "completed" && e.durationMs).map((e) => e.durationMs);
|
|
119
|
+
const avgDurationMs = durations.length > 0 ? durations.reduce((a, b) => a + b, 0) / durations.length : null;
|
|
120
|
+
const bySquad = {};
|
|
121
|
+
for (const e of executions) {
|
|
122
|
+
bySquad[e.squad] = (bySquad[e.squad] || 0) + 1;
|
|
123
|
+
}
|
|
124
|
+
const byAgent = {};
|
|
125
|
+
for (const e of executions) {
|
|
126
|
+
const key = `${e.squad}/${e.agent}`;
|
|
127
|
+
byAgent[key] = (byAgent[key] || 0) + 1;
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
total: executions.length,
|
|
131
|
+
running,
|
|
132
|
+
completed,
|
|
133
|
+
failed,
|
|
134
|
+
avgDurationMs,
|
|
135
|
+
bySquad,
|
|
136
|
+
byAgent
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function formatDuration(ms) {
|
|
140
|
+
if (!ms) return "\u2014";
|
|
141
|
+
if (ms < 1e3) {
|
|
142
|
+
return `${ms}ms`;
|
|
143
|
+
}
|
|
144
|
+
if (ms < 6e4) {
|
|
145
|
+
return `${(ms / 1e3).toFixed(1)}s`;
|
|
146
|
+
}
|
|
147
|
+
if (ms < 36e5) {
|
|
148
|
+
const mins2 = Math.floor(ms / 6e4);
|
|
149
|
+
const secs = Math.round(ms % 6e4 / 1e3);
|
|
150
|
+
return `${mins2}m ${secs}s`;
|
|
151
|
+
}
|
|
152
|
+
const hours = Math.floor(ms / 36e5);
|
|
153
|
+
const mins = Math.round(ms % 36e5 / 6e4);
|
|
154
|
+
return `${hours}h ${mins}m`;
|
|
155
|
+
}
|
|
156
|
+
function formatRelativeTime(isoTime) {
|
|
157
|
+
const date = new Date(isoTime);
|
|
158
|
+
if (isNaN(date.getTime())) return isoTime;
|
|
159
|
+
const now = Date.now();
|
|
160
|
+
const diff = now - date.getTime();
|
|
161
|
+
if (diff < 6e4) return "just now";
|
|
162
|
+
if (diff < 36e5) return `${Math.floor(diff / 6e4)}m ago`;
|
|
163
|
+
if (diff < 864e5) return `${Math.floor(diff / 36e5)}h ago`;
|
|
164
|
+
if (diff < 6048e5) return `${Math.floor(diff / 864e5)}d ago`;
|
|
165
|
+
return date.toLocaleDateString();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export {
|
|
169
|
+
listExecutions,
|
|
170
|
+
getExecutionStats,
|
|
171
|
+
formatDuration,
|
|
172
|
+
formatRelativeTime
|
|
173
|
+
};
|
|
174
|
+
//# sourceMappingURL=chunk-67RO2HKR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/executions.ts"],"sourcesContent":["/**\n * Execution log parsing and querying\n *\n * Parses execution logs from .agents/memory/<squad>/<agent>/executions.md\n * and provides query functions for the `squads exec` command.\n */\n\nimport { readFileSync, existsSync, readdirSync } from 'fs';\nimport { join } from 'path';\nimport { findMemoryDir } from './memory.js';\n\nexport interface Execution {\n id: string;\n squad: string;\n agent: string;\n startTime: string;\n endTime?: string;\n durationMs?: number;\n status: 'running' | 'completed' | 'failed';\n trigger: 'manual' | 'scheduled' | 'event' | 'smart';\n taskType: 'evaluation' | 'execution' | 'research' | 'lead';\n outcome?: string;\n error?: string;\n}\n\nexport interface ExecutionListOptions {\n squad?: string;\n agent?: string;\n status?: Execution['status'];\n limit?: number;\n since?: Date;\n}\n\n/**\n * Parse a single execution entry from markdown\n */\nfunction parseExecutionEntry(\n content: string,\n squad: string,\n agent: string\n): Execution | null {\n // Extract execution ID from comment marker\n const idMatch = content.match(/<!-- exec:(\\S+) -->/);\n if (!idMatch) return null;\n\n const id = idMatch[1];\n\n // Extract timestamp and status from header\n const headerMatch = content.match(/\\*\\*([^*]+)\\*\\* \\| Status: (\\w+)/);\n if (!headerMatch) return null;\n\n const startTime = headerMatch[1].trim();\n const status = headerMatch[2] as Execution['status'];\n\n // Parse structured fields\n const triggerMatch = content.match(/- Trigger: (\\w+)/);\n const taskTypeMatch = content.match(/- Task Type: (\\w+)/);\n const completedMatch = content.match(/- Completed: ([^\\n]+)/);\n const durationMatch = content.match(/- Duration: ([^\\n]+)/);\n const outcomeMatch = content.match(/- Outcome: ([^\\n]+)/);\n const errorMatch = content.match(/- Error: ([^\\n]+)/);\n\n // Parse duration string to ms\n let durationMs: number | undefined;\n if (durationMatch) {\n const durationStr = durationMatch[1].trim();\n const secMatch = durationStr.match(/^([\\d.]+)s$/);\n if (secMatch) {\n durationMs = parseFloat(secMatch[1]) * 1000;\n }\n }\n\n return {\n id,\n squad,\n agent,\n startTime,\n endTime: completedMatch?.[1]?.trim(),\n durationMs,\n status,\n trigger: (triggerMatch?.[1] || 'manual') as Execution['trigger'],\n taskType: (taskTypeMatch?.[1] || 'execution') as Execution['taskType'],\n outcome: outcomeMatch?.[1]?.trim(),\n error: errorMatch?.[1]?.trim(),\n };\n}\n\n/**\n * Parse all executions from an agent's execution log\n */\nfunction parseExecutionLog(filePath: string, squad: string, agent: string): Execution[] {\n if (!existsSync(filePath)) return [];\n\n const content = readFileSync(filePath, 'utf-8');\n const executions: Execution[] = [];\n\n // Split by entry separator\n const entries = content.split(/\\n---\\n/);\n\n for (const entry of entries) {\n if (!entry.includes('<!-- exec:')) continue;\n\n const execution = parseExecutionEntry(entry, squad, agent);\n if (execution) {\n executions.push(execution);\n }\n }\n\n // Also try to parse legacy format entries (without exec: marker)\n // These will have limited data but we can still extract basic info\n for (const entry of entries) {\n if (entry.includes('<!-- exec:')) continue; // Already parsed\n\n const headerMatch = entry.match(/\\*\\*([^*]+)\\*\\* \\| Status: (\\w+)/);\n if (!headerMatch) continue;\n\n const startTime = headerMatch[1].trim();\n const status = headerMatch[2] as Execution['status'];\n\n // Generate a deterministic ID from timestamp for legacy entries\n const legacyId = `legacy_${startTime.replace(/[^a-z0-9]/gi, '')}`;\n\n // Skip if we already have this (by timestamp proximity)\n if (executions.some(e => e.startTime === startTime)) continue;\n\n executions.push({\n id: legacyId,\n squad,\n agent,\n startTime,\n status,\n trigger: 'manual',\n taskType: 'execution',\n });\n }\n\n return executions;\n}\n\n/**\n * List all executions across all squads\n */\nexport function listExecutions(options: ExecutionListOptions = {}): Execution[] {\n const memoryDir = findMemoryDir();\n if (!memoryDir) return [];\n\n const executions: Execution[] = [];\n const { squad: filterSquad, agent: filterAgent, status: filterStatus, limit, since } = options;\n\n // Find all squad directories\n const squads = readdirSync(memoryDir, { withFileTypes: true })\n .filter(e => e.isDirectory())\n .map(e => e.name);\n\n for (const squad of squads) {\n if (filterSquad && squad !== filterSquad) continue;\n\n const squadPath = join(memoryDir, squad);\n const agents = readdirSync(squadPath, { withFileTypes: true })\n .filter(e => e.isDirectory())\n .map(e => e.name);\n\n for (const agent of agents) {\n if (filterAgent && agent !== filterAgent) continue;\n\n const logPath = join(squadPath, agent, 'executions.md');\n const agentExecutions = parseExecutionLog(logPath, squad, agent);\n executions.push(...agentExecutions);\n }\n }\n\n // Filter by status\n let filtered = filterStatus\n ? executions.filter(e => e.status === filterStatus)\n : executions;\n\n // Filter by date\n if (since) {\n const sinceMs = since.getTime();\n filtered = filtered.filter(e => {\n const execDate = new Date(e.startTime).getTime();\n return !isNaN(execDate) && execDate >= sinceMs;\n });\n }\n\n // Sort by start time (most recent first)\n filtered.sort((a, b) => {\n const aTime = new Date(a.startTime).getTime();\n const bTime = new Date(b.startTime).getTime();\n if (isNaN(aTime) || isNaN(bTime)) return 0;\n return bTime - aTime;\n });\n\n // Apply limit\n if (limit && limit > 0) {\n filtered = filtered.slice(0, limit);\n }\n\n return filtered;\n}\n\n/**\n * Get a specific execution by ID\n */\nexport function getExecution(executionId: string): Execution | null {\n const executions = listExecutions();\n return executions.find(e => e.id === executionId) || null;\n}\n\n/**\n * Get execution statistics\n */\nexport function getExecutionStats(options: ExecutionListOptions = {}): {\n total: number;\n running: number;\n completed: number;\n failed: number;\n avgDurationMs: number | null;\n bySquad: Record<string, number>;\n byAgent: Record<string, number>;\n} {\n const executions = listExecutions(options);\n\n const running = executions.filter(e => e.status === 'running').length;\n const completed = executions.filter(e => e.status === 'completed').length;\n const failed = executions.filter(e => e.status === 'failed').length;\n\n // Calculate average duration from completed executions\n const durations = executions\n .filter(e => e.status === 'completed' && e.durationMs)\n .map(e => e.durationMs!);\n const avgDurationMs = durations.length > 0\n ? durations.reduce((a, b) => a + b, 0) / durations.length\n : null;\n\n // Count by squad\n const bySquad: Record<string, number> = {};\n for (const e of executions) {\n bySquad[e.squad] = (bySquad[e.squad] || 0) + 1;\n }\n\n // Count by agent\n const byAgent: Record<string, number> = {};\n for (const e of executions) {\n const key = `${e.squad}/${e.agent}`;\n byAgent[key] = (byAgent[key] || 0) + 1;\n }\n\n return {\n total: executions.length,\n running,\n completed,\n failed,\n avgDurationMs,\n bySquad,\n byAgent,\n };\n}\n\n/**\n * Format duration for display\n */\nexport function formatDuration(ms: number | undefined): string {\n if (!ms) return '—';\n\n if (ms < 1000) {\n return `${ms}ms`;\n }\n if (ms < 60000) {\n return `${(ms / 1000).toFixed(1)}s`;\n }\n if (ms < 3600000) {\n const mins = Math.floor(ms / 60000);\n const secs = Math.round((ms % 60000) / 1000);\n return `${mins}m ${secs}s`;\n }\n\n const hours = Math.floor(ms / 3600000);\n const mins = Math.round((ms % 3600000) / 60000);\n return `${hours}h ${mins}m`;\n}\n\n/**\n * Format relative time for display\n */\nexport function formatRelativeTime(isoTime: string): string {\n const date = new Date(isoTime);\n if (isNaN(date.getTime())) return isoTime;\n\n const now = Date.now();\n const diff = now - date.getTime();\n\n if (diff < 60000) return 'just now';\n if (diff < 3600000) return `${Math.floor(diff / 60000)}m ago`;\n if (diff < 86400000) return `${Math.floor(diff / 3600000)}h ago`;\n if (diff < 604800000) return `${Math.floor(diff / 86400000)}d ago`;\n\n return date.toLocaleDateString();\n}\n"],"mappings":";;;;;;AAOA,SAAS,cAAc,YAAY,mBAAmB;AACtD,SAAS,YAAY;AA4BrB,SAAS,oBACP,SACA,OACA,OACkB;AAElB,QAAM,UAAU,QAAQ,MAAM,qBAAqB;AACnD,MAAI,CAAC,QAAS,QAAO;AAErB,QAAM,KAAK,QAAQ,CAAC;AAGpB,QAAM,cAAc,QAAQ,MAAM,kCAAkC;AACpE,MAAI,CAAC,YAAa,QAAO;AAEzB,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efined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
+
}) : x)(function(x) {
|
|
5
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
__require
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=chunk-7OCVIDC7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|