@polderlabs/bizar 4.9.0 → 5.0.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/bizar-dash/dist/assets/icons-Bo0iH9EC.js +701 -0
- package/bizar-dash/dist/assets/icons-Bo0iH9EC.js.map +1 -0
- package/bizar-dash/dist/assets/{index-DU61awG3.js → index-DmpSFPJY.js} +1 -1
- package/bizar-dash/dist/assets/{index-DU61awG3.js.map → index-DmpSFPJY.js.map} +1 -1
- package/bizar-dash/dist/assets/main-C1cpttnv.js +19 -0
- package/bizar-dash/dist/assets/main-C1cpttnv.js.map +1 -0
- package/bizar-dash/dist/assets/main-DTkNlLrw.css +1 -0
- package/bizar-dash/dist/assets/markdown-DIquRulQ.js +29 -0
- package/bizar-dash/dist/assets/markdown-DIquRulQ.js.map +1 -0
- package/bizar-dash/dist/assets/mobile-BtxQJftK.js +2 -0
- package/bizar-dash/dist/assets/mobile-BtxQJftK.js.map +1 -0
- package/bizar-dash/dist/assets/mobile-DD-FZrTC.js +1 -0
- package/bizar-dash/dist/assets/{mobile-CL5uUQEC.js.map → mobile-DD-FZrTC.js.map} +1 -1
- package/bizar-dash/dist/assets/react-vendor-DZRUXSPQ.js +40 -0
- package/bizar-dash/dist/assets/react-vendor-DZRUXSPQ.js.map +1 -0
- package/bizar-dash/dist/index.html +6 -3
- package/bizar-dash/dist/mobile.html +5 -2
- package/bizar-dash/node_modules/.package-lock.json +6 -0
- package/bizar-dash/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
- package/bizar-dash/package-lock.json +6 -0
- package/bizar-dash/skills/eval/SKILL.md +237 -0
- package/bizar-dash/src/server/api.mjs +35 -0
- package/bizar-dash/src/server/auth.mjs +155 -1
- package/bizar-dash/src/server/diagnostics-store.mjs +452 -2
- package/bizar-dash/src/server/eval-store.mjs +226 -0
- package/bizar-dash/src/server/eval.mjs +347 -0
- package/bizar-dash/src/server/memory-store.mjs +46 -0
- package/bizar-dash/src/server/ocr.mjs +55 -0
- package/bizar-dash/src/server/plugins/registry.mjs +363 -0
- package/bizar-dash/src/server/plugins/sandbox.mjs +655 -0
- package/bizar-dash/src/server/plugins/store.mjs +659 -0
- package/bizar-dash/src/server/providers-store.mjs +11 -4
- package/bizar-dash/src/server/routes/_shared.mjs +2 -2
- package/bizar-dash/src/server/routes/clipboard.mjs +173 -0
- package/bizar-dash/src/server/routes/doctor.mjs +71 -0
- package/bizar-dash/src/server/routes/env-vars.mjs +67 -1
- package/bizar-dash/src/server/routes/eval.mjs +147 -0
- package/bizar-dash/src/server/routes/memory.mjs +3 -0
- package/bizar-dash/src/server/routes/ocr.mjs +182 -0
- package/bizar-dash/src/server/routes/opencode-session-detail.mjs +61 -42
- package/bizar-dash/src/server/routes/plugins.mjs +220 -0
- package/bizar-dash/src/server/routes/schedules.mjs +55 -0
- package/bizar-dash/src/server/routes/users.mjs +84 -0
- package/bizar-dash/src/server/routes/voice.mjs +131 -0
- package/bizar-dash/src/server/routes/workspaces.mjs +204 -0
- package/bizar-dash/src/server/serve-info.mjs +172 -0
- package/bizar-dash/src/server/voice-store.mjs +202 -0
- package/bizar-dash/src/server/voice-transcribe.mjs +72 -0
- package/bizar-dash/src/server/workspaces.mjs +626 -0
- package/bizar-dash/src/web/App.tsx +48 -11
- package/bizar-dash/src/web/components/AutosaveField.tsx +50 -0
- package/bizar-dash/src/web/components/DoctorPanel.tsx +160 -0
- package/bizar-dash/src/web/components/EnvVarManager.tsx +245 -62
- package/bizar-dash/src/web/components/InviteDialog.tsx +205 -0
- package/bizar-dash/src/web/components/ScheduleTemplateCard.tsx +71 -0
- package/bizar-dash/src/web/components/ScreenshotCapture.tsx +138 -0
- package/bizar-dash/src/web/components/ScreenshotOCR.tsx +42 -0
- package/bizar-dash/src/web/components/SettingsNav.tsx +101 -0
- package/bizar-dash/src/web/components/Sidebar.tsx +25 -1
- package/bizar-dash/src/web/components/StatusBadge.tsx +33 -2
- package/bizar-dash/src/web/components/Topbar.tsx +11 -0
- package/bizar-dash/src/web/components/VoiceNotesPanel.tsx +182 -0
- package/bizar-dash/src/web/components/VoiceRecorder.tsx +104 -0
- package/bizar-dash/src/web/components/WorkspaceSelector.tsx +158 -0
- package/bizar-dash/src/web/components/chat/ChatInfoPanel.tsx +64 -0
- package/bizar-dash/src/web/components/chat/Composer.tsx +1 -1
- package/bizar-dash/src/web/components/chat/useChat.ts +118 -1
- package/bizar-dash/src/web/hooks/useAutosave.ts +107 -0
- package/bizar-dash/src/web/lib/types.ts +134 -0
- package/bizar-dash/src/web/styles/chat.css +8 -5
- package/bizar-dash/src/web/styles/main.css +77 -2
- package/bizar-dash/src/web/styles/memory.css +82 -0
- package/bizar-dash/src/web/styles/settings.css +265 -0
- package/bizar-dash/src/web/views/Chat.tsx +15 -1
- package/bizar-dash/src/web/views/Doctor.tsx +317 -0
- package/bizar-dash/src/web/views/Memory.tsx +17 -2
- package/bizar-dash/src/web/views/MiniMaxUsage.tsx +1 -0
- package/bizar-dash/src/web/views/Schedules.tsx +94 -12
- package/bizar-dash/src/web/views/Settings.tsx +78 -45
- package/bizar-dash/src/web/views/Workspace.tsx +294 -0
- package/bizar-dash/src/web/views/memory/ConfigPanel.tsx +114 -133
- package/bizar-dash/src/web/views/memory/FromScreenshotPanel.tsx +23 -0
- package/bizar-dash/src/web/views/memory/VaultFromClipboardPanel.tsx +101 -0
- package/bizar-dash/src/web/views/settings/AgentSection.tsx +23 -12
- package/bizar-dash/src/web/views/settings/EnvVarsSection.tsx +5 -6
- package/bizar-dash/src/web/views/settings/GeneralSection.tsx +38 -15
- package/bizar-dash/src/web/views/settings/MemorySection.tsx +92 -8
- package/bizar-dash/src/web/views/settings/WorkspacesSection.tsx +189 -0
- package/bizar-dash/tests/autosave.test.tsx +276 -0
- package/bizar-dash/tests/bundle-analysis.test.mjs +5 -2
- package/bizar-dash/tests/chat-composer.test.tsx +140 -0
- package/bizar-dash/tests/clipboard.test.mjs +147 -0
- package/bizar-dash/tests/components/doctor-panel.test.tsx +105 -0
- package/bizar-dash/tests/components/screenshot-ocr.test.tsx +75 -0
- package/bizar-dash/tests/components/workspace-selector.test.tsx +73 -0
- package/bizar-dash/tests/deploy-templates.test.mjs +100 -0
- package/bizar-dash/tests/diagnostics-store.test.mjs +206 -0
- package/bizar-dash/tests/env-vars-extended.test.mjs +190 -0
- package/bizar-dash/tests/eval/fixtures.test.mjs +141 -0
- package/bizar-dash/tests/eval/report.test.mjs +284 -0
- package/bizar-dash/tests/eval/runner.test.mjs +471 -0
- package/bizar-dash/tests/layout-spacing.test.mjs +101 -0
- package/bizar-dash/tests/memory-default-vault.test.mjs +98 -0
- package/bizar-dash/tests/minimax-bar.test.tsx +113 -0
- package/bizar-dash/tests/minimax-models.test.mjs +123 -0
- package/bizar-dash/tests/ocr.test.mjs +87 -0
- package/bizar-dash/tests/opencode-sessions-detail.test.mjs +158 -0
- package/bizar-dash/tests/plugins-registry.test.mjs +387 -0
- package/bizar-dash/tests/plugins-sandbox.test.mjs +374 -0
- package/bizar-dash/tests/plugins-store.test.mjs +455 -0
- package/bizar-dash/tests/routes-doctor.test.mjs +159 -0
- package/bizar-dash/tests/schedules-templates.test.mjs +144 -0
- package/bizar-dash/tests/settings-layout.test.tsx +129 -0
- package/bizar-dash/tests/settings-mode-wiring.test.tsx +151 -0
- package/bizar-dash/tests/settings-nav.test.tsx +126 -0
- package/bizar-dash/tests/users.test.mjs +108 -0
- package/bizar-dash/tests/voice-recorder.test.tsx +95 -0
- package/bizar-dash/tests/voice-store.test.mjs +148 -0
- package/bizar-dash/tests/voice-transcribe.test.mjs +87 -0
- package/bizar-dash/tests/workspaces.test.mjs +527 -0
- package/cli/bin.mjs +72 -2
- package/cli/commands/clip.mjs +146 -0
- package/cli/commands/deploy/cloudflare.mjs +250 -0
- package/cli/commands/deploy/docker.mjs +221 -0
- package/cli/commands/deploy/fly.mjs +161 -0
- package/cli/commands/deploy/vercel.mjs +225 -0
- package/cli/commands/deploy.mjs +240 -0
- package/cli/commands/eval.mjs +378 -0
- package/cli/commands/marketplace.mjs +64 -0
- package/cli/commands/minimax.mjs +5 -2
- package/cli/commands/ocr.mjs +165 -0
- package/cli/commands/plugin.mjs +358 -0
- package/cli/commands/voice.mjs +211 -0
- package/cli/commands/workspace.mjs +247 -0
- package/cli/tests/minimax-cli.test.mjs +79 -0
- package/config/agents/frigg.md +1 -1
- package/config/agents/heimdall.md +1 -1
- package/config/agents/mimir.md +1 -1
- package/config/agents/quick.md +1 -1
- package/config/agents/semble-search.md +1 -1
- package/config/agents/vor.md +1 -1
- package/config/opencode.json +28 -21
- package/config/opencode.json.template +8 -1
- package/package.json +12 -8
- package/plugins/bizar/index.ts +77 -0
- package/plugins/bizar/src/compaction.d.mts +48 -0
- package/plugins/bizar/src/compaction.mjs +192 -0
- package/plugins/bizar/tests/compaction.test.ts +264 -0
- package/templates/deploy/cloudflare/README.md +32 -0
- package/templates/deploy/cloudflare/functions-index.template.js +15 -0
- package/templates/deploy/cloudflare/wrangler.toml.template +9 -0
- package/templates/deploy/docker/.env.template +16 -0
- package/templates/deploy/docker/README.md +58 -0
- package/templates/deploy/docker/docker-compose.template.yml +23 -0
- package/templates/deploy/fly/README.md +35 -0
- package/templates/deploy/fly/fly.toml.template +28 -0
- package/templates/deploy/vercel/README.md +29 -0
- package/templates/deploy/vercel/api-index.template.js +18 -0
- package/templates/deploy/vercel/vercel.json.template +16 -0
- package/templates/eval-fixtures/README.md +58 -0
- package/templates/eval-fixtures/code-search-basic.json +28 -0
- package/templates/eval-fixtures/latency-bounds.json +16 -0
- package/templates/eval-fixtures/regression-suite.json +79 -0
- package/templates/eval-fixtures/response-format.json +30 -0
- package/templates/eval-fixtures/tool-call-correctness.json +24 -0
- package/templates/plugin-template/README.md +121 -0
- package/templates/plugin-template/index.js +66 -0
- package/templates/plugin-template/plugin.json +42 -0
- package/templates/plugin-template/tests/plugin.test.js +83 -0
- package/templates/schedules/daily-backup.json +12 -0
- package/templates/schedules/daily-cleanup.json +12 -0
- package/templates/schedules/hourly-health-check.json +12 -0
- package/templates/schedules/webhook-on-push.json +13 -0
- package/templates/schedules/weekly-digest.json +13 -0
- package/bizar-dash/dist/assets/main-DaC1Lc6q.js +0 -366
- package/bizar-dash/dist/assets/main-DaC1Lc6q.js.map +0 -1
- package/bizar-dash/dist/assets/main-DfmIfOUS.css +0 -1
- package/bizar-dash/dist/assets/mobile-CL5uUQEC.js +0 -1
- package/bizar-dash/dist/assets/mobile-D5WTWvuh.js +0 -338
- package/bizar-dash/dist/assets/mobile-D5WTWvuh.js.map +0 -1
- package/bizar-dash/src/web/views/settings/BackupSection.tsx +0 -16
- package/bizar-dash/src/web/views/settings/ProvidersSection.tsx +0 -16
- package/bizar-dash/src/web/views/settings/SkillsSection.tsx +0 -16
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type declarations for `./compaction.mjs`.
|
|
3
|
+
*
|
|
4
|
+
* The runtime module is shipped as plain ESM JavaScript (`.mjs`) per the
|
|
5
|
+
* brief, but its consumers in `index.ts` and `tests/compaction.test.ts`
|
|
6
|
+
* are TypeScript. Without this companion declaration file, TypeScript
|
|
7
|
+
* would type the exports as `any`, which causes cascading `implicitly
|
|
8
|
+
* has 'any' type` errors at call sites (e.g. the `texts` parameter in
|
|
9
|
+
* the test's `summarizer` stubs).
|
|
10
|
+
*
|
|
11
|
+
* The declarations here mirror the contract documented in
|
|
12
|
+
* `./compaction.mjs`. They are NOT loaded at runtime — they exist only
|
|
13
|
+
* for the type-checker.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export interface CompactionResult {
|
|
17
|
+
compacted: boolean;
|
|
18
|
+
reason?: "below_threshold";
|
|
19
|
+
sessionId?: string;
|
|
20
|
+
threshold?: number;
|
|
21
|
+
preservedRecent?: number;
|
|
22
|
+
atMessages?: number;
|
|
23
|
+
ratio?: number | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface MaybeCompactSessionOpts {
|
|
27
|
+
sessionId: string;
|
|
28
|
+
messageCount: number;
|
|
29
|
+
currentUsage: { total?: number } | null | undefined;
|
|
30
|
+
maxContext: number | null | undefined;
|
|
31
|
+
summarizer: (texts: string[]) => Promise<string>;
|
|
32
|
+
preserveRecent?: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function shouldCompact(
|
|
36
|
+
usage: { total?: number } | null | undefined,
|
|
37
|
+
maxContext: number | null | undefined,
|
|
38
|
+
): boolean;
|
|
39
|
+
|
|
40
|
+
export function maybeCompactSession(opts: MaybeCompactSessionOpts): Promise<CompactionResult>;
|
|
41
|
+
|
|
42
|
+
export function getCompactionThreshold(): number;
|
|
43
|
+
|
|
44
|
+
export function setCompactionThreshold(value: number): void;
|
|
45
|
+
|
|
46
|
+
export function resetCompactionDefaults(): void;
|
|
47
|
+
|
|
48
|
+
export function getDefaultPreserveRecent(): number;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* compaction.mjs
|
|
3
|
+
*
|
|
4
|
+
* Context-window compaction gate.
|
|
5
|
+
*
|
|
6
|
+
* Monitors a chat session's context-usage ratio and reports whether the
|
|
7
|
+
* session has reached the compaction threshold (default 50% of the model's
|
|
8
|
+
* max-context window). When the ratio crosses the threshold, callers can
|
|
9
|
+
* trigger summarization of the older message history while preserving a
|
|
10
|
+
* configurable recent tail so the model retains short-term continuity.
|
|
11
|
+
*
|
|
12
|
+
* Spec contract:
|
|
13
|
+
* - The threshold is the *ratio* `usage.total / maxContext`, NOT an
|
|
14
|
+
* absolute token count. This makes the gate model-agnostic — it works
|
|
15
|
+
* whether the model has a 32k, 128k, or 1M context window.
|
|
16
|
+
* - `shouldCompact` is a pure function: same inputs → same output, no I/O.
|
|
17
|
+
* - `maybeCompactSession` is async to match the real summarizer signature
|
|
18
|
+
* but performs no I/O itself when below threshold — it short-circuits.
|
|
19
|
+
* - Threshold is mutable via `setCompactionThreshold` and is validated
|
|
20
|
+
* against the range [0.1, 1.0]. A throw is the right signal here —
|
|
21
|
+
* misconfiguration should fail loudly at startup, not silently use a
|
|
22
|
+
* bad value at runtime.
|
|
23
|
+
* - Threshold uses `let` (not `const`) so the setter can mutate it.
|
|
24
|
+
* The reference spec used `const` and would throw a TypeError on
|
|
25
|
+
* assignment; this implementation keeps the API but fixes the bug.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const PRESERVE_RECENT_MESSAGES_DEFAULT = 10;
|
|
29
|
+
const MIN_THRESHOLD = 0.1;
|
|
30
|
+
const MAX_THRESHOLD = 1.0;
|
|
31
|
+
|
|
32
|
+
// Module-level threshold. Exposed via get/set for tunability.
|
|
33
|
+
// Exported as a number via getCompactionThreshold(); the underlying binding
|
|
34
|
+
// is private (not exported) so callers cannot bypass validation by writing
|
|
35
|
+
// to it directly.
|
|
36
|
+
let compactionThreshold = 0.5;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Returns `true` when `usage.total / maxContext` meets or exceeds the
|
|
40
|
+
* compaction threshold. `false` when below, or when either input is
|
|
41
|
+
* missing/invalid (defensive default).
|
|
42
|
+
*
|
|
43
|
+
* @param {{ total?: number } | null | undefined} usage
|
|
44
|
+
* Object with a `total` token count, or null/undefined.
|
|
45
|
+
* @param {number | null | undefined} maxContext
|
|
46
|
+
* Maximum context window size in tokens.
|
|
47
|
+
* @returns {boolean}
|
|
48
|
+
*/
|
|
49
|
+
export function shouldCompact(usage, maxContext) {
|
|
50
|
+
if (!usage || typeof usage.total !== "number") return false;
|
|
51
|
+
if (typeof maxContext !== "number" || maxContext <= 0) return false;
|
|
52
|
+
const ratio = usage.total / maxContext;
|
|
53
|
+
return ratio >= compactionThreshold;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Decision-shaped result returned by `maybeCompactSession`.
|
|
58
|
+
*
|
|
59
|
+
* - When below threshold: `{ compacted: false, reason: "below_threshold", ratio }`.
|
|
60
|
+
* - When at/over threshold: `{ compacted: true, sessionId, threshold,
|
|
61
|
+
* preservedRecent, atMessages, ratio }`.
|
|
62
|
+
*
|
|
63
|
+
* @typedef {Object} CompactionResult
|
|
64
|
+
* @property {boolean} compacted
|
|
65
|
+
* @property {"below_threshold"} [reason] when compacted=false
|
|
66
|
+
* @property {string} [sessionId]
|
|
67
|
+
* @property {number} [threshold] the threshold at decision time
|
|
68
|
+
* @property {number} [preservedRecent] how many recent messages to keep verbatim
|
|
69
|
+
* @property {number} [atMessages] message count at decision time
|
|
70
|
+
* @property {number} [ratio] usage.total / maxContext
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Decide whether to compact and, if so, record the decision. The summarizer
|
|
75
|
+
* is NOT invoked here — that is the caller's responsibility. This function
|
|
76
|
+
* is the decision gate, not the executor. (The summarizer receives an
|
|
77
|
+
* `Array<string>` of older messages and returns a single summary string.)
|
|
78
|
+
*
|
|
79
|
+
* @param {Object} opts
|
|
80
|
+
* @param {string} opts.sessionId
|
|
81
|
+
* @param {number} opts.messageCount total messages in the session
|
|
82
|
+
* @param {{ total?: number } | null | undefined} opts.currentUsage
|
|
83
|
+
* @param {number | null | undefined} opts.maxContext
|
|
84
|
+
* @param {(texts: string[]) => Promise<string>} opts.summarizer
|
|
85
|
+
* Async summarizer used by the caller when `compacted === true`. Not invoked
|
|
86
|
+
* here. Accepting it as a parameter documents the contract for downstream
|
|
87
|
+
* callers without forcing this function to do I/O.
|
|
88
|
+
* @param {number} [opts.preserveRecent=10] how many recent messages to keep verbatim
|
|
89
|
+
* @returns {Promise<CompactionResult>}
|
|
90
|
+
*/
|
|
91
|
+
export async function maybeCompactSession({
|
|
92
|
+
sessionId,
|
|
93
|
+
messageCount,
|
|
94
|
+
currentUsage,
|
|
95
|
+
maxContext,
|
|
96
|
+
// summarizer is accepted for API symmetry with downstream callers; we do
|
|
97
|
+
// not invoke it here because compaction execution lives in the plugin
|
|
98
|
+
// hook layer, not in this pure decision gate.
|
|
99
|
+
summarizer, // eslint-disable-line no-unused-vars
|
|
100
|
+
preserveRecent = PRESERVE_RECENT_MESSAGES_DEFAULT,
|
|
101
|
+
}) {
|
|
102
|
+
if (typeof sessionId !== "string" || sessionId === "") {
|
|
103
|
+
// Misuse — caller forgot a sessionId. Refuse rather than silently
|
|
104
|
+
// returning below_threshold, which would mask a real bug upstream.
|
|
105
|
+
throw new Error("maybeCompactSession: sessionId is required");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (!shouldCompact(currentUsage, maxContext)) {
|
|
109
|
+
const ratio = computeRatio(currentUsage, maxContext);
|
|
110
|
+
return { compacted: false, reason: "below_threshold", ratio };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const ratio = computeRatio(currentUsage, maxContext);
|
|
114
|
+
return {
|
|
115
|
+
compacted: true,
|
|
116
|
+
sessionId,
|
|
117
|
+
threshold: compactionThreshold,
|
|
118
|
+
preservedRecent: preserveRecent,
|
|
119
|
+
atMessages: messageCount,
|
|
120
|
+
ratio,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Return the current compaction threshold (0.0–1.0).
|
|
126
|
+
*
|
|
127
|
+
* @returns {number}
|
|
128
|
+
*/
|
|
129
|
+
export function getCompactionThreshold() {
|
|
130
|
+
return compactionThreshold;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Set the compaction threshold. Validates the new value is in the range
|
|
135
|
+
* `[0.1, 1.0]` and is a finite number. Throws on invalid input.
|
|
136
|
+
*
|
|
137
|
+
* The minimum of 0.1 prevents pathological "compact at 10%" configurations
|
|
138
|
+
* that would shred the conversation on the first reply. The maximum of 1.0
|
|
139
|
+
* means "compact only when the context is full" — anything above 1.0 would
|
|
140
|
+
* mean "never compact", which `shouldCompact` already handles correctly, so
|
|
141
|
+
* we reject it for clarity.
|
|
142
|
+
*
|
|
143
|
+
* @param {number} value
|
|
144
|
+
* @returns {void}
|
|
145
|
+
*/
|
|
146
|
+
export function setCompactionThreshold(value) {
|
|
147
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
148
|
+
throw new Error(`Invalid compaction threshold: ${value} (must be a finite number)`);
|
|
149
|
+
}
|
|
150
|
+
if (value < MIN_THRESHOLD || value > MAX_THRESHOLD) {
|
|
151
|
+
throw new Error(
|
|
152
|
+
`Invalid compaction threshold: ${value} (must be in [${MIN_THRESHOLD}, ${MAX_THRESHOLD}])`,
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
compactionThreshold = value;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Reset the threshold and preserve-count to their defaults. Exposed for
|
|
160
|
+
* tests and for plugin re-init (so a hot-reload doesn't carry stale state).
|
|
161
|
+
*
|
|
162
|
+
* @returns {void}
|
|
163
|
+
*/
|
|
164
|
+
export function resetCompactionDefaults() {
|
|
165
|
+
compactionThreshold = 0.5;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Return the number of recent messages that the default policy preserves
|
|
170
|
+
* verbatim when compacting.
|
|
171
|
+
*
|
|
172
|
+
* @returns {number}
|
|
173
|
+
*/
|
|
174
|
+
export function getDefaultPreserveRecent() {
|
|
175
|
+
return PRESERVE_RECENT_MESSAGES_DEFAULT;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// --- Internal helpers -----------------------------------------------------
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Compute `usage.total / maxContext`, or `null` when either input is
|
|
182
|
+
* missing/invalid. Returns a number in `[0, +Infinity)` for valid inputs.
|
|
183
|
+
*
|
|
184
|
+
* @param {{ total?: number } | null | undefined} usage
|
|
185
|
+
* @param {number | null | undefined} maxContext
|
|
186
|
+
* @returns {number | null}
|
|
187
|
+
*/
|
|
188
|
+
function computeRatio(usage, maxContext) {
|
|
189
|
+
if (!usage || typeof usage.total !== "number") return null;
|
|
190
|
+
if (typeof maxContext !== "number" || maxContext <= 0) return null;
|
|
191
|
+
return usage.total / maxContext;
|
|
192
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* compaction.test.ts
|
|
3
|
+
*
|
|
4
|
+
* Spec contract for the compaction gate (see src/compaction.mjs):
|
|
5
|
+
* - `shouldCompact` returns false below 50%, true at and above 50%.
|
|
6
|
+
* - `shouldCompact` is defensive: null usage, undefined usage.total, and
|
|
7
|
+
* non-positive maxContext all return false (no false positives).
|
|
8
|
+
* - `maybeCompactSession` returns `{ compacted: false, reason: "below_threshold" }`
|
|
9
|
+
* when below the gate.
|
|
10
|
+
* - `maybeCompactSession` returns `{ compacted: true, sessionId, threshold, … }`
|
|
11
|
+
* when at/over the gate.
|
|
12
|
+
* - The default threshold is 0.5.
|
|
13
|
+
* - `setCompactionThreshold` rejects out-of-range values with a throw;
|
|
14
|
+
* accepts in-range values silently.
|
|
15
|
+
* - State leaks between tests are not allowed — every test that mutates
|
|
16
|
+
* the threshold calls `resetCompactionDefaults()` in its teardown
|
|
17
|
+
* (bun:test does not have a global afterEach, so we use try/finally).
|
|
18
|
+
*
|
|
19
|
+
* Tests use `bun:test` to match the rest of the plugin suite (see
|
|
20
|
+
* `tests/loop.test.ts`, `tests/options.test.ts`, etc.).
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import {
|
|
24
|
+
describe,
|
|
25
|
+
test,
|
|
26
|
+
expect,
|
|
27
|
+
beforeEach,
|
|
28
|
+
afterEach,
|
|
29
|
+
} from "bun:test";
|
|
30
|
+
|
|
31
|
+
import {
|
|
32
|
+
shouldCompact,
|
|
33
|
+
maybeCompactSession,
|
|
34
|
+
getCompactionThreshold,
|
|
35
|
+
setCompactionThreshold,
|
|
36
|
+
resetCompactionDefaults,
|
|
37
|
+
} from "../src/compaction.mjs";
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Bun:test does not expose a global `afterEach`/`beforeEach` reset hook
|
|
41
|
+
* that runs across describe blocks, so we wire per-block setup/teardown
|
|
42
|
+
* via the standard `beforeEach`/`afterEach` imports. We also reset on
|
|
43
|
+
* entry to each test as a belt-and-braces guarantee that no leak from a
|
|
44
|
+
* prior test (run in the same process by `bun test`) can poison state.
|
|
45
|
+
*/
|
|
46
|
+
beforeEach(() => {
|
|
47
|
+
resetCompactionDefaults();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
afterEach(() => {
|
|
51
|
+
resetCompactionDefaults();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe("shouldCompact", () => {
|
|
55
|
+
test("does not compact below 50%", () => {
|
|
56
|
+
expect(shouldCompact({ total: 40000 }, 100000)).toBe(false);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("does not compact at 49.99%", () => {
|
|
60
|
+
expect(shouldCompact({ total: 49999 }, 100000)).toBe(false);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("compacts at exactly 50%", () => {
|
|
64
|
+
expect(shouldCompact({ total: 50000 }, 100000)).toBe(true);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test("compacts above 50%", () => {
|
|
68
|
+
expect(shouldCompact({ total: 80000 }, 100000)).toBe(true);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test("compacts at 100% (full context)", () => {
|
|
72
|
+
expect(shouldCompact({ total: 100000 }, 100000)).toBe(true);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("does not compact with null usage", () => {
|
|
76
|
+
expect(shouldCompact(null, 100000)).toBe(false);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test("does not compact with undefined usage", () => {
|
|
80
|
+
expect(shouldCompact(undefined, 100000)).toBe(false);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("does not compact when usage.total is missing", () => {
|
|
84
|
+
expect(shouldCompact({}, 100000)).toBe(false);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test("does not compact with non-positive maxContext", () => {
|
|
88
|
+
expect(shouldCompact({ total: 50000 }, 0)).toBe(false);
|
|
89
|
+
expect(shouldCompact({ total: 50000 }, -1)).toBe(false);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test("respects a non-default threshold (0.7)", () => {
|
|
93
|
+
setCompactionThreshold(0.7);
|
|
94
|
+
expect(shouldCompact({ total: 60000 }, 100000)).toBe(false);
|
|
95
|
+
expect(shouldCompact({ total: 70000 }, 100000)).toBe(true);
|
|
96
|
+
expect(shouldCompact({ total: 80000 }, 100000)).toBe(true);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe("getCompactionThreshold / setCompactionThreshold", () => {
|
|
101
|
+
test("default threshold is 0.5", () => {
|
|
102
|
+
expect(getCompactionThreshold()).toBe(0.5);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test("setCompactionThreshold rejects 0 (below minimum)", () => {
|
|
106
|
+
expect(() => setCompactionThreshold(0)).toThrow(/Invalid compaction threshold/);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test("setCompactionThreshold rejects 0.05 (below minimum 0.1)", () => {
|
|
110
|
+
expect(() => setCompactionThreshold(0.05)).toThrow(/Invalid compaction threshold/);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test("setCompactionThreshold rejects 1.5 (above maximum)", () => {
|
|
114
|
+
expect(() => setCompactionThreshold(1.5)).toThrow(/Invalid compaction threshold/);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test("setCompactionThreshold rejects NaN", () => {
|
|
118
|
+
expect(() => setCompactionThreshold(Number.NaN)).toThrow(/Invalid compaction threshold/);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test("setCompactionThreshold rejects Infinity", () => {
|
|
122
|
+
expect(() => setCompactionThreshold(Number.POSITIVE_INFINITY)).toThrow(
|
|
123
|
+
/Invalid compaction threshold/,
|
|
124
|
+
);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test("setCompactionThreshold rejects non-number values", () => {
|
|
128
|
+
expect(() => setCompactionThreshold("0.5" as unknown as number)).toThrow(
|
|
129
|
+
/Invalid compaction threshold/,
|
|
130
|
+
);
|
|
131
|
+
expect(() => setCompactionThreshold(null as unknown as number)).toThrow(
|
|
132
|
+
/Invalid compaction threshold/,
|
|
133
|
+
);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test("setCompactionThreshold accepts 0.1 (lower bound)", () => {
|
|
137
|
+
expect(() => setCompactionThreshold(0.1)).not.toThrow();
|
|
138
|
+
expect(getCompactionThreshold()).toBe(0.1);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test("setCompactionThreshold accepts 1.0 (upper bound)", () => {
|
|
142
|
+
expect(() => setCompactionThreshold(1.0)).not.toThrow();
|
|
143
|
+
expect(getCompactionThreshold()).toBe(1.0);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test("setCompactionThreshold accepts 0.7 (in-range)", () => {
|
|
147
|
+
expect(() => setCompactionThreshold(0.7)).not.toThrow();
|
|
148
|
+
expect(getCompactionThreshold()).toBe(0.7);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
describe("maybeCompactSession", () => {
|
|
153
|
+
test("returns below_threshold when under limit", async () => {
|
|
154
|
+
const r = await maybeCompactSession({
|
|
155
|
+
sessionId: "s1",
|
|
156
|
+
messageCount: 5,
|
|
157
|
+
currentUsage: { total: 30000 },
|
|
158
|
+
maxContext: 100000,
|
|
159
|
+
summarizer: async (texts) => texts.join(" "),
|
|
160
|
+
});
|
|
161
|
+
expect(r.compacted).toBe(false);
|
|
162
|
+
expect(r.reason).toBe("below_threshold");
|
|
163
|
+
expect(r.ratio).toBeCloseTo(0.3);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test("triggers when over limit", async () => {
|
|
167
|
+
const r = await maybeCompactSession({
|
|
168
|
+
sessionId: "s1",
|
|
169
|
+
messageCount: 100,
|
|
170
|
+
currentUsage: { total: 60000 },
|
|
171
|
+
maxContext: 100000,
|
|
172
|
+
summarizer: async () => "summary",
|
|
173
|
+
});
|
|
174
|
+
expect(r.compacted).toBe(true);
|
|
175
|
+
expect(r.sessionId).toBe("s1");
|
|
176
|
+
expect(r.atMessages).toBe(100);
|
|
177
|
+
expect(r.threshold).toBe(0.5);
|
|
178
|
+
expect(r.preservedRecent).toBe(10);
|
|
179
|
+
expect(r.ratio).toBeCloseTo(0.6);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
test("triggers at exactly the threshold (50000/100000 = 0.5)", async () => {
|
|
183
|
+
const r = await maybeCompactSession({
|
|
184
|
+
sessionId: "edge",
|
|
185
|
+
messageCount: 42,
|
|
186
|
+
currentUsage: { total: 50000 },
|
|
187
|
+
maxContext: 100000,
|
|
188
|
+
summarizer: async () => "",
|
|
189
|
+
});
|
|
190
|
+
expect(r.compacted).toBe(true);
|
|
191
|
+
expect(r.atMessages).toBe(42);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
test("respects a custom preserveRecent override", async () => {
|
|
195
|
+
const r = await maybeCompactSession({
|
|
196
|
+
sessionId: "s2",
|
|
197
|
+
messageCount: 200,
|
|
198
|
+
currentUsage: { total: 90000 },
|
|
199
|
+
maxContext: 100000,
|
|
200
|
+
summarizer: async () => "",
|
|
201
|
+
preserveRecent: 25,
|
|
202
|
+
});
|
|
203
|
+
expect(r.compacted).toBe(true);
|
|
204
|
+
expect(r.preservedRecent).toBe(25);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
test("respects a non-default threshold", async () => {
|
|
208
|
+
setCompactionThreshold(0.8);
|
|
209
|
+
const r1 = await maybeCompactSession({
|
|
210
|
+
sessionId: "s3",
|
|
211
|
+
messageCount: 50,
|
|
212
|
+
currentUsage: { total: 70000 },
|
|
213
|
+
maxContext: 100000,
|
|
214
|
+
summarizer: async () => "",
|
|
215
|
+
});
|
|
216
|
+
expect(r1.compacted).toBe(false);
|
|
217
|
+
|
|
218
|
+
const r2 = await maybeCompactSession({
|
|
219
|
+
sessionId: "s3",
|
|
220
|
+
messageCount: 50,
|
|
221
|
+
currentUsage: { total: 85000 },
|
|
222
|
+
maxContext: 100000,
|
|
223
|
+
summarizer: async () => "",
|
|
224
|
+
});
|
|
225
|
+
expect(r2.compacted).toBe(true);
|
|
226
|
+
expect(r2.threshold).toBe(0.8);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
test("does not invoke the summarizer when below threshold", async () => {
|
|
230
|
+
let called = false;
|
|
231
|
+
await maybeCompactSession({
|
|
232
|
+
sessionId: "s4",
|
|
233
|
+
messageCount: 10,
|
|
234
|
+
currentUsage: { total: 1000 },
|
|
235
|
+
maxContext: 100000,
|
|
236
|
+
summarizer: async () => {
|
|
237
|
+
called = true;
|
|
238
|
+
return "should-not-run";
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
expect(called).toBe(false);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
test("throws when sessionId is missing", async () => {
|
|
245
|
+
await expect(
|
|
246
|
+
maybeCompactSession({
|
|
247
|
+
sessionId: "",
|
|
248
|
+
messageCount: 1,
|
|
249
|
+
currentUsage: { total: 999999 },
|
|
250
|
+
maxContext: 100000,
|
|
251
|
+
summarizer: async () => "",
|
|
252
|
+
}),
|
|
253
|
+
).rejects.toThrow(/sessionId is required/);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
describe("resetCompactionDefaults", () => {
|
|
258
|
+
test("restores the threshold to 0.5 after a custom set", () => {
|
|
259
|
+
setCompactionThreshold(0.9);
|
|
260
|
+
expect(getCompactionThreshold()).toBe(0.9);
|
|
261
|
+
resetCompactionDefaults();
|
|
262
|
+
expect(getCompactionThreshold()).toBe(0.5);
|
|
263
|
+
});
|
|
264
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Cloudflare Deployment
|
|
2
|
+
|
|
3
|
+
This directory contains the scaffold files for deploying the Bizar dashboard
|
|
4
|
+
to Cloudflare Pages + Workers. Generated by `bizar deploy --to cloudflare`.
|
|
5
|
+
|
|
6
|
+
## Files
|
|
7
|
+
|
|
8
|
+
- `wrangler.toml` — Cloudflare Pages project configuration
|
|
9
|
+
- `functions/index.js` — Workers function entry (handles SPA routing)
|
|
10
|
+
- `public/` — Static dashboard bundle (built from `npm run build`)
|
|
11
|
+
|
|
12
|
+
## How it works
|
|
13
|
+
|
|
14
|
+
1. The dashboard is built with `npm run build` → `dist/`
|
|
15
|
+
2. Built assets are copied to `public/`
|
|
16
|
+
3. `wrangler.toml` configures the Pages project
|
|
17
|
+
4. `functions/index.js` handles SPA routing for non-asset paths
|
|
18
|
+
5. The deployment is pushed to Cloudflare via wrangler CLI or REST API
|
|
19
|
+
|
|
20
|
+
## Manual deployment
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Install wrangler
|
|
24
|
+
npm i -g wrangler
|
|
25
|
+
|
|
26
|
+
# Login to Cloudflare
|
|
27
|
+
wrangler login
|
|
28
|
+
|
|
29
|
+
# Deploy from the scaffold directory
|
|
30
|
+
cd bizar-deploy/cloudflare
|
|
31
|
+
npx wrangler pages deploy . --project-name bizar-dash
|
|
32
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Cloudflare Workers entry — Bizar dashboard
|
|
2
|
+
// This file becomes functions/index.js in the deployment.
|
|
3
|
+
|
|
4
|
+
export async function onRequest(context) {
|
|
5
|
+
const { request, env } = context;
|
|
6
|
+
const url = new URL(request.url);
|
|
7
|
+
|
|
8
|
+
// Serve static assets from Pages KV
|
|
9
|
+
if (url.pathname.startsWith("/assets/")) {
|
|
10
|
+
return env.ASSETS.fetch(request);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// SPA fallback — serve index.html for all non-asset routes
|
|
14
|
+
return env.ASSETS.fetch(new Request(url.origin + "/index.html", request));
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Bizar dashboard environment variables
|
|
2
|
+
# Copy this file to .env and fill in your values.
|
|
3
|
+
|
|
4
|
+
# Dashboard
|
|
5
|
+
# BIZAR_DASHBOARD_PORT=4097
|
|
6
|
+
# BIZAR_DASHBOARD_HOST=0.0.0.0
|
|
7
|
+
|
|
8
|
+
# OpenTelemetry (optional)
|
|
9
|
+
# BIZAR_OTEL=1
|
|
10
|
+
# OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
|
|
11
|
+
|
|
12
|
+
# Tailscale (optional)
|
|
13
|
+
# TAILSCALE_AUTHKEY=tskey-auth-xxxxxxxxxxxxxxxxxxxx
|
|
14
|
+
|
|
15
|
+
# Headroom context compression (optional)
|
|
16
|
+
# HEADROOM_ENABLED=1
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Docker Deployment
|
|
2
|
+
|
|
3
|
+
This directory contains the scaffold files for deploying the Bizar dashboard
|
|
4
|
+
as a Docker container. Generated by `bizar deploy --to docker`.
|
|
5
|
+
|
|
6
|
+
## Files
|
|
7
|
+
|
|
8
|
+
- `docker-compose.yml` — Docker Compose configuration for self-hosting
|
|
9
|
+
- `.env.template` — Environment variable template
|
|
10
|
+
|
|
11
|
+
## Prerequisites
|
|
12
|
+
|
|
13
|
+
- Docker Engine 24+ (or Docker Desktop)
|
|
14
|
+
- Docker Compose v2 (`docker compose` plugin)
|
|
15
|
+
- A container registry account (GitHub Container Registry, Docker Hub, etc.)
|
|
16
|
+
|
|
17
|
+
## How it works
|
|
18
|
+
|
|
19
|
+
The `bizar deploy --to docker` command:
|
|
20
|
+
|
|
21
|
+
1. Builds the Docker image using the project's `Dockerfile`
|
|
22
|
+
2. Tags it with `<registry>/<image-name>:<version>` and `:latest`
|
|
23
|
+
3. Pushes both tags to the registry
|
|
24
|
+
4. With `--compose`: generates `docker-compose.yml` + `.env.template`
|
|
25
|
+
|
|
26
|
+
## Self-hosting with Docker Compose
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Generate compose files
|
|
30
|
+
bizar deploy --to docker --compose
|
|
31
|
+
|
|
32
|
+
# Edit .env with your settings
|
|
33
|
+
cp .env.template .env
|
|
34
|
+
$EDITOR .env
|
|
35
|
+
|
|
36
|
+
# Start the dashboard
|
|
37
|
+
cd bizar-deploy/docker
|
|
38
|
+
docker compose up -d
|
|
39
|
+
|
|
40
|
+
# Check logs
|
|
41
|
+
docker compose logs -f
|
|
42
|
+
|
|
43
|
+
# Stop
|
|
44
|
+
docker compose down
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Manual build & push
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Build
|
|
51
|
+
docker build -t ghcr.io/my-org/bizar-dash:latest .
|
|
52
|
+
|
|
53
|
+
# Push
|
|
54
|
+
docker push ghcr.io/my-org/bizar-dash:latest
|
|
55
|
+
|
|
56
|
+
# Run
|
|
57
|
+
docker run -d -p 4097:4097 ghcr.io/my-org/bizar-dash:latest
|
|
58
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
version: "3.8"
|
|
2
|
+
|
|
3
|
+
services:
|
|
4
|
+
bizar-dash:
|
|
5
|
+
image: ghcr.io/your-org/bizar-dash:latest
|
|
6
|
+
container_name: bizar-dash
|
|
7
|
+
restart: unless-stopped
|
|
8
|
+
ports:
|
|
9
|
+
- "4097:4097"
|
|
10
|
+
- "4098:4098"
|
|
11
|
+
environment:
|
|
12
|
+
- BIZAR_DASHBOARD_PORT=4097
|
|
13
|
+
- BIZAR_DASHBOARD_HOST=0.0.0.0
|
|
14
|
+
- NODE_ENV=production
|
|
15
|
+
env_file:
|
|
16
|
+
- .env
|
|
17
|
+
volumes:
|
|
18
|
+
- bizar-config:/home/bizar/.config/bizar
|
|
19
|
+
- bizar-memory:/home/bizar/.local/share/bizar/memory
|
|
20
|
+
|
|
21
|
+
volumes:
|
|
22
|
+
bizar-config:
|
|
23
|
+
bizar-memory:
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Fly.io Deployment
|
|
2
|
+
|
|
3
|
+
This directory contains the scaffold file for deploying the Bizar dashboard
|
|
4
|
+
to Fly.io. Generated by `bizar deploy --to fly`.
|
|
5
|
+
|
|
6
|
+
## Files
|
|
7
|
+
|
|
8
|
+
- `fly.toml` — Fly.io application configuration
|
|
9
|
+
|
|
10
|
+
## Prerequisites
|
|
11
|
+
|
|
12
|
+
- [flyctl](https://fly.io/docs/getting-started/installing-flyctl/) installed
|
|
13
|
+
- A Fly.io account (sign up: `flyctl auth signup`)
|
|
14
|
+
- Dockerfile at the project root (already present in BizarHarness)
|
|
15
|
+
|
|
16
|
+
## How it works
|
|
17
|
+
|
|
18
|
+
1. `fly.toml` references the project's `Dockerfile` for building
|
|
19
|
+
2. The app is launched on Fly.io (if not already created)
|
|
20
|
+
3. `flyctl deploy` builds and deploys the container
|
|
21
|
+
4. The dashboard is served at `https://<app-name>.fly.dev`
|
|
22
|
+
|
|
23
|
+
## Manual deployment
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Login
|
|
27
|
+
flyctl auth login
|
|
28
|
+
|
|
29
|
+
# Launch (first time)
|
|
30
|
+
cd bizar-deploy/fly
|
|
31
|
+
flyctl launch --name bizar-dash --region iad --now
|
|
32
|
+
|
|
33
|
+
# Deploy (subsequent times)
|
|
34
|
+
flyctl deploy --app bizar-dash
|
|
35
|
+
```
|