@bastani/atomic 0.9.39 → 0.9.40-alpha.2
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 +35 -0
- package/dist/builtin/intercom/CHANGELOG.md +14 -0
- package/dist/builtin/intercom/broker/broker.ts +523 -72
- package/dist/builtin/intercom/broker/client.ts +136 -5
- package/dist/builtin/intercom/broker/database-wake-up-bus.ts +274 -0
- package/dist/builtin/intercom/broker/group-membership.ts +2 -2
- package/dist/builtin/intercom/broker/multinode-router.ts +1500 -0
- package/dist/builtin/intercom/broker/multinode-state-store.ts +569 -0
- package/dist/builtin/intercom/broker/open-broker-state.ts +160 -0
- package/dist/builtin/intercom/broker/paths.ts +6 -0
- package/dist/builtin/intercom/broker/pending-send-registry.ts +14 -0
- package/dist/builtin/intercom/broker/recipient-receipts.ts +93 -0
- package/dist/builtin/intercom/broker/restoring-recipients.ts +263 -0
- package/dist/builtin/intercom/broker/send-handler.ts +241 -25
- package/dist/builtin/intercom/broker/session-id-reclaim.ts +41 -0
- package/dist/builtin/intercom/broker/socket-writes.ts +47 -0
- package/dist/builtin/intercom/broker/spawn.ts +10 -2
- package/dist/builtin/intercom/broker/sql-held-send-store.ts +96 -0
- package/dist/builtin/intercom/broker/sql-known-session-store.ts +129 -0
- package/dist/builtin/intercom/broker/sql-lease-store.ts +194 -0
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +249 -0
- package/dist/builtin/intercom/broker/sql-pending-ask-store.ts +105 -0
- package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +295 -0
- package/dist/builtin/intercom/broker/sql-sent-message-authority.ts +126 -0
- package/dist/builtin/intercom/broker/supervisor-channel.ts +10 -0
- package/dist/builtin/intercom/broker/wake-up-bus.ts +60 -0
- package/dist/builtin/intercom/index.bundle.mjs +793 -91
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/retry-policy.ts +4 -0
- package/dist/builtin/intercom/session-target.ts +24 -0
- package/dist/builtin/intercom/types.ts +57 -3
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +31 -0
- package/dist/builtin/subagents/README.md +18 -12
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/agent-browser/SKILL.md +1 -1
- package/dist/builtin/subagents/skills/cua-driver/BROWSER.md +55 -8
- package/dist/builtin/subagents/skills/cua-driver/EMBEDDING.md +7 -2
- package/dist/builtin/subagents/skills/cua-driver/LINUX.md +7 -1
- package/dist/builtin/subagents/skills/cua-driver/MACOS.md +151 -27
- package/dist/builtin/subagents/skills/cua-driver/RUNTIME.md +1 -1
- package/dist/builtin/subagents/skills/cua-driver/SKILL.md +33 -17
- package/dist/builtin/subagents/skills/cua-driver/WINDOWS.md +5 -0
- package/dist/builtin/subagents/skills/cua-driver/WORKFLOW.md +46 -8
- package/dist/builtin/subagents/skills/subagent/SKILL.md +18 -20
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +8032 -6034
- package/dist/builtin/web-access/CHANGELOG.md +6 -0
- package/dist/builtin/web-access/README.md +1 -1
- package/dist/builtin/web-access/index.bundle.mjs +2 -5
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +24 -0
- package/dist/builtin/workflows/README.md +1 -1
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/skills/impeccable/SKILL.md +8 -8
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.native.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/audit.md +4 -2
- package/dist/builtin/workflows/skills/impeccable/reference/audit.native.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/critique.md +22 -9
- package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +2 -2
- package/dist/builtin/workflows/skills/impeccable/reference/distill.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/extract.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/harden.md +2 -4
- package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +4 -4
- package/dist/builtin/workflows/skills/impeccable/reference/live.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +6 -6
- package/dist/builtin/workflows/skills/impeccable/reference/onboard.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/optimize.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/overdrive.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/quieter.md +3 -3
- package/dist/builtin/workflows/skills/impeccable/reference/typeset.md +10 -0
- package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/VERSION +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/impeccable +6 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/impeccable.cmd +47 -22
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-dom.js +34 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-session.js +25 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +33 -8
- package/dist/builtin/workflows/src/durable/journal/resolution.d.ts +7 -7
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +22715 -22159
- package/dist/builtin/workflows/src/index.js +106 -35
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +17 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts +2 -0
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +6 -6
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +6 -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-persistent-custom-messages.d.ts +7 -2
- package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.js +29 -12
- package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
- package/dist/core/agent-session-recovery.d.ts +14 -0
- package/dist/core/agent-session-recovery.d.ts.map +1 -0
- package/dist/core/agent-session-recovery.js +83 -0
- package/dist/core/agent-session-recovery.js.map +1 -0
- package/dist/core/agent-session-tasks.d.ts.map +1 -1
- package/dist/core/agent-session-tasks.js +4 -6
- package/dist/core/agent-session-tasks.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +13 -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 +2 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +4 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +3 -2
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template.html +1 -0
- package/dist/core/export-html/template.js +37 -20
- package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
- package/dist/core/export-html/vendor/marked.min.js +76 -3
- package/dist/core/extensions/api-types.d.ts +6 -2
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/event-results.d.ts +21 -0
- package/dist/core/extensions/event-results.d.ts.map +1 -1
- package/dist/core/extensions/event-results.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +4 -0
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/runner-events.d.ts +9 -2
- package/dist/core/extensions/runner-events.d.ts.map +1 -1
- package/dist/core/extensions/runner-events.js +29 -0
- package/dist/core/extensions/runner-events.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +5 -3
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +7 -2
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +1 -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/extensions/session-events.d.ts +30 -2
- package/dist/core/extensions/session-events.d.ts.map +1 -1
- package/dist/core/extensions/session-events.js.map +1 -1
- package/dist/core/sdk-types.d.ts +3 -2
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +3 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-storage.d.ts.map +1 -1
- package/dist/core/session-storage.js +15 -9
- package/dist/core/session-storage.js.map +1 -1
- package/dist/core/storage/process-selection.d.ts +39 -0
- package/dist/core/storage/process-selection.d.ts.map +1 -0
- package/dist/core/storage/process-selection.js +154 -0
- package/dist/core/storage/process-selection.js.map +1 -0
- package/dist/core/storage/provider.d.ts +6 -1
- package/dist/core/storage/provider.d.ts.map +1 -1
- package/dist/core/storage/provider.js +3 -2
- package/dist/core/storage/provider.js.map +1 -1
- package/dist/core/storage/selection.d.ts +1 -1
- package/dist/core/storage/selection.d.ts.map +1 -1
- package/dist/core/storage/selection.js.map +1 -1
- package/dist/core/storage/session/jsonl-session-store.d.ts +2 -0
- package/dist/core/storage/session/jsonl-session-store.d.ts.map +1 -1
- package/dist/core/storage/session/jsonl-session-store.js +38 -2
- package/dist/core/storage/session/jsonl-session-store.js.map +1 -1
- package/dist/core/tasks/completion.d.ts +11 -2
- package/dist/core/tasks/completion.d.ts.map +1 -1
- package/dist/core/tasks/completion.js +40 -16
- package/dist/core/tasks/completion.js.map +1 -1
- package/dist/core/tasks/pause.d.ts +4 -1
- package/dist/core/tasks/pause.d.ts.map +1 -1
- package/dist/core/tasks/pause.js +8 -5
- package/dist/core/tasks/pause.js.map +1 -1
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +7 -1
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.js +11 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.d.ts +2 -0
- package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.js +2 -0
- package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +4 -0
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +2 -1
- 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-render-chat.js +3 -0
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +2 -0
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.d.ts +2 -1
- package/dist/modes/interactive/interactive-session-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +29 -0
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +4 -1
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive-engine/engine-args.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-args.js +4 -0
- package/dist/modes/interactive-engine/engine-args.js.map +1 -1
- package/dist/modes/interactive-engine/engine-render-service.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-render-service.js +4 -4
- package/dist/modes/interactive-engine/engine-render-service.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +4 -0
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/remote-renderer.js +1 -1
- package/dist/modes/interactive-engine/remote-renderer.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +4 -1
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js +4 -0
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +3 -0
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-command-timeouts.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-timeouts.js +1 -0
- package/dist/modes/rpc/rpc-command-timeouts.js.map +1 -1
- package/dist/modes/rpc/rpc-input-scheduler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-input-scheduler.js +6 -1
- package/dist/modes/rpc/rpc-input-scheduler.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +12 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +44 -11
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/tools-manager.js +1 -1
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/background-tasks.md +5 -3
- package/docs/computer-use.md +2 -2
- package/docs/environment-variables.md +4 -1
- package/docs/extensions/events.md +29 -2
- package/docs/getting-started/first-session.md +1 -1
- package/docs/guides/intercom.md +1 -1
- package/docs/intercom/operations.md +103 -1
- package/docs/intercom/reference.md +10 -3
- package/docs/intercom.md +8 -6
- package/docs/keybindings.md +1 -1
- package/docs/models.md +1 -1
- package/docs/providers.md +5 -3
- package/docs/reference/cli.md +5 -0
- package/docs/rpc/protocol.md +19 -0
- package/docs/rpc.md +3 -0
- package/docs/sdk/web-server.md +1 -1
- package/docs/sdk.md +5 -2
- package/docs/sessions.md +17 -1
- package/docs/settings.md +6 -4
- package/docs/skills.md +1 -1
- package/docs/storage.md +54 -3
- package/docs/subagents.md +49 -9
- package/docs/usage.md +1 -1
- package/docs/windows.md +14 -4
- package/docs/workflows/api-reference.md +1 -1
- package/docs/workflows/authoring.md +1 -1
- package/docs/workflows/operations.md +10 -6
- package/npm-shrinkwrap.json +40 -40
- package/package.json +6 -6
- package/dist/core/export-html/template-js/data-tree.js +0 -287
- package/dist/core/export-html/template-js/entries-navigation.js +0 -434
- package/dist/core/export-html/template-js/initialization.js +0 -335
- package/dist/core/export-html/template-js/message-tools.js +0 -428
- package/dist/core/export-html/template-js/tree-filter-render.js +0 -419
- package/dist/core/export-html/template-script.d.ts +0 -3
- package/dist/core/export-html/template-script.d.ts.map +0 -1
- package/dist/core/export-html/template-script.js +0 -13
- package/dist/core/export-html/template-script.js.map +0 -1
|
@@ -1,335 +0,0 @@
|
|
|
1
|
-
// ============================================================
|
|
2
|
-
// INITIALIZATION
|
|
3
|
-
// ============================================================
|
|
4
|
-
|
|
5
|
-
// Configure marked with syntax highlighting and TUI-compatible HTML handling
|
|
6
|
-
const strictStrikethroughRegex = /^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/;
|
|
7
|
-
|
|
8
|
-
marked.use({
|
|
9
|
-
breaks: true,
|
|
10
|
-
gfm: true,
|
|
11
|
-
tokenizer: {
|
|
12
|
-
// Treat HTML-like input as plain text so tags are shown verbatim,
|
|
13
|
-
// matching the TUI markdown renderer.
|
|
14
|
-
html() {
|
|
15
|
-
return undefined;
|
|
16
|
-
},
|
|
17
|
-
tag() {
|
|
18
|
-
return undefined;
|
|
19
|
-
},
|
|
20
|
-
del(src) {
|
|
21
|
-
const match = strictStrikethroughRegex.exec(src);
|
|
22
|
-
if (!match) return undefined;
|
|
23
|
-
return {
|
|
24
|
-
type: 'del',
|
|
25
|
-
raw: match[0],
|
|
26
|
-
text: match[2],
|
|
27
|
-
tokens: this.lexer.inlineTokens(match[2])
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
renderer: {
|
|
32
|
-
// Sanitize link URLs with a scheme allow-list. Browsers strip C0
|
|
33
|
-
// controls from schemes, so strip them before checking and emitting.
|
|
34
|
-
link(token) {
|
|
35
|
-
const href = sanitizeMarkdownUrl(token.href);
|
|
36
|
-
if (href === null) {
|
|
37
|
-
return this.parser.parseInline(token.tokens);
|
|
38
|
-
}
|
|
39
|
-
let out = '<a href="' + escapeHtml(href) + '"';
|
|
40
|
-
if (token.title) {
|
|
41
|
-
out += ' title="' + escapeHtml(token.title) + '"';
|
|
42
|
-
}
|
|
43
|
-
out += '>' + this.parser.parseInline(token.tokens) + '</a>';
|
|
44
|
-
return out;
|
|
45
|
-
},
|
|
46
|
-
// Sanitize image src URLs with the same scheme allow-list.
|
|
47
|
-
image(token) {
|
|
48
|
-
const href = sanitizeMarkdownUrl(token.href);
|
|
49
|
-
if (href === null) {
|
|
50
|
-
return escapeHtml(token.text || '');
|
|
51
|
-
}
|
|
52
|
-
let out = '<img src="' + escapeHtml(href) + '" alt="' + escapeHtml(token.text || '') + '"';
|
|
53
|
-
if (token.title) {
|
|
54
|
-
out += ' title="' + escapeHtml(token.title) + '"';
|
|
55
|
-
}
|
|
56
|
-
out += '>';
|
|
57
|
-
return out;
|
|
58
|
-
},
|
|
59
|
-
// Code blocks: syntax highlight, no HTML escaping
|
|
60
|
-
code(token) {
|
|
61
|
-
const code = token.text;
|
|
62
|
-
const lang = token.lang;
|
|
63
|
-
let highlighted;
|
|
64
|
-
if (lang && hljs.getLanguage(lang)) {
|
|
65
|
-
try {
|
|
66
|
-
highlighted = hljs.highlight(code, { language: lang }).value;
|
|
67
|
-
} catch {
|
|
68
|
-
highlighted = escapeHtml(code);
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
// Auto-detect language if not specified
|
|
72
|
-
try {
|
|
73
|
-
highlighted = hljs.highlightAuto(code).value;
|
|
74
|
-
} catch {
|
|
75
|
-
highlighted = escapeHtml(code);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return `<pre><code class="hljs">${highlighted}</code></pre>`;
|
|
79
|
-
},
|
|
80
|
-
// Inline code: escape HTML
|
|
81
|
-
codespan(token) {
|
|
82
|
-
return `<code>${escapeHtml(token.text)}</code>`;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// Simple marked parse (escaping handled in renderers)
|
|
88
|
-
function safeMarkedParse(text) {
|
|
89
|
-
return marked.parse(text);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Search input
|
|
93
|
-
const searchInput = document.getElementById('tree-search');
|
|
94
|
-
searchInput.addEventListener('input', (e) => {
|
|
95
|
-
searchQuery = e.target.value;
|
|
96
|
-
forceTreeRerender();
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// Filter buttons
|
|
100
|
-
document.querySelectorAll('.filter-btn').forEach(btn => {
|
|
101
|
-
btn.addEventListener('click', () => {
|
|
102
|
-
document.querySelectorAll('.filter-btn').forEach(b => b.classList.remove('active'));
|
|
103
|
-
btn.classList.add('active');
|
|
104
|
-
filterMode = btn.dataset.filter;
|
|
105
|
-
forceTreeRerender();
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
// Sidebar toggle
|
|
110
|
-
const sidebar = document.getElementById('sidebar');
|
|
111
|
-
const overlay = document.getElementById('sidebar-overlay');
|
|
112
|
-
const hamburger = document.getElementById('hamburger');
|
|
113
|
-
const sidebarResizer = document.getElementById('sidebar-resizer');
|
|
114
|
-
const SIDEBAR_WIDTH_STORAGE_KEY = 'pi-share:v1:sidebar-width';
|
|
115
|
-
const MIN_CONTENT_WIDTH = 320;
|
|
116
|
-
|
|
117
|
-
function isMobileLayout() {
|
|
118
|
-
return window.matchMedia('(max-width: 900px)').matches;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function getSidebarBounds() {
|
|
122
|
-
const rootStyles = getComputedStyle(document.documentElement);
|
|
123
|
-
const minWidth = parseFloat(rootStyles.getPropertyValue('--sidebar-min-width')) || 240;
|
|
124
|
-
const maxWidth = parseFloat(rootStyles.getPropertyValue('--sidebar-max-width')) || 720;
|
|
125
|
-
const viewportMaxWidth = window.innerWidth - MIN_CONTENT_WIDTH;
|
|
126
|
-
return {
|
|
127
|
-
minWidth,
|
|
128
|
-
maxWidth: Math.max(minWidth, Math.min(maxWidth, viewportMaxWidth))
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function clampSidebarWidth(width) {
|
|
133
|
-
const { minWidth, maxWidth } = getSidebarBounds();
|
|
134
|
-
return Math.max(minWidth, Math.min(maxWidth, width));
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function applySidebarWidth(width) {
|
|
138
|
-
document.documentElement.style.setProperty('--sidebar-width', `${Math.round(clampSidebarWidth(width))}px`);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function loadSidebarWidth() {
|
|
142
|
-
try {
|
|
143
|
-
const raw = localStorage.getItem(SIDEBAR_WIDTH_STORAGE_KEY);
|
|
144
|
-
if (raw === null) return null;
|
|
145
|
-
const width = Number(raw);
|
|
146
|
-
return Number.isFinite(width) ? width : null;
|
|
147
|
-
} catch {
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function saveSidebarWidth(width) {
|
|
153
|
-
try {
|
|
154
|
-
localStorage.setItem(SIDEBAR_WIDTH_STORAGE_KEY, String(Math.round(clampSidebarWidth(width))));
|
|
155
|
-
} catch {
|
|
156
|
-
// Ignore storage failures (e.g. private browsing restrictions)
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function setupSidebarResize() {
|
|
161
|
-
const savedWidth = loadSidebarWidth();
|
|
162
|
-
if (savedWidth !== null) {
|
|
163
|
-
applySidebarWidth(savedWidth);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (!sidebarResizer) return;
|
|
167
|
-
|
|
168
|
-
let cleanupDrag = null;
|
|
169
|
-
|
|
170
|
-
const stopDrag = (pointerId) => {
|
|
171
|
-
if (cleanupDrag) {
|
|
172
|
-
cleanupDrag(pointerId);
|
|
173
|
-
cleanupDrag = null;
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
sidebarResizer.addEventListener('pointerdown', (e) => {
|
|
178
|
-
if (isMobileLayout()) return;
|
|
179
|
-
|
|
180
|
-
e.preventDefault();
|
|
181
|
-
const startX = e.clientX;
|
|
182
|
-
const startWidth = sidebar.getBoundingClientRect().width;
|
|
183
|
-
document.body.classList.add('sidebar-resizing');
|
|
184
|
-
sidebarResizer.setPointerCapture?.(e.pointerId);
|
|
185
|
-
|
|
186
|
-
const onPointerMove = (event) => {
|
|
187
|
-
applySidebarWidth(startWidth + (event.clientX - startX));
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
cleanupDrag = (pointerIdToRelease) => {
|
|
191
|
-
document.body.classList.remove('sidebar-resizing');
|
|
192
|
-
sidebarResizer.releasePointerCapture?.(pointerIdToRelease);
|
|
193
|
-
window.removeEventListener('pointermove', onPointerMove);
|
|
194
|
-
window.removeEventListener('pointerup', onPointerUp);
|
|
195
|
-
window.removeEventListener('pointercancel', onPointerCancel);
|
|
196
|
-
saveSidebarWidth(sidebar.getBoundingClientRect().width);
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
const onPointerUp = (event) => stopDrag(event.pointerId);
|
|
200
|
-
const onPointerCancel = (event) => stopDrag(event.pointerId);
|
|
201
|
-
|
|
202
|
-
window.addEventListener('pointermove', onPointerMove);
|
|
203
|
-
window.addEventListener('pointerup', onPointerUp);
|
|
204
|
-
window.addEventListener('pointercancel', onPointerCancel);
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
sidebarResizer.addEventListener('dblclick', () => {
|
|
208
|
-
if (isMobileLayout()) return;
|
|
209
|
-
applySidebarWidth(400);
|
|
210
|
-
saveSidebarWidth(400);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
window.addEventListener('resize', () => {
|
|
214
|
-
if (isMobileLayout()) return;
|
|
215
|
-
applySidebarWidth(sidebar.getBoundingClientRect().width);
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
setupSidebarResize();
|
|
220
|
-
|
|
221
|
-
hamburger.addEventListener('click', () => {
|
|
222
|
-
sidebar.classList.add('open');
|
|
223
|
-
overlay.classList.add('open');
|
|
224
|
-
hamburger.style.display = 'none';
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
const closeSidebar = () => {
|
|
228
|
-
sidebar.classList.remove('open');
|
|
229
|
-
overlay.classList.remove('open');
|
|
230
|
-
hamburger.style.display = '';
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
overlay.addEventListener('click', closeSidebar);
|
|
234
|
-
document.getElementById('sidebar-close').addEventListener('click', closeSidebar);
|
|
235
|
-
|
|
236
|
-
// Toggle states
|
|
237
|
-
let thinkingExpanded = true;
|
|
238
|
-
let toolOutputsExpanded = false;
|
|
239
|
-
let showHiddenMessages = false;
|
|
240
|
-
|
|
241
|
-
function setHiddenMessagesVisible(visible) {
|
|
242
|
-
showHiddenMessages = visible;
|
|
243
|
-
document.body.classList.toggle('show-hidden-messages', visible);
|
|
244
|
-
const button = document.querySelector('[data-action="toggle-hidden-messages"]');
|
|
245
|
-
if (button) {
|
|
246
|
-
button.setAttribute('aria-pressed', String(visible));
|
|
247
|
-
button.textContent = visible ? 'Hide hidden messages' : 'Show hidden messages';
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
function setThinkingExpanded(expanded) {
|
|
252
|
-
thinkingExpanded = expanded;
|
|
253
|
-
document.querySelector('[data-action="toggle-thinking"]')?.setAttribute('aria-pressed', String(expanded));
|
|
254
|
-
document.querySelectorAll('.thinking-text').forEach(el => {
|
|
255
|
-
el.style.display = thinkingExpanded ? '' : 'none';
|
|
256
|
-
});
|
|
257
|
-
document.querySelectorAll('.thinking-collapsed').forEach(el => {
|
|
258
|
-
el.style.display = thinkingExpanded ? 'none' : 'block';
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function setToolOutputsExpanded(expanded) {
|
|
263
|
-
toolOutputsExpanded = expanded;
|
|
264
|
-
document.querySelector('[data-action="toggle-tools"]')?.setAttribute('aria-pressed', String(expanded));
|
|
265
|
-
document.querySelectorAll('.tool-output.expandable').forEach(el => {
|
|
266
|
-
el.classList.toggle('expanded', toolOutputsExpanded);
|
|
267
|
-
});
|
|
268
|
-
document.querySelectorAll('.compaction').forEach(el => {
|
|
269
|
-
el.classList.toggle('expanded', toolOutputsExpanded);
|
|
270
|
-
});
|
|
271
|
-
document.querySelectorAll('.skill-invocation').forEach(el => {
|
|
272
|
-
el.classList.toggle('expanded', toolOutputsExpanded);
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
const attachHeaderHandlers = () => {
|
|
277
|
-
document.querySelector('[data-action="toggle-thinking"]')?.addEventListener('click', () => {
|
|
278
|
-
setThinkingExpanded(!thinkingExpanded);
|
|
279
|
-
});
|
|
280
|
-
document.querySelector('[data-action="toggle-tools"]')?.addEventListener('click', () => {
|
|
281
|
-
setToolOutputsExpanded(!toolOutputsExpanded);
|
|
282
|
-
});
|
|
283
|
-
document.querySelector('[data-action="toggle-hidden-messages"]')?.addEventListener('click', () => {
|
|
284
|
-
setHiddenMessagesVisible(!showHiddenMessages);
|
|
285
|
-
});
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
const isEditableTarget = (element) => {
|
|
289
|
-
if (!element) return false;
|
|
290
|
-
const tagName = element.tagName;
|
|
291
|
-
if (tagName === 'INPUT' || tagName === 'TEXTAREA' || tagName === 'SELECT' || tagName === 'BUTTON') {
|
|
292
|
-
return true;
|
|
293
|
-
}
|
|
294
|
-
return element.isContentEditable || Boolean(element.closest?.('[contenteditable="true"]'));
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
// Keyboard shortcuts
|
|
298
|
-
document.addEventListener('keydown', (e) => {
|
|
299
|
-
if (e.key === 'Escape') {
|
|
300
|
-
searchInput.value = '';
|
|
301
|
-
searchQuery = '';
|
|
302
|
-
navigateTo(leafId, 'bottom');
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
if (e.ctrlKey || e.metaKey || e.altKey || isEditableTarget(document.activeElement)) {
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
const key = e.key.toLowerCase();
|
|
310
|
-
if (key === 't') {
|
|
311
|
-
e.preventDefault();
|
|
312
|
-
setThinkingExpanded(!thinkingExpanded);
|
|
313
|
-
} else if (key === 'o') {
|
|
314
|
-
e.preventDefault();
|
|
315
|
-
setToolOutputsExpanded(!toolOutputsExpanded);
|
|
316
|
-
} else if (key === 'h') {
|
|
317
|
-
e.preventDefault();
|
|
318
|
-
setHiddenMessagesVisible(!showHiddenMessages);
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
// Initial render
|
|
323
|
-
// If URL has targetId, scroll to that specific message; otherwise stay at top
|
|
324
|
-
if (leafId) {
|
|
325
|
-
if (urlTargetId && byId.has(urlTargetId)) {
|
|
326
|
-
// Deep link: navigate to leaf and scroll to target message
|
|
327
|
-
navigateTo(leafId, 'target', urlTargetId);
|
|
328
|
-
} else {
|
|
329
|
-
navigateTo(leafId, 'none');
|
|
330
|
-
}
|
|
331
|
-
} else if (entries.length > 0) {
|
|
332
|
-
// Fallback: use last entry if no leafId
|
|
333
|
-
navigateTo(entries[entries.length - 1].id, 'none');
|
|
334
|
-
}
|
|
335
|
-
})();
|