@bastani/atomic 0.9.17 → 0.9.18-alpha.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/CHANGELOG.md +15 -0
- package/dist/builtin/intercom/index.bundle.mjs +349 -57517
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/index.bundle.mjs +28948 -58339
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/mcp/xdg-open +1267 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +7929 -78021
- package/dist/builtin/web-access/index.bundle.mjs +70791 -57707
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/builtin/adversarial-verification.js +0 -1
- package/dist/builtin/workflows/builtin/{chunk-3y1hmzw6.js → chunk-6v0yv8tj.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-w9c7rkrk.js → chunk-brerg33r.js} +5 -7
- package/dist/builtin/workflows/builtin/{chunk-bz1c9732.js → chunk-ngffz3y8.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-6rbajjf5.js → chunk-szz1ajz9.js} +1 -3
- package/dist/builtin/workflows/builtin/classify-and-act.js +0 -1
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +0 -1
- package/dist/builtin/workflows/builtin/generate-and-filter.js +0 -1
- package/dist/builtin/workflows/builtin/goal.js +2 -5
- package/dist/builtin/workflows/builtin/index.js +4 -7
- package/dist/builtin/workflows/builtin/loop-until-done.js +0 -1
- package/dist/builtin/workflows/builtin/open-claude-design.js +1 -4
- package/dist/builtin/workflows/builtin/ralph.js +2 -5
- package/dist/builtin/workflows/builtin/steering-context.js +0 -1
- package/dist/builtin/workflows/builtin/tournament.js +0 -1
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +39989 -81500
- package/dist/builtin/workflows/src/index.js +1253 -58524
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/split-loader.js +2 -0
- package/dist/bun/split-loader.js.map +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth-command.js.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/cli.js +5 -2
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts +19 -2
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +253 -74
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +8 -3
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts +2 -7
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +1 -35
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +2 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +2 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-guidance.js.map +1 -1
- package/dist/core/auth-storage-backends.js.map +1 -1
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/builtin-packages.d.ts +8 -0
- package/dist/core/builtin-packages.d.ts.map +1 -1
- package/dist/core/builtin-packages.js +11 -5
- package/dist/core/builtin-packages.js.map +1 -1
- package/dist/core/event-bus.d.ts +11 -0
- package/dist/core/event-bus.d.ts.map +1 -1
- package/dist/core/event-bus.js +96 -0
- package/dist/core/event-bus.js.map +1 -1
- package/dist/core/experimental.js.map +1 -1
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/extensions/builtin-extension-entry-labels.d.ts +6 -0
- package/dist/core/extensions/builtin-extension-entry-labels.d.ts.map +1 -0
- package/dist/core/extensions/builtin-extension-entry-labels.js +22 -0
- package/dist/core/extensions/builtin-extension-entry-labels.js.map +1 -0
- package/dist/core/extensions/host-module-bridge.d.ts +22 -0
- package/dist/core/extensions/host-module-bridge.d.ts.map +1 -0
- package/dist/core/extensions/host-module-bridge.js +39 -0
- package/dist/core/extensions/host-module-bridge.js.map +1 -0
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +2 -2
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/loader-discovery.js.map +1 -1
- package/dist/core/extensions/loader-host-modules.d.ts +10 -0
- package/dist/core/extensions/loader-host-modules.d.ts.map +1 -0
- package/dist/core/extensions/loader-host-modules.js +88 -0
- package/dist/core/extensions/loader-host-modules.js.map +1 -0
- package/dist/core/extensions/loader-runtime.d.ts.map +1 -1
- package/dist/core/extensions/loader-runtime.js +1 -0
- package/dist/core/extensions/loader-runtime.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts +5 -2
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +51 -71
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +1 -1
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/native-builtin-entries.d.ts +6 -0
- package/dist/core/extensions/native-builtin-entries.d.ts.map +1 -0
- package/dist/core/extensions/native-builtin-entries.js +23 -0
- package/dist/core/extensions/native-builtin-entries.js.map +1 -0
- package/dist/core/extensions/runtime-types.d.ts +2 -0
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/lifecycle-timings.d.ts +21 -0
- package/dist/core/lifecycle-timings.d.ts.map +1 -0
- package/dist/core/lifecycle-timings.js +57 -0
- package/dist/core/lifecycle-timings.js.map +1 -0
- package/dist/core/mandatory-resource-loader.d.ts.map +1 -1
- package/dist/core/mandatory-resource-loader.js +43 -0
- package/dist/core/mandatory-resource-loader.js.map +1 -1
- package/dist/core/model-runtime.d.ts +8 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +82 -0
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/package-manager-auto-resources.js.map +1 -1
- package/dist/core/package-manager-env.js.map +1 -1
- package/dist/core/package-manager-git.js.map +1 -1
- package/dist/core/package-manager-manifest.js.map +1 -1
- package/dist/core/package-manager-npm.js.map +1 -1
- package/dist/core/package-manager-paths.js.map +1 -1
- package/dist/core/package-manager-resolver.js.map +1 -1
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/prompt-templates-async.js.map +1 -1
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-attribution.js.map +1 -1
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader-assets.js.map +1 -1
- package/dist/core/resource-loader-context-files.js.map +1 -1
- package/dist/core/resource-loader-core.d.ts +5 -1
- package/dist/core/resource-loader-core.d.ts.map +1 -1
- package/dist/core/resource-loader-core.js +90 -1
- package/dist/core/resource-loader-core.js.map +1 -1
- package/dist/core/resource-loader-discovery.js.map +1 -1
- package/dist/core/resource-loader-paths.js.map +1 -1
- package/dist/core/resource-loader-source-info.js.map +1 -1
- package/dist/core/resource-loader-types.d.ts +16 -0
- package/dist/core/resource-loader-types.d.ts.map +1 -1
- package/dist/core/resource-loader-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +4 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-paths.js.map +1 -1
- package/dist/core/settings-manager-core.d.ts +6 -0
- package/dist/core/settings-manager-core.d.ts.map +1 -1
- package/dist/core/settings-manager-core.js +24 -0
- package/dist/core/settings-manager-core.js.map +1 -1
- package/dist/core/settings-manager-ui-accessors.js.map +1 -1
- package/dist/core/settings-storage.js.map +1 -1
- package/dist/core/skills-async.js.map +1 -1
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +0 -6
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/telemetry.js.map +1 -1
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/powershell.js.map +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/session-temp-cleanup.js.map +1 -1
- package/dist/core/tools/session-temp-dir.js.map +1 -1
- package/dist/core/tools/todos-paths.js.map +1 -1
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main-deferred-startup.d.ts +16 -0
- package/dist/main-deferred-startup.d.ts.map +1 -1
- package/dist/main-deferred-startup.js +14 -0
- package/dist/main-deferred-startup.js.map +1 -1
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +41 -22
- package/dist/main.js.map +1 -1
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/chat-input-actions.js.map +1 -1
- package/dist/modes/interactive/components/config-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/config-selector-project-scope.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/startup-identity.d.ts.map +1 -1
- package/dist/modes/interactive/components/startup-identity.js +4 -0
- package/dist/modes/interactive/components/startup-identity.js.map +1 -1
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.js +13 -5
- package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +2 -5
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +8 -8
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-onboarding.js +1 -1
- package/dist/modes/interactive/interactive-onboarding.js.map +1 -1
- package/dist/modes/interactive/interactive-prompt-restore.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-prompt-restore.js +2 -1
- package/dist/modes/interactive/interactive-prompt-restore.js.map +1 -1
- package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +2 -0
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-disclosure.js +21 -53
- package/dist/modes/interactive/interactive-resource-disclosure.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-paths.js +29 -5
- package/dist/modes/interactive/interactive-resource-paths.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.js +66 -69
- package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
- package/dist/modes/interactive/interactive-startup-chat-container.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup-chat-container.js +2 -0
- package/dist/modes/interactive/interactive-startup-chat-container.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts +2 -0
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +30 -10
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-tui.js +12 -2
- package/dist/modes/interactive/interactive-tui.js.map +1 -1
- package/dist/modes/interactive/theme/global-theme.js.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.js.map +1 -1
- package/dist/modes/interactive-engine/create-isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/engine-child-liveness.d.ts +2 -0
- package/dist/modes/interactive-engine/engine-child-liveness.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-child-liveness.js +16 -2
- package/dist/modes/interactive-engine/engine-child-liveness.js.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
- package/dist/modes/interactive-engine/engine-monitor.d.ts +5 -0
- package/dist/modes/interactive-engine/engine-monitor.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-monitor.js +24 -0
- package/dist/modes/interactive-engine/engine-monitor.js.map +1 -1
- package/dist/modes/interactive-engine/engine-render-service.js.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +3 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.js +6 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +21 -2
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +160 -7
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +9 -4
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +8 -4
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/interactive-engine/resource-readiness-error.d.ts +6 -0
- package/dist/modes/interactive-engine/resource-readiness-error.d.ts.map +1 -0
- package/dist/modes/interactive-engine/resource-readiness-error.js +11 -0
- package/dist/modes/interactive-engine/resource-readiness-error.js.map +1 -0
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +3 -0
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +1 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +5 -1
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts +4 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +59 -18
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +4 -13
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +31 -2
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-resource-readiness.d.ts +11 -0
- package/dist/modes/rpc/rpc-resource-readiness.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-resource-readiness.js +51 -0
- package/dist/modes/rpc/rpc-resource-readiness.js.map +1 -0
- package/dist/modes/rpc/rpc-session-binding.d.ts +2 -0
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.js +21 -0
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +7 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli-parser.js.map +1 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/rpc-entry.js.map +1 -1
- package/dist/self-update-plan.js.map +1 -1
- package/dist/utils/changelog.d.ts +1 -1
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/module-require.js.map +1 -1
- package/dist/utils/pi-user-agent.js.map +1 -1
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.js.map +1 -1
- package/dist/utils/windows-self-update.js.map +1 -1
- package/docs/development.md +28 -1
- package/docs/extensions.md +5 -3
- package/docs/quickstart.md +1 -3
- package/docs/sdk.md +2 -0
- package/docs/usage.md +3 -1
- package/docs/windows.md +8 -0
- package/npm-shrinkwrap.json +32 -32
- package/package.json +4 -4
- package/dist/builtin/workflows/builtin/chunk-4febxsv4.js +0 -264
- package/dist/builtin/workflows/builtin/chunk-5wgwscd0.js +0 -4
- package/dist/builtin/workflows/builtin/chunk-dattsgxg.js +0 -529
- package/dist/builtin/workflows/builtin/chunk-gdx0avpx.js +0 -70082
- package/dist/builtin/workflows/builtin/chunk-qx2ptjs3.js +0 -215
- package/dist/builtin/workflows/builtin/chunk-x2ghn0je.js +0 -4110
- package/dist/core/atomic-guide-command.d.ts +0 -41
- package/dist/core/atomic-guide-command.d.ts.map +0 -1
- package/dist/core/atomic-guide-command.js +0 -311
- package/dist/core/atomic-guide-command.js.map +0 -1
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
APP_NAME,
|
|
3
|
-
SessionManager,
|
|
4
|
-
getExportTemplateDir,
|
|
5
|
-
getResolvedThemeColors,
|
|
6
|
-
getThemeExportColors,
|
|
7
|
-
normalizePath,
|
|
8
|
-
resolvePath
|
|
9
|
-
} from "./chunk-x2ghn0je.js";
|
|
10
|
-
import"./chunk-5wgwscd0.js";
|
|
11
|
-
|
|
12
|
-
// src/core/export-html/index.ts
|
|
13
|
-
import { existsSync, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
14
|
-
import { basename, join as join2 } from "path";
|
|
15
|
-
|
|
16
|
-
// src/core/export-html/template-script.ts
|
|
17
|
-
import { readFileSync } from "fs";
|
|
18
|
-
import { join } from "path";
|
|
19
|
-
var EXPORT_HTML_TEMPLATE_SCRIPT_CHUNKS = [
|
|
20
|
-
"data-tree.js",
|
|
21
|
-
"tree-filter-render.js",
|
|
22
|
-
"message-tools.js",
|
|
23
|
-
"entries-navigation.js",
|
|
24
|
-
"initialization.js"
|
|
25
|
-
];
|
|
26
|
-
function readExportHtmlTemplateScript(templateDir) {
|
|
27
|
-
return EXPORT_HTML_TEMPLATE_SCRIPT_CHUNKS.map((fileName) => readFileSync(join(templateDir, "template-js", fileName), "utf-8")).join("");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// src/core/export-html/index.ts
|
|
31
|
-
function parseColor(color) {
|
|
32
|
-
const hexMatch = color.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);
|
|
33
|
-
if (hexMatch) {
|
|
34
|
-
return {
|
|
35
|
-
r: Number.parseInt(hexMatch[1], 16),
|
|
36
|
-
g: Number.parseInt(hexMatch[2], 16),
|
|
37
|
-
b: Number.parseInt(hexMatch[3], 16)
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
const rgbMatch = color.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);
|
|
41
|
-
if (rgbMatch) {
|
|
42
|
-
return {
|
|
43
|
-
r: Number.parseInt(rgbMatch[1], 10),
|
|
44
|
-
g: Number.parseInt(rgbMatch[2], 10),
|
|
45
|
-
b: Number.parseInt(rgbMatch[3], 10)
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
function getLuminance(r, g, b) {
|
|
51
|
-
const toLinear = (c) => {
|
|
52
|
-
const s = c / 255;
|
|
53
|
-
return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
|
|
54
|
-
};
|
|
55
|
-
return 0.2126 * toLinear(r) + 0.7152 * toLinear(g) + 0.0722 * toLinear(b);
|
|
56
|
-
}
|
|
57
|
-
function adjustBrightness(color, factor) {
|
|
58
|
-
const parsed = parseColor(color);
|
|
59
|
-
if (!parsed)
|
|
60
|
-
return color;
|
|
61
|
-
const adjust = (c) => Math.min(255, Math.max(0, Math.round(c * factor)));
|
|
62
|
-
return `rgb(${adjust(parsed.r)}, ${adjust(parsed.g)}, ${adjust(parsed.b)})`;
|
|
63
|
-
}
|
|
64
|
-
function deriveExportColors(baseColor) {
|
|
65
|
-
const parsed = parseColor(baseColor);
|
|
66
|
-
if (!parsed) {
|
|
67
|
-
return {
|
|
68
|
-
pageBg: "rgb(24, 24, 30)",
|
|
69
|
-
cardBg: "rgb(30, 30, 36)",
|
|
70
|
-
infoBg: "rgb(60, 55, 40)"
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
const luminance = getLuminance(parsed.r, parsed.g, parsed.b);
|
|
74
|
-
const isLight = luminance > 0.5;
|
|
75
|
-
if (isLight) {
|
|
76
|
-
return {
|
|
77
|
-
pageBg: adjustBrightness(baseColor, 0.96),
|
|
78
|
-
cardBg: baseColor,
|
|
79
|
-
infoBg: `rgb(${Math.min(255, parsed.r + 10)}, ${Math.min(255, parsed.g + 5)}, ${Math.max(0, parsed.b - 20)})`
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
return {
|
|
83
|
-
pageBg: adjustBrightness(baseColor, 0.7),
|
|
84
|
-
cardBg: adjustBrightness(baseColor, 0.85),
|
|
85
|
-
infoBg: `rgb(${Math.min(255, parsed.r + 20)}, ${Math.min(255, parsed.g + 15)}, ${parsed.b})`
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
function generateThemeVars(themeName) {
|
|
89
|
-
const colors = getResolvedThemeColors(themeName);
|
|
90
|
-
const lines = [];
|
|
91
|
-
for (const [key, value] of Object.entries(colors)) {
|
|
92
|
-
lines.push(`--${key}: ${value};`);
|
|
93
|
-
}
|
|
94
|
-
const themeExport = getThemeExportColors(themeName);
|
|
95
|
-
const userMessageBg = colors.userMessageBg || "#343541";
|
|
96
|
-
const derivedColors = deriveExportColors(userMessageBg);
|
|
97
|
-
lines.push(`--exportPageBg: ${themeExport.pageBg ?? derivedColors.pageBg};`);
|
|
98
|
-
lines.push(`--exportCardBg: ${themeExport.cardBg ?? derivedColors.cardBg};`);
|
|
99
|
-
lines.push(`--exportInfoBg: ${themeExport.infoBg ?? derivedColors.infoBg};`);
|
|
100
|
-
return lines.join(`
|
|
101
|
-
`);
|
|
102
|
-
}
|
|
103
|
-
function generateHtml(sessionData, themeName) {
|
|
104
|
-
const templateDir = getExportTemplateDir();
|
|
105
|
-
const template = readFileSync2(join2(templateDir, "template.html"), "utf-8");
|
|
106
|
-
const templateCss = readFileSync2(join2(templateDir, "template.css"), "utf-8");
|
|
107
|
-
const templateJs = readExportHtmlTemplateScript(templateDir);
|
|
108
|
-
const markedJs = readFileSync2(join2(templateDir, "vendor", "marked.min.js"), "utf-8");
|
|
109
|
-
const hljsJs = readFileSync2(join2(templateDir, "vendor", "highlight.min.js"), "utf-8");
|
|
110
|
-
const themeVars = generateThemeVars(themeName);
|
|
111
|
-
const colors = getResolvedThemeColors(themeName);
|
|
112
|
-
const themeExport = getThemeExportColors(themeName);
|
|
113
|
-
const derivedExportColors = deriveExportColors(colors.userMessageBg || "#343541");
|
|
114
|
-
const bodyBg = themeExport.pageBg ?? derivedExportColors.pageBg;
|
|
115
|
-
const containerBg = themeExport.cardBg ?? derivedExportColors.cardBg;
|
|
116
|
-
const infoBg = themeExport.infoBg ?? derivedExportColors.infoBg;
|
|
117
|
-
const sessionDataBase64 = Buffer.from(JSON.stringify(sessionData)).toString("base64");
|
|
118
|
-
const css = templateCss.replace("{{THEME_VARS}}", themeVars).replace("{{BODY_BG}}", bodyBg).replace("{{CONTAINER_BG}}", containerBg).replace("{{INFO_BG}}", infoBg);
|
|
119
|
-
return template.replace("{{CSS}}", css).replace("{{JS}}", templateJs).replace("{{SESSION_DATA}}", sessionDataBase64).replace("{{MARKED_JS}}", markedJs).replace("{{HIGHLIGHT_JS}}", hljsJs);
|
|
120
|
-
}
|
|
121
|
-
var TEMPLATE_RENDERED_TOOLS = new Set(["bash", "read", "write", "edit", "ls"]);
|
|
122
|
-
function preRenderCustomTools(entries, toolRenderer) {
|
|
123
|
-
const renderedTools = {};
|
|
124
|
-
for (const entry of entries) {
|
|
125
|
-
if (entry.type !== "message")
|
|
126
|
-
continue;
|
|
127
|
-
const msg = entry.message;
|
|
128
|
-
if (msg.role === "assistant" && Array.isArray(msg.content)) {
|
|
129
|
-
for (const block of msg.content) {
|
|
130
|
-
if (block.type === "toolCall" && !TEMPLATE_RENDERED_TOOLS.has(block.name)) {
|
|
131
|
-
const callHtml = toolRenderer.renderCall(block.id, block.name, block.arguments);
|
|
132
|
-
if (callHtml) {
|
|
133
|
-
renderedTools[block.id] = { callHtml };
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
if (msg.role === "toolResult" && msg.toolCallId) {
|
|
139
|
-
const toolName = msg.toolName || "";
|
|
140
|
-
const existing = renderedTools[msg.toolCallId];
|
|
141
|
-
if (existing || !TEMPLATE_RENDERED_TOOLS.has(toolName)) {
|
|
142
|
-
const rendered = toolRenderer.renderResult(msg.toolCallId, toolName, msg.content, msg.details, msg.isError || false);
|
|
143
|
-
if (rendered) {
|
|
144
|
-
renderedTools[msg.toolCallId] = {
|
|
145
|
-
...existing,
|
|
146
|
-
resultHtmlCollapsed: rendered.collapsed,
|
|
147
|
-
resultHtmlExpanded: rendered.expanded
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return renderedTools;
|
|
154
|
-
}
|
|
155
|
-
async function exportSessionToHtml(sm, state, options) {
|
|
156
|
-
const opts = typeof options === "string" ? { outputPath: options } : options || {};
|
|
157
|
-
const sessionFile = sm.getSessionFile();
|
|
158
|
-
if (!sessionFile) {
|
|
159
|
-
throw new Error("Cannot export in-memory session to HTML");
|
|
160
|
-
}
|
|
161
|
-
if (!existsSync(sessionFile)) {
|
|
162
|
-
throw new Error("Nothing to export yet - start a conversation first");
|
|
163
|
-
}
|
|
164
|
-
const entries = sm.getEntries();
|
|
165
|
-
let renderedTools;
|
|
166
|
-
if (opts.toolRenderer) {
|
|
167
|
-
renderedTools = preRenderCustomTools(entries, opts.toolRenderer);
|
|
168
|
-
if (Object.keys(renderedTools).length === 0) {
|
|
169
|
-
renderedTools = undefined;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
const sessionData = {
|
|
173
|
-
header: sm.getHeader(),
|
|
174
|
-
entries,
|
|
175
|
-
leafId: sm.getLeafId(),
|
|
176
|
-
systemPrompt: state?.systemPrompt,
|
|
177
|
-
tools: state?.tools?.map((t) => ({ name: t.name, description: t.description, parameters: t.parameters })),
|
|
178
|
-
renderedTools
|
|
179
|
-
};
|
|
180
|
-
const html = generateHtml(sessionData, opts.themeName);
|
|
181
|
-
let outputPath = opts.outputPath ? normalizePath(opts.outputPath) : undefined;
|
|
182
|
-
if (!outputPath) {
|
|
183
|
-
const sessionBasename = basename(sessionFile, ".jsonl");
|
|
184
|
-
outputPath = `${APP_NAME}-session-${sessionBasename}.html`;
|
|
185
|
-
}
|
|
186
|
-
writeFileSync(outputPath, html, "utf8");
|
|
187
|
-
return outputPath;
|
|
188
|
-
}
|
|
189
|
-
async function exportFromFile(inputPath, options) {
|
|
190
|
-
const opts = typeof options === "string" ? { outputPath: options } : options || {};
|
|
191
|
-
const resolvedInputPath = resolvePath(inputPath);
|
|
192
|
-
if (!existsSync(resolvedInputPath)) {
|
|
193
|
-
throw new Error(`File not found: ${resolvedInputPath}`);
|
|
194
|
-
}
|
|
195
|
-
const sm = SessionManager.open(resolvedInputPath);
|
|
196
|
-
const sessionData = {
|
|
197
|
-
header: sm.getHeader(),
|
|
198
|
-
entries: sm.getEntries(),
|
|
199
|
-
leafId: sm.getLeafId(),
|
|
200
|
-
systemPrompt: undefined,
|
|
201
|
-
tools: undefined
|
|
202
|
-
};
|
|
203
|
-
const html = generateHtml(sessionData, opts.themeName);
|
|
204
|
-
let outputPath = opts.outputPath ? normalizePath(opts.outputPath) : undefined;
|
|
205
|
-
if (!outputPath) {
|
|
206
|
-
const inputBasename = basename(resolvedInputPath, ".jsonl");
|
|
207
|
-
outputPath = `${APP_NAME}-session-${inputBasename}.html`;
|
|
208
|
-
}
|
|
209
|
-
writeFileSync(outputPath, html, "utf8");
|
|
210
|
-
return outputPath;
|
|
211
|
-
}
|
|
212
|
-
export {
|
|
213
|
-
exportFromFile,
|
|
214
|
-
exportSessionToHtml
|
|
215
|
-
};
|