pith-ui 0.0.0-stage → 0.1.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/AI.md +75 -0
- package/API.md +3688 -0
- package/LICENSE +661 -0
- package/README.md +80 -2
- package/dist/composer.d.ts +38 -0
- package/dist/composer.d.ts.map +1 -0
- package/dist/composer.js +123 -0
- package/dist/composer.js.map +1 -0
- package/dist/content/conversation-reader.d.ts +19 -0
- package/dist/content/conversation-reader.d.ts.map +1 -0
- package/dist/content/conversation-reader.js +280 -0
- package/dist/content/conversation-reader.js.map +1 -0
- package/dist/content/conversation-view.d.ts +65 -0
- package/dist/content/conversation-view.d.ts.map +1 -0
- package/dist/content/conversation-view.js +140 -0
- package/dist/content/conversation-view.js.map +1 -0
- package/dist/content/image-viewer.d.ts +25 -0
- package/dist/content/image-viewer.d.ts.map +1 -0
- package/dist/content/image-viewer.js +114 -0
- package/dist/content/image-viewer.js.map +1 -0
- package/dist/content/markdown.d.ts +12 -0
- package/dist/content/markdown.d.ts.map +1 -0
- package/dist/content/markdown.js +68 -0
- package/dist/content/markdown.js.map +1 -0
- package/dist/content/paged-preview.d.ts +15 -0
- package/dist/content/paged-preview.d.ts.map +1 -0
- package/dist/content/paged-preview.js +108 -0
- package/dist/content/paged-preview.js.map +1 -0
- package/dist/content/views.d.ts +9 -0
- package/dist/content/views.d.ts.map +1 -0
- package/dist/content/views.js +53 -0
- package/dist/content/views.js.map +1 -0
- package/dist/content/welcome.d.ts +18 -0
- package/dist/content/welcome.d.ts.map +1 -0
- package/dist/content/welcome.js +54 -0
- package/dist/content/welcome.js.map +1 -0
- package/dist/core.d.ts +36 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +44 -0
- package/dist/core.js.map +1 -0
- package/dist/dom.d.ts +14 -0
- package/dist/dom.d.ts.map +1 -0
- package/dist/dom.js +69 -0
- package/dist/dom.js.map +1 -0
- package/dist/files/panels.d.ts +100 -0
- package/dist/files/panels.d.ts.map +1 -0
- package/dist/files/panels.js +286 -0
- package/dist/files/panels.js.map +1 -0
- package/dist/files/systems.d.ts +91 -0
- package/dist/files/systems.d.ts.map +1 -0
- package/dist/files/systems.js +273 -0
- package/dist/files/systems.js.map +1 -0
- package/dist/forms/actions.d.ts +27 -0
- package/dist/forms/actions.d.ts.map +1 -0
- package/dist/forms/actions.js +39 -0
- package/dist/forms/actions.js.map +1 -0
- package/dist/forms/custom-connection.d.ts +62 -0
- package/dist/forms/custom-connection.d.ts.map +1 -0
- package/dist/forms/custom-connection.js +72 -0
- package/dist/forms/custom-connection.js.map +1 -0
- package/dist/forms/dialog-frame.d.ts +41 -0
- package/dist/forms/dialog-frame.d.ts.map +1 -0
- package/dist/forms/dialog-frame.js +95 -0
- package/dist/forms/dialog-frame.js.map +1 -0
- package/dist/forms/history.d.ts +16 -0
- package/dist/forms/history.d.ts.map +1 -0
- package/dist/forms/history.js +21 -0
- package/dist/forms/history.js.map +1 -0
- package/dist/forms/identity.d.ts +16 -0
- package/dist/forms/identity.d.ts.map +1 -0
- package/dist/forms/identity.js +53 -0
- package/dist/forms/identity.js.map +1 -0
- package/dist/forms/model-editor.d.ts +40 -0
- package/dist/forms/model-editor.d.ts.map +1 -0
- package/dist/forms/model-editor.js +89 -0
- package/dist/forms/model-editor.js.map +1 -0
- package/dist/forms/panels.d.ts +146 -0
- package/dist/forms/panels.d.ts.map +1 -0
- package/dist/forms/panels.js +339 -0
- package/dist/forms/panels.js.map +1 -0
- package/dist/forms/provider-login.d.ts +22 -0
- package/dist/forms/provider-login.d.ts.map +1 -0
- package/dist/forms/provider-login.js +116 -0
- package/dist/forms/provider-login.js.map +1 -0
- package/dist/forms/resource-editor.d.ts +27 -0
- package/dist/forms/resource-editor.d.ts.map +1 -0
- package/dist/forms/resource-editor.js +34 -0
- package/dist/forms/resource-editor.js.map +1 -0
- package/dist/foundations.d.ts +95 -0
- package/dist/foundations.d.ts.map +1 -0
- package/dist/foundations.js +315 -0
- package/dist/foundations.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/navigation/context-menu.d.ts +26 -0
- package/dist/navigation/context-menu.d.ts.map +1 -0
- package/dist/navigation/context-menu.js +81 -0
- package/dist/navigation/context-menu.js.map +1 -0
- package/dist/navigation/navigation.d.ts +92 -0
- package/dist/navigation/navigation.d.ts.map +1 -0
- package/dist/navigation/navigation.js +368 -0
- package/dist/navigation/navigation.js.map +1 -0
- package/dist/primitives.d.ts +310 -0
- package/dist/primitives.d.ts.map +1 -0
- package/dist/primitives.js +633 -0
- package/dist/primitives.js.map +1 -0
- package/dist/styles.css +853 -0
- package/dist/surface.d.ts +29 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +154 -0
- package/dist/surface.js.map +1 -0
- package/dist/tasks/approval.d.ts +25 -0
- package/dist/tasks/approval.d.ts.map +1 -0
- package/dist/tasks/approval.js +64 -0
- package/dist/tasks/approval.js.map +1 -0
- package/dist/tasks/permission.d.ts +37 -0
- package/dist/tasks/permission.d.ts.map +1 -0
- package/dist/tasks/permission.js +73 -0
- package/dist/tasks/permission.js.map +1 -0
- package/dist/tasks/runtime.d.ts +31 -0
- package/dist/tasks/runtime.d.ts.map +1 -0
- package/dist/tasks/runtime.js +34 -0
- package/dist/tasks/runtime.js.map +1 -0
- package/dist/theme.d.ts +4 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +6 -0
- package/dist/theme.js.map +1 -0
- package/dist/workspace.d.ts +92 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +288 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +27 -4
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { type ActionResult } from './core.js';
|
|
2
|
+
export interface ComposerViewState {
|
|
3
|
+
placeholder?: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
readOnly?: boolean;
|
|
6
|
+
action?: 'send' | 'queue' | 'stop';
|
|
7
|
+
actionDisabled?: boolean;
|
|
8
|
+
model?: {
|
|
9
|
+
label: string;
|
|
10
|
+
description: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
};
|
|
13
|
+
thinking?: {
|
|
14
|
+
options: readonly {
|
|
15
|
+
value: string;
|
|
16
|
+
label: string;
|
|
17
|
+
}[];
|
|
18
|
+
value: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface ComposerViewOptions {
|
|
23
|
+
prefix?: string;
|
|
24
|
+
onSubmit?: (text: string) => void | ActionResult | Promise<void | ActionResult>;
|
|
25
|
+
onStop?: () => void | ActionResult | Promise<void | ActionResult>;
|
|
26
|
+
onInput?: (text: string) => void;
|
|
27
|
+
onModel?: () => void;
|
|
28
|
+
onAttach?: () => void;
|
|
29
|
+
onImages?: (files: File[]) => void;
|
|
30
|
+
onThinkingChange?: (value: string) => void;
|
|
31
|
+
}
|
|
32
|
+
export declare function createComposerView(options?: ComposerViewOptions): {
|
|
33
|
+
element: HTMLFormElement;
|
|
34
|
+
input: HTMLTextAreaElement;
|
|
35
|
+
update: (state: ComposerViewState) => void;
|
|
36
|
+
getValue: () => string;
|
|
37
|
+
reset(value: string): void;
|
|
38
|
+
focus: () => void;
|
|
39
|
+
resize: () => void;
|
|
40
|
+
pickImages(): void;
|
|
41
|
+
destroy(): void;
|
|
42
|
+
};
|
|
43
|
+
export type WorkspaceDialogName = 'model' | 'settings' | 'workspace' | 'permissions' | 'delete' | 'rename' | 'queue-edit' | 'message-edit' | 'resources' | 'connections' | 'preview' | 'image';
|
|
44
|
+
export interface ActionScope {
|
|
45
|
+
kind: 'global' | 'conversation' | 'workspace' | 'active';
|
|
46
|
+
id?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface WorkspaceShellOptions {
|
|
49
|
+
brand: Node;
|
|
50
|
+
prefix?: string;
|
|
51
|
+
composer?: ComposerViewOptions;
|
|
52
|
+
onDialogClose?: (name: WorkspaceDialogName) => void;
|
|
53
|
+
onSearch?: (query: string) => void;
|
|
54
|
+
onBusyAction?: (key: string) => void;
|
|
55
|
+
}
|
|
56
|
+
export interface WorkspaceShellState {
|
|
57
|
+
workspace?: string;
|
|
58
|
+
conversation?: string;
|
|
59
|
+
reconnecting?: boolean;
|
|
60
|
+
error?: {
|
|
61
|
+
message: string;
|
|
62
|
+
hidden?: boolean;
|
|
63
|
+
};
|
|
64
|
+
busy?: {
|
|
65
|
+
key: string;
|
|
66
|
+
message: string;
|
|
67
|
+
actionLabel: string;
|
|
68
|
+
} | null;
|
|
69
|
+
}
|
|
70
|
+
export declare function createWorkspaceShell(options: WorkspaceShellOptions): {
|
|
71
|
+
element: HTMLDivElement;
|
|
72
|
+
composer: {
|
|
73
|
+
element: HTMLFormElement;
|
|
74
|
+
input: HTMLTextAreaElement;
|
|
75
|
+
update: (state: ComposerViewState) => void;
|
|
76
|
+
getValue: () => string;
|
|
77
|
+
reset(value: string): void;
|
|
78
|
+
focus: () => void;
|
|
79
|
+
resize: () => void;
|
|
80
|
+
pickImages(): void;
|
|
81
|
+
destroy(): void;
|
|
82
|
+
};
|
|
83
|
+
part: <T extends HTMLElement = HTMLElement>(name: string) => T;
|
|
84
|
+
update(state: Readonly<WorkspaceShellState>): void;
|
|
85
|
+
setSidebarOpen: (open: boolean) => void;
|
|
86
|
+
openDialog(name: WorkspaceDialogName): void;
|
|
87
|
+
closeDialog(name: WorkspaceDialogName): void;
|
|
88
|
+
isDialogOpen(name: WorkspaceDialogName): boolean;
|
|
89
|
+
updateActionAvailability(unavailable: (scope: ActionScope) => boolean, root?: ParentNode): void;
|
|
90
|
+
destroy(): void;
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,YAAY,EA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Q,CAAC,mBAAmB,CAAC;2BAP/C,OAAO;qBAwBpB,mBAAmB;sBAClB,mBAAmB;uBAClB,mBAAmB;0CACA,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,SAAQ,UAAU;;EASxF"}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { Generation } from './core.js';
|
|
2
|
+
import { icon } from './dom.js';
|
|
3
|
+
import { controlDisabled } from './core.js';
|
|
4
|
+
import { adoptProductParts, reconcileSelectOptions } from './foundations.js';
|
|
5
|
+
import { installDialogLifecycle } from './surface.js';
|
|
6
|
+
let sequence = 0;
|
|
7
|
+
function identify(root, prefix) {
|
|
8
|
+
if (!prefix)
|
|
9
|
+
return;
|
|
10
|
+
const attributes = ['id', 'for', 'aria-labelledby', 'aria-describedby', 'aria-controls', 'data-close'];
|
|
11
|
+
for (const node of [root, ...root.querySelectorAll('*')])
|
|
12
|
+
for (const attribute of attributes) {
|
|
13
|
+
const value = node.getAttribute(attribute);
|
|
14
|
+
if (value)
|
|
15
|
+
node.setAttribute(attribute, value.split(' ').map(part => prefix + part).join(' '));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function createComposerView(options = {}) {
|
|
19
|
+
const holder = document.createElement('div');
|
|
20
|
+
holder.innerHTML = `<form id="composer-form" class="pui-composer">
|
|
21
|
+
<div id="draft-images" class="pui-draft-images" aria-label="Image attachments" hidden></div>
|
|
22
|
+
<input id="image-picker" type="file" accept="image/png,image/jpeg,image/gif,image/webp" multiple hidden />
|
|
23
|
+
<textarea id="composer-input" rows="1" placeholder="Ask Pith to help with your work…" aria-label="Message Pith"></textarea>
|
|
24
|
+
<div class="pui-composer-toolbar">
|
|
25
|
+
<div class="pui-composer-context">
|
|
26
|
+
<button id="attach-images" type="button" class="pui-quiet-icon pui-attach-images" data-action="attach-images" aria-label="Attach images" title="Attach images">${icon('image')}</button>
|
|
27
|
+
<label class="pui-permission-control" id="permission-control">${icon('shield')}<span class="pui-sr-only">Conversation permissions</span><select id="permission-mode" aria-describedby="permission-description"><option value="ask">Ask before changes</option><option value="workspace-write">Allow workspace changes</option><option value="full-access">Full access</option></select>${icon('down')}</label>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="pui-composer-actions"><button id="composer-model" type="button" class="pui-composer-model" data-action="model" data-idle-action data-global-idle aria-label="Choose model">Choose model</button><label class="pui-composer-thinking"><span class="pui-sr-only">Thinking effort</span><select id="composer-thinking" aria-label="Thinking effort"></select></label><button id="send-button" class="pui-send-button" type="submit" aria-label="Send message">${icon('arrow')}</button></div>
|
|
30
|
+
</div>
|
|
31
|
+
</form>`;
|
|
32
|
+
const element = holder.firstElementChild;
|
|
33
|
+
const input = element.querySelector('textarea');
|
|
34
|
+
const action = element.querySelector('[type="submit"]');
|
|
35
|
+
const model = element.querySelector('[data-action="model"]');
|
|
36
|
+
const thinking = element.querySelector('[aria-label="Thinking effort"]');
|
|
37
|
+
const imagePicker = element.querySelector('[type="file"]');
|
|
38
|
+
identify(element, options.prefix ?? 'pui-composer-' + ++sequence + '-');
|
|
39
|
+
const generation = new Generation();
|
|
40
|
+
const parts = adoptProductParts(element);
|
|
41
|
+
let destroyed = false;
|
|
42
|
+
let pending = false, last = {}, lastAction = 'send';
|
|
43
|
+
const error = document.createElement('div');
|
|
44
|
+
error.className = 'pui-form-error';
|
|
45
|
+
error.setAttribute('role', 'alert');
|
|
46
|
+
error.hidden = true;
|
|
47
|
+
element.insertBefore(error, element.firstChild);
|
|
48
|
+
const resize = () => { input.style.height = 'auto'; input.style.height = Math.min(input.scrollHeight, 180) + 'px'; };
|
|
49
|
+
const update = (state) => {
|
|
50
|
+
if (destroyed)
|
|
51
|
+
return;
|
|
52
|
+
last = state;
|
|
53
|
+
parts.control(input).update({ disabled: !!state.disabled, readOnly: !!state.readOnly, ...(state.placeholder !== undefined ? { placeholder: state.placeholder } : {}) });
|
|
54
|
+
if (state.action && state.action !== lastAction) {
|
|
55
|
+
lastAction = state.action;
|
|
56
|
+
action.type = state.action === 'stop' ? 'button' : 'submit';
|
|
57
|
+
action.innerHTML = icon(state.action === 'stop' ? 'stop' : 'arrow');
|
|
58
|
+
action.classList.toggle('pui-is-stop', state.action === 'stop');
|
|
59
|
+
}
|
|
60
|
+
const actionLabel = lastAction === 'stop' ? 'Stop agent' : lastAction === 'queue' ? 'Queue message' : 'Send message';
|
|
61
|
+
action.setAttribute('aria-label', actionLabel);
|
|
62
|
+
action.title = actionLabel;
|
|
63
|
+
parts.action(action).update({ disabled: !!(state.actionDisabled || state.disabled), pending });
|
|
64
|
+
if (state.model) {
|
|
65
|
+
parts.action(model).update({ label: state.model.label, title: state.model.description, disabled: !!state.model.disabled });
|
|
66
|
+
}
|
|
67
|
+
if (state.thinking) {
|
|
68
|
+
const { options: choices, value, disabled } = state.thinking;
|
|
69
|
+
reconcileSelectOptions(thinking, choices, value);
|
|
70
|
+
parts.control(thinking).update({ disabled: !!disabled });
|
|
71
|
+
thinking.parentElement.hidden = choices.length < 2;
|
|
72
|
+
}
|
|
73
|
+
parts.update();
|
|
74
|
+
};
|
|
75
|
+
const onInput = () => { resize(); options.onInput?.(input.value); };
|
|
76
|
+
const run = async (callback, textSubmission = true) => {
|
|
77
|
+
if (!callback || pending || action.disabled || (textSubmission && (input.disabled || input.readOnly)))
|
|
78
|
+
return;
|
|
79
|
+
const seq = generation.next();
|
|
80
|
+
pending = true;
|
|
81
|
+
error.hidden = true;
|
|
82
|
+
error.textContent = '';
|
|
83
|
+
update(last);
|
|
84
|
+
try {
|
|
85
|
+
const result = await callback();
|
|
86
|
+
if (generation.current(seq) && result && !result.ok) {
|
|
87
|
+
error.textContent = result.error;
|
|
88
|
+
error.hidden = false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (reason) {
|
|
92
|
+
if (generation.current(seq)) {
|
|
93
|
+
error.textContent = reason instanceof Error ? reason.message : String(reason);
|
|
94
|
+
error.hidden = false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
if (generation.current(seq)) {
|
|
99
|
+
pending = false;
|
|
100
|
+
update(last);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const submit = (event) => { if (options.onSubmit) {
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
const text = input.value;
|
|
107
|
+
void run(() => options.onSubmit(text));
|
|
108
|
+
} };
|
|
109
|
+
const stop = () => { if (action.type === 'button')
|
|
110
|
+
void run(options.onStop, false); };
|
|
111
|
+
const keydown = (event) => {
|
|
112
|
+
if (options.onSubmit && event.key === 'Enter' && !event.shiftKey && !event.isComposing) {
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
if (action.type === 'submit')
|
|
115
|
+
element.requestSubmit();
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const click = (event) => {
|
|
119
|
+
const button = event.target.closest('button');
|
|
120
|
+
if (!button || button.disabled)
|
|
121
|
+
return;
|
|
122
|
+
const callback = button === model ? options.onModel : button.hasAttribute('data-action') && button.dataset.action === 'attach-images' ? options.onAttach : undefined;
|
|
123
|
+
if (callback) {
|
|
124
|
+
event.stopPropagation();
|
|
125
|
+
callback();
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
const chooseThinking = () => options.onThinkingChange?.(thinking.value);
|
|
129
|
+
const images = () => { const files = Array.from(imagePicker.files ?? []); imagePicker.value = ''; options.onImages?.(files); };
|
|
130
|
+
element.addEventListener('click', click);
|
|
131
|
+
thinking.addEventListener('change', chooseThinking);
|
|
132
|
+
imagePicker.addEventListener('change', images);
|
|
133
|
+
input.addEventListener('input', onInput);
|
|
134
|
+
input.addEventListener('keydown', keydown);
|
|
135
|
+
element.addEventListener('submit', submit);
|
|
136
|
+
action.addEventListener('click', stop);
|
|
137
|
+
return { element, input, update, getValue: () => input.value,
|
|
138
|
+
reset(value) { if (destroyed)
|
|
139
|
+
return; generation.invalidate(); pending = false; error.hidden = true; error.textContent = ''; input.value = value; update(last); resize(); }, focus: () => { if (!destroyed)
|
|
140
|
+
input.focus(); }, resize,
|
|
141
|
+
pickImages() { if (!destroyed)
|
|
142
|
+
imagePicker.click(); },
|
|
143
|
+
destroy() { if (destroyed)
|
|
144
|
+
return; destroyed = true; generation.destroy(); parts.destroy(); input.removeEventListener('input', onInput); input.removeEventListener('keydown', keydown); element.removeEventListener('submit', submit); action.removeEventListener('click', stop); element.removeEventListener('click', click); thinking.removeEventListener('change', chooseThinking); imagePicker.removeEventListener('change', images); element.remove(); } };
|
|
145
|
+
}
|
|
146
|
+
export function createWorkspaceShell(options) {
|
|
147
|
+
const element = document.createElement('div');
|
|
148
|
+
element.className = 'pui-app';
|
|
149
|
+
element.innerHTML = `
|
|
150
|
+
<aside class="pui-sidebar" id="sidebar">
|
|
151
|
+
<div class="pui-brand"><span data-brand-slot></span></div>
|
|
152
|
+
<div class="pui-sidebar-section-label">WORKSPACES <button class="pui-quiet-icon" data-action="workspace" aria-label="Manage workspaces">${icon('plus')}</button></div>
|
|
153
|
+
<label class="pui-history-search">${icon('search')}<span class="pui-sr-only">Search conversation titles</span><input id="history-search" type="search" placeholder="Search conversations" autocomplete="off" /></label>
|
|
154
|
+
<nav id="history-list" class="pui-history-list" aria-label="Workspaces and conversations"></nav>
|
|
155
|
+
<div class="pui-sidebar-bottom">
|
|
156
|
+
<button class="pui-settings-button" data-action="resources">${icon('file')}<span>Workspace resources</span></button>
|
|
157
|
+
<button class="pui-settings-button" data-action="connections">${icon('plug')}<span>Connections</span></button>
|
|
158
|
+
<button class="pui-settings-button" data-action="settings">${icon('settings')}<span>Settings</span></button>
|
|
159
|
+
<div id="connection-status" class="pui-local-status" role="status" hidden><span class="pui-status-dot pui-reconnecting" aria-hidden="true"></span><span>Reconnecting…</span></div>
|
|
160
|
+
</div>
|
|
161
|
+
</aside>
|
|
162
|
+
<div id="conversation-menu" class="pui-sidebar-conversation-menu" role="menu" hidden></div>
|
|
163
|
+
<div class="pui-sidebar-scrim" id="sidebar-scrim"></div>
|
|
164
|
+
<main class="pui-main">
|
|
165
|
+
<header class="pui-topbar">
|
|
166
|
+
<button class="pui-quiet-icon pui-mobile-menu" data-action="menu" aria-label="Open sidebar">${icon('menu')}</button>
|
|
167
|
+
<div class="pui-breadcrumb">${icon('folder')}<span id="workspace-label">No workspace</span>${icon('chevron', 'pui-breadcrumb-chevron')}<span class="pui-breadcrumb-current" id="conversation-label">New conversation</span></div>
|
|
168
|
+
<div class="pui-conversation-actions"><button class="pui-quiet-icon pui-compact-action" data-sdk="compact" data-sdk-idle title="Compress context by summarizing older messages" aria-label="Compress context">${icon('compress')}<span>Compact</span></button><div id="artifacts-control" class="pui-artifacts-control" hidden><button id="artifacts-toggle" type="button" class="pui-quiet-icon pui-artifacts-toggle" aria-label="Conversation files" title="Conversation files" aria-expanded="false" aria-controls="artifacts">${icon('file')}<span id="artifacts-count" class="pui-artifacts-count" aria-hidden="true"></span></button><section id="artifacts" class="pui-artifacts-panel" aria-labelledby="artifacts-title" tabindex="-1" hidden></section></div></div>
|
|
169
|
+
</header>
|
|
170
|
+
<section id="conversation-find" class="pui-conversation-find" aria-label="Find in conversation" hidden>
|
|
171
|
+
<input type="search" aria-label="Find in this conversation" placeholder="Find in this conversation" autocomplete="off" />
|
|
172
|
+
<span data-find-count role="status" aria-live="polite"></span>
|
|
173
|
+
<button type="button" class="pui-quiet-icon pui-find-previous" data-find-previous aria-label="Previous match" title="Previous match (Shift+Enter)">${icon('down')}</button>
|
|
174
|
+
<button type="button" class="pui-quiet-icon" data-find-next aria-label="Next match" title="Next match (Enter)">${icon('down')}</button>
|
|
175
|
+
<button type="button" class="pui-quiet-icon" data-find-close aria-label="Close search" title="Close (Esc)">${icon('close')}</button>
|
|
176
|
+
</section>
|
|
177
|
+
<div class="pui-conversation-region"><section id="chat-scroll" class="pui-chat-scroll" aria-label="Conversation" tabindex="-1">
|
|
178
|
+
<div id="welcome" class="pui-welcome"></div>
|
|
179
|
+
<div id="messages" class="pui-messages" aria-live="polite" aria-relevant="additions text"></div>
|
|
180
|
+
</section><button id="back-to-latest" type="button" class="pui-secondary-button pui-back-to-latest" hidden>${icon('down')}<span>Back to latest</span></button></div>
|
|
181
|
+
<div class="pui-composer-region">
|
|
182
|
+
<div class="pui-composer-panels">
|
|
183
|
+
<div id="approval" class="pui-approval-region"></div>
|
|
184
|
+
<div id="workspace-busy" class="pui-workspace-busy" hidden></div><div id="inline-error" class="pui-inline-error" role="alert" hidden></div>
|
|
185
|
+
<section id="task-failure" class="pui-task-failure" role="status" hidden></section>
|
|
186
|
+
<details id="run-status" class="pui-run-status" hidden><summary id="run-status-summary"></summary><div id="run-status-details"><div id="runtime-values"></div><details id="cost-requests" class="pui-cost-requests" hidden><summary>Request breakdown</summary><div id="cost-ledger"></div></details></div></details>
|
|
187
|
+
<section id="queued-messages" class="pui-queued-messages" aria-label="Pending messages" aria-live="polite" hidden></section>
|
|
188
|
+
</div>
|
|
189
|
+
<div data-composer-slot></div>
|
|
190
|
+
<p id="image-guidance" class="pui-composer-note pui-image-guidance" hidden></p>
|
|
191
|
+
<p class="pui-composer-note" id="permission-description">Pith can read workspace files. Changes and commands require your approval.</p>
|
|
192
|
+
</div>
|
|
193
|
+
</main>
|
|
194
|
+
<section id="completion-notices" class="pui-completion-notices" aria-label="Completed tasks" aria-live="polite"></section>
|
|
195
|
+
<span id="copy-status" class="pui-sr-only" role="status" aria-live="polite"></span>
|
|
196
|
+
<dialog id="model-dialog" class="pui-modal pui-model-modal" aria-labelledby="model-title"><div id="model-content"></div></dialog>
|
|
197
|
+
<dialog id="settings-dialog" class="pui-modal" aria-labelledby="settings-title"><div id="settings-content"></div></dialog>
|
|
198
|
+
<dialog id="workspace-dialog" class="pui-modal" aria-labelledby="workspace-title"><div id="workspace-content"></div></dialog>
|
|
199
|
+
<dialog id="permissions-dialog" class="pui-modal pui-permission-modal" aria-labelledby="full-access-title"><div id="permissions-content"></div></dialog>
|
|
200
|
+
<dialog id="delete-dialog" class="pui-modal" aria-labelledby="delete-title"><div id="delete-content"></div></dialog>
|
|
201
|
+
<dialog id="rename-dialog" class="pui-modal" aria-labelledby="rename-title"><div id="rename-content"></div></dialog>
|
|
202
|
+
<dialog id="queue-edit-dialog" class="pui-modal" aria-labelledby="queue-edit-title"><div id="queue-edit-content"></div></dialog>
|
|
203
|
+
<dialog id="message-edit-dialog" class="pui-modal" aria-labelledby="message-edit-title"><div id="message-edit-content"></div></dialog>
|
|
204
|
+
<dialog id="resources-dialog" class="pui-modal pui-feature-modal" aria-labelledby="resources-title"><div id="resources-content"></div></dialog>
|
|
205
|
+
<dialog id="connections-dialog" class="pui-modal pui-feature-modal" aria-labelledby="connections-title"><div id="connections-content"></div></dialog>
|
|
206
|
+
<dialog id="preview-dialog" class="pui-modal pui-file-preview-modal" aria-labelledby="preview-title"><div id="preview-content"></div></dialog>
|
|
207
|
+
<dialog id="image-dialog"></dialog>
|
|
208
|
+
`;
|
|
209
|
+
element.querySelector('[data-brand-slot]').replaceWith(options.brand);
|
|
210
|
+
const prefix = options.prefix ?? 'pui-workspace-' + ++sequence + '-';
|
|
211
|
+
const composer = createComposerView({ ...options.composer, prefix: '' });
|
|
212
|
+
element.querySelector('[data-composer-slot]').replaceWith(composer.element);
|
|
213
|
+
identify(element, prefix);
|
|
214
|
+
const part = (name) => element.querySelector('[id="' + prefix + name + '"]');
|
|
215
|
+
let destroyed = false;
|
|
216
|
+
const parts = adoptProductParts(element);
|
|
217
|
+
const dialogs = new Map(Array.from(element.querySelectorAll('dialog'), dialog => {
|
|
218
|
+
const name = dialog.id.slice(prefix.length).replace(/-dialog$/, '');
|
|
219
|
+
return [name, installDialogLifecycle(dialog, { onClose: () => options.onDialogClose?.(name) })];
|
|
220
|
+
}));
|
|
221
|
+
const setSidebarOpen = (open) => { if (destroyed)
|
|
222
|
+
return; part('sidebar').classList.toggle('pui-open', open); part('sidebar-scrim').classList.toggle('pui-visible', open); };
|
|
223
|
+
const sidebarClick = (event) => { const target = event.target; if (target === part('sidebar-scrim') || target.closest('[data-action="menu"]')) {
|
|
224
|
+
setSidebarOpen(target !== part('sidebar-scrim'));
|
|
225
|
+
event.stopPropagation();
|
|
226
|
+
} };
|
|
227
|
+
const search = part('history-search');
|
|
228
|
+
const onSearch = () => options.onSearch?.(search.value);
|
|
229
|
+
search.addEventListener('input', onSearch);
|
|
230
|
+
element.addEventListener('click', sidebarClick);
|
|
231
|
+
const busy = part('workspace-busy');
|
|
232
|
+
const onBusy = (event) => { if (event.target.closest('button') && busy.dataset.key) {
|
|
233
|
+
event.stopPropagation();
|
|
234
|
+
options.onBusyAction?.(busy.dataset.key);
|
|
235
|
+
} };
|
|
236
|
+
busy.addEventListener('click', onBusy);
|
|
237
|
+
return { element, composer, part, update(state) {
|
|
238
|
+
if (destroyed)
|
|
239
|
+
return;
|
|
240
|
+
if (state.workspace !== undefined)
|
|
241
|
+
part('workspace-label').textContent = state.workspace;
|
|
242
|
+
if (state.conversation !== undefined)
|
|
243
|
+
part('conversation-label').textContent = state.conversation;
|
|
244
|
+
part('connection-status').hidden = !state.reconnecting;
|
|
245
|
+
if (state.error) {
|
|
246
|
+
part('inline-error').textContent = state.error.message;
|
|
247
|
+
part('inline-error').hidden = !!state.error.hidden || !state.error.message;
|
|
248
|
+
}
|
|
249
|
+
if (state.busy !== undefined) {
|
|
250
|
+
busy.hidden = !state.busy;
|
|
251
|
+
if (state.busy) {
|
|
252
|
+
if (!busy.firstChild) {
|
|
253
|
+
busy.append(document.createElement('span'), document.createElement('button'));
|
|
254
|
+
const button = busy.lastElementChild;
|
|
255
|
+
button.type = 'button';
|
|
256
|
+
button.className = 'pui-text-button';
|
|
257
|
+
}
|
|
258
|
+
busy.dataset.key = state.busy.key;
|
|
259
|
+
if (busy.firstElementChild.textContent !== state.busy.message)
|
|
260
|
+
busy.firstElementChild.textContent = state.busy.message;
|
|
261
|
+
if (busy.lastElementChild.textContent !== state.busy.actionLabel)
|
|
262
|
+
busy.lastElementChild.textContent = state.busy.actionLabel;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
parts.update();
|
|
266
|
+
}, setSidebarOpen,
|
|
267
|
+
openDialog(name) { if (!destroyed) {
|
|
268
|
+
setSidebarOpen(false);
|
|
269
|
+
dialogs.get(name)?.open();
|
|
270
|
+
} },
|
|
271
|
+
closeDialog(name) { if (!destroyed)
|
|
272
|
+
dialogs.get(name)?.close(); },
|
|
273
|
+
isDialogOpen(name) { return !destroyed && !!dialogs.get(name)?.isOpen(); },
|
|
274
|
+
updateActionAvailability(unavailable, root = element) {
|
|
275
|
+
if (destroyed)
|
|
276
|
+
return;
|
|
277
|
+
for (const button of root.querySelectorAll('[data-idle-action], [data-global-idle], [data-mcp-edit], [data-action="new-mcp"]')) {
|
|
278
|
+
const scope = button.hasAttribute('data-global-idle') || button.hasAttribute('data-mcp-edit') || button.dataset.action === 'new-mcp' ? { kind: 'global' } : button.dataset.idleConversation ? { kind: 'conversation', id: button.dataset.idleConversation } : button.dataset.idleWorkspace ? { kind: 'workspace', id: button.dataset.idleWorkspace } : { kind: 'active' };
|
|
279
|
+
button.disabled = controlDisabled(button, unavailable(scope));
|
|
280
|
+
}
|
|
281
|
+
for (const link of root.querySelectorAll('a[data-download-conversation]'))
|
|
282
|
+
link.setAttribute('aria-disabled', String(unavailable({ kind: 'conversation', id: link.dataset.downloadConversation })));
|
|
283
|
+
},
|
|
284
|
+
destroy() { if (destroyed)
|
|
285
|
+
return; destroyed = true; for (const dialog of dialogs.values())
|
|
286
|
+
dialog.destroy(); parts.destroy(); search.removeEventListener('input', onSearch); element.removeEventListener('click', sidebarClick); busy.removeEventListener('click', onBusy); composer.destroy(); element.remove(); } };
|
|
287
|
+
}
|
|
288
|
+
//# sourceMappingURL=workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmC,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC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OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACzT,CAAC","sourcesContent":["import { Generation, type UIBlock, type ActionResult } from './core.js';\nimport { icon } from './dom.js';\nimport { controlDisabled } from './core.js';\nimport { adoptProductParts, reconcileSelectOptions } from './foundations.js';\nimport { installDialogLifecycle } from './surface.js';\n\nexport interface ComposerViewState {\n placeholder?: string; disabled?: boolean; readOnly?: boolean;\n action?: 'send' | 'queue' | 'stop'; actionDisabled?: boolean;\n model?: { label: string; description: string; disabled?: boolean };\n thinking?: { options: readonly { value: string; label: string }[]; value: string; disabled?: boolean };\n}\nexport interface ComposerViewOptions {\n prefix?: string;\n onSubmit?: (text: string) => void | ActionResult | Promise<void | ActionResult>;\n onStop?: () => void | ActionResult | Promise<void | ActionResult>;\n onInput?: (text: string) => void;\n onModel?: () => void;\n onAttach?: () => void;\n onImages?: (files: File[]) => void;\n onThinkingChange?: (value: string) => void;\n}\nlet sequence = 0;\nfunction identify(root: HTMLElement, prefix: string): void {\n if (!prefix) return;\n const attributes = ['id', 'for', 'aria-labelledby', 'aria-describedby', 'aria-controls', 'data-close'];\n for (const node of [root, ...root.querySelectorAll<HTMLElement>('*')]) for (const attribute of attributes) {\n const value = node.getAttribute(attribute); if (value) node.setAttribute(attribute, value.split(' ').map(part => prefix + part).join(' '));\n }\n}\nexport function createComposerView(options: ComposerViewOptions = {}) {\n const holder = document.createElement('div'); holder.innerHTML = `<form id=\"composer-form\" class=\"pui-composer\">\n <div id=\"draft-images\" class=\"pui-draft-images\" aria-label=\"Image attachments\" hidden></div>\n <input id=\"image-picker\" type=\"file\" accept=\"image/png,image/jpeg,image/gif,image/webp\" multiple hidden />\n <textarea id=\"composer-input\" rows=\"1\" placeholder=\"Ask Pith to help with your work…\" aria-label=\"Message Pith\"></textarea>\n <div class=\"pui-composer-toolbar\">\n <div class=\"pui-composer-context\">\n <button id=\"attach-images\" type=\"button\" class=\"pui-quiet-icon pui-attach-images\" data-action=\"attach-images\" aria-label=\"Attach images\" title=\"Attach images\">${icon('image')}</button>\n <label class=\"pui-permission-control\" id=\"permission-control\">${icon('shield')}<span class=\"pui-sr-only\">Conversation permissions</span><select id=\"permission-mode\" aria-describedby=\"permission-description\"><option value=\"ask\">Ask before changes</option><option value=\"workspace-write\">Allow workspace changes</option><option value=\"full-access\">Full access</option></select>${icon('down')}</label>\n </div>\n <div class=\"pui-composer-actions\"><button id=\"composer-model\" type=\"button\" class=\"pui-composer-model\" data-action=\"model\" data-idle-action data-global-idle aria-label=\"Choose model\">Choose model</button><label class=\"pui-composer-thinking\"><span class=\"pui-sr-only\">Thinking effort</span><select id=\"composer-thinking\" aria-label=\"Thinking effort\"></select></label><button id=\"send-button\" class=\"pui-send-button\" type=\"submit\" aria-label=\"Send message\">${icon('arrow')}</button></div>\n </div>\n </form>`;\n const element = holder.firstElementChild as HTMLFormElement;\n const input = element.querySelector<HTMLTextAreaElement>('textarea')!;\n const action = element.querySelector<HTMLButtonElement>('[type=\"submit\"]')!;\n const model = element.querySelector<HTMLButtonElement>('[data-action=\"model\"]')!;\n const thinking = element.querySelector<HTMLSelectElement>('[aria-label=\"Thinking effort\"]')!;\n const imagePicker = element.querySelector<HTMLInputElement>('[type=\"file\"]')!;\n identify(element, options.prefix ?? 'pui-composer-' + ++sequence + '-');\n const generation = new Generation();\n const parts = adoptProductParts(element);\n let destroyed = false;\n let pending = false, last: ComposerViewState = {}, lastAction = 'send';\n const error = document.createElement('div'); error.className = 'pui-form-error'; error.setAttribute('role','alert'); error.hidden = true; element.insertBefore(error, element.firstChild);\n const resize = () => { input.style.height = 'auto'; input.style.height = Math.min(input.scrollHeight, 180) + 'px'; };\n const update = (state: ComposerViewState) => {\n if (destroyed) return;\n last = state;\n parts.control(input).update({ disabled: !!state.disabled, readOnly: !!state.readOnly, ...(state.placeholder !== undefined ? { placeholder: state.placeholder } : {}) });\n if (state.action && state.action !== lastAction) { lastAction = state.action; action.type = state.action === 'stop' ? 'button' : 'submit'; action.innerHTML = icon(state.action === 'stop' ? 'stop' : 'arrow'); action.classList.toggle('pui-is-stop', state.action === 'stop'); }\n const actionLabel = lastAction === 'stop' ? 'Stop agent' : lastAction === 'queue' ? 'Queue message' : 'Send message';\n action.setAttribute('aria-label', actionLabel); action.title = actionLabel;\n parts.action(action).update({ disabled: !!(state.actionDisabled || state.disabled), pending });\n if (state.model) {\n parts.action(model).update({ label: state.model.label, title: state.model.description, disabled: !!state.model.disabled });\n }\n if (state.thinking) {\n const { options: choices, value, disabled } = state.thinking;\n reconcileSelectOptions(thinking, choices, value);\n parts.control(thinking).update({ disabled: !!disabled }); thinking.parentElement!.hidden = choices.length < 2;\n }\n parts.update();\n };\n const onInput = () => { resize(); options.onInput?.(input.value); };\n const run = async (callback: (() => void | ActionResult | Promise<void | ActionResult>) | undefined, textSubmission = true) => {\n if (!callback || pending || action.disabled || (textSubmission && (input.disabled || input.readOnly))) return;\n const seq = generation.next(); pending = true; error.hidden = true; error.textContent = ''; update(last);\n try {\n const result = await callback();\n if (generation.current(seq) && result && !result.ok) { error.textContent = result.error; error.hidden = false; }\n } catch (reason) {\n if (generation.current(seq)) { error.textContent = reason instanceof Error ? reason.message : String(reason); error.hidden = false; }\n } finally { if (generation.current(seq)) { pending = false; update(last); } }\n };\n const submit = (event: SubmitEvent) => { if (options.onSubmit) { event.preventDefault(); const text = input.value; void run(() => options.onSubmit!(text)); } };\n const stop = () => { if (action.type === 'button') void run(options.onStop, false); };\n const keydown = (event: KeyboardEvent) => {\n if (options.onSubmit && event.key === 'Enter' && !event.shiftKey && !event.isComposing) {\n event.preventDefault();\n if (action.type === 'submit') element.requestSubmit();\n }\n };\n const click = (event: MouseEvent) => {\n const button = (event.target as Element).closest<HTMLButtonElement>('button');\n if (!button || button.disabled) return;\n const callback = button === model ? options.onModel : button.hasAttribute('data-action') && button.dataset.action === 'attach-images' ? options.onAttach : undefined;\n if (callback) { event.stopPropagation(); callback(); }\n };\n const chooseThinking = () => options.onThinkingChange?.(thinking.value);\n const images = () => { const files = Array.from(imagePicker.files ?? []); imagePicker.value = ''; options.onImages?.(files); };\n element.addEventListener('click', click); thinking.addEventListener('change', chooseThinking); imagePicker.addEventListener('change', images);\n input.addEventListener('input', onInput); input.addEventListener('keydown', keydown); element.addEventListener('submit', submit); action.addEventListener('click', stop);\n return { element, input, update, getValue: () => input.value,\n reset(value: string) { if (destroyed) return; generation.invalidate(); pending = false; error.hidden = true; error.textContent = ''; input.value = value; update(last); resize(); }, focus: () => { if (!destroyed) input.focus(); }, resize,\n pickImages() { if (!destroyed) imagePicker.click(); },\n destroy() { if (destroyed) return; destroyed = true; generation.destroy(); parts.destroy(); input.removeEventListener('input', onInput); input.removeEventListener('keydown', keydown); element.removeEventListener('submit', submit); action.removeEventListener('click', stop); element.removeEventListener('click', click); thinking.removeEventListener('change', chooseThinking); imagePicker.removeEventListener('change', images); element.remove(); } };\n\n}\n\nexport type WorkspaceDialogName = 'model' | 'settings' | 'workspace' | 'permissions' | 'delete' | 'rename' | 'queue-edit' | 'message-edit' | 'resources' | 'connections' | 'preview' | 'image';\nexport interface ActionScope { kind: 'global' | 'conversation' | 'workspace' | 'active'; id?: string; }\nexport interface WorkspaceShellOptions { brand: Node; prefix?: string; composer?: ComposerViewOptions; onDialogClose?: (name: WorkspaceDialogName) => void; onSearch?: (query: string) => void; onBusyAction?: (key: string) => void; }\nexport interface WorkspaceShellState { workspace?: string; conversation?: string; reconnecting?: boolean; error?: { message: string; hidden?: boolean }; busy?: { key: string; message: string; actionLabel: string } | null; }\nexport function createWorkspaceShell(options: WorkspaceShellOptions) {\n const element = document.createElement('div'); element.className = 'pui-app';\n element.innerHTML = `\n <aside class=\"pui-sidebar\" id=\"sidebar\">\n <div class=\"pui-brand\"><span data-brand-slot></span></div>\n <div class=\"pui-sidebar-section-label\">WORKSPACES <button class=\"pui-quiet-icon\" data-action=\"workspace\" aria-label=\"Manage workspaces\">${icon('plus')}</button></div>\n <label class=\"pui-history-search\">${icon('search')}<span class=\"pui-sr-only\">Search conversation titles</span><input id=\"history-search\" type=\"search\" placeholder=\"Search conversations\" autocomplete=\"off\" /></label>\n <nav id=\"history-list\" class=\"pui-history-list\" aria-label=\"Workspaces and conversations\"></nav>\n <div class=\"pui-sidebar-bottom\">\n <button class=\"pui-settings-button\" data-action=\"resources\">${icon('file')}<span>Workspace resources</span></button>\n <button class=\"pui-settings-button\" data-action=\"connections\">${icon('plug')}<span>Connections</span></button>\n <button class=\"pui-settings-button\" data-action=\"settings\">${icon('settings')}<span>Settings</span></button>\n <div id=\"connection-status\" class=\"pui-local-status\" role=\"status\" hidden><span class=\"pui-status-dot pui-reconnecting\" aria-hidden=\"true\"></span><span>Reconnecting…</span></div>\n </div>\n </aside>\n <div id=\"conversation-menu\" class=\"pui-sidebar-conversation-menu\" role=\"menu\" hidden></div>\n <div class=\"pui-sidebar-scrim\" id=\"sidebar-scrim\"></div>\n <main class=\"pui-main\">\n <header class=\"pui-topbar\">\n <button class=\"pui-quiet-icon pui-mobile-menu\" data-action=\"menu\" aria-label=\"Open sidebar\">${icon('menu')}</button>\n <div class=\"pui-breadcrumb\">${icon('folder')}<span id=\"workspace-label\">No workspace</span>${icon('chevron', 'pui-breadcrumb-chevron')}<span class=\"pui-breadcrumb-current\" id=\"conversation-label\">New conversation</span></div>\n <div class=\"pui-conversation-actions\"><button class=\"pui-quiet-icon pui-compact-action\" data-sdk=\"compact\" data-sdk-idle title=\"Compress context by summarizing older messages\" aria-label=\"Compress context\">${icon('compress')}<span>Compact</span></button><div id=\"artifacts-control\" class=\"pui-artifacts-control\" hidden><button id=\"artifacts-toggle\" type=\"button\" class=\"pui-quiet-icon pui-artifacts-toggle\" aria-label=\"Conversation files\" title=\"Conversation files\" aria-expanded=\"false\" aria-controls=\"artifacts\">${icon('file')}<span id=\"artifacts-count\" class=\"pui-artifacts-count\" aria-hidden=\"true\"></span></button><section id=\"artifacts\" class=\"pui-artifacts-panel\" aria-labelledby=\"artifacts-title\" tabindex=\"-1\" hidden></section></div></div>\n </header>\n <section id=\"conversation-find\" class=\"pui-conversation-find\" aria-label=\"Find in conversation\" hidden>\n <input type=\"search\" aria-label=\"Find in this conversation\" placeholder=\"Find in this conversation\" autocomplete=\"off\" />\n <span data-find-count role=\"status\" aria-live=\"polite\"></span>\n <button type=\"button\" class=\"pui-quiet-icon pui-find-previous\" data-find-previous aria-label=\"Previous match\" title=\"Previous match (Shift+Enter)\">${icon('down')}</button>\n <button type=\"button\" class=\"pui-quiet-icon\" data-find-next aria-label=\"Next match\" title=\"Next match (Enter)\">${icon('down')}</button>\n <button type=\"button\" class=\"pui-quiet-icon\" data-find-close aria-label=\"Close search\" title=\"Close (Esc)\">${icon('close')}</button>\n </section>\n <div class=\"pui-conversation-region\"><section id=\"chat-scroll\" class=\"pui-chat-scroll\" aria-label=\"Conversation\" tabindex=\"-1\">\n <div id=\"welcome\" class=\"pui-welcome\"></div>\n <div id=\"messages\" class=\"pui-messages\" aria-live=\"polite\" aria-relevant=\"additions text\"></div>\n </section><button id=\"back-to-latest\" type=\"button\" class=\"pui-secondary-button pui-back-to-latest\" hidden>${icon('down')}<span>Back to latest</span></button></div>\n <div class=\"pui-composer-region\">\n <div class=\"pui-composer-panels\">\n <div id=\"approval\" class=\"pui-approval-region\"></div>\n <div id=\"workspace-busy\" class=\"pui-workspace-busy\" hidden></div><div id=\"inline-error\" class=\"pui-inline-error\" role=\"alert\" hidden></div>\n <section id=\"task-failure\" class=\"pui-task-failure\" role=\"status\" hidden></section>\n <details id=\"run-status\" class=\"pui-run-status\" hidden><summary id=\"run-status-summary\"></summary><div id=\"run-status-details\"><div id=\"runtime-values\"></div><details id=\"cost-requests\" class=\"pui-cost-requests\" hidden><summary>Request breakdown</summary><div id=\"cost-ledger\"></div></details></div></details>\n <section id=\"queued-messages\" class=\"pui-queued-messages\" aria-label=\"Pending messages\" aria-live=\"polite\" hidden></section>\n </div>\n <div data-composer-slot></div>\n <p id=\"image-guidance\" class=\"pui-composer-note pui-image-guidance\" hidden></p>\n <p class=\"pui-composer-note\" id=\"permission-description\">Pith can read workspace files. Changes and commands require your approval.</p>\n </div>\n </main>\n <section id=\"completion-notices\" class=\"pui-completion-notices\" aria-label=\"Completed tasks\" aria-live=\"polite\"></section>\n <span id=\"copy-status\" class=\"pui-sr-only\" role=\"status\" aria-live=\"polite\"></span>\n <dialog id=\"model-dialog\" class=\"pui-modal pui-model-modal\" aria-labelledby=\"model-title\"><div id=\"model-content\"></div></dialog>\n <dialog id=\"settings-dialog\" class=\"pui-modal\" aria-labelledby=\"settings-title\"><div id=\"settings-content\"></div></dialog>\n <dialog id=\"workspace-dialog\" class=\"pui-modal\" aria-labelledby=\"workspace-title\"><div id=\"workspace-content\"></div></dialog>\n <dialog id=\"permissions-dialog\" class=\"pui-modal pui-permission-modal\" aria-labelledby=\"full-access-title\"><div id=\"permissions-content\"></div></dialog>\n <dialog id=\"delete-dialog\" class=\"pui-modal\" aria-labelledby=\"delete-title\"><div id=\"delete-content\"></div></dialog>\n <dialog id=\"rename-dialog\" class=\"pui-modal\" aria-labelledby=\"rename-title\"><div id=\"rename-content\"></div></dialog>\n <dialog id=\"queue-edit-dialog\" class=\"pui-modal\" aria-labelledby=\"queue-edit-title\"><div id=\"queue-edit-content\"></div></dialog>\n <dialog id=\"message-edit-dialog\" class=\"pui-modal\" aria-labelledby=\"message-edit-title\"><div id=\"message-edit-content\"></div></dialog>\n <dialog id=\"resources-dialog\" class=\"pui-modal pui-feature-modal\" aria-labelledby=\"resources-title\"><div id=\"resources-content\"></div></dialog>\n <dialog id=\"connections-dialog\" class=\"pui-modal pui-feature-modal\" aria-labelledby=\"connections-title\"><div id=\"connections-content\"></div></dialog>\n <dialog id=\"preview-dialog\" class=\"pui-modal pui-file-preview-modal\" aria-labelledby=\"preview-title\"><div id=\"preview-content\"></div></dialog>\n <dialog id=\"image-dialog\"></dialog>\n`;\n element.querySelector('[data-brand-slot]')!.replaceWith(options.brand);\n const prefix = options.prefix ?? 'pui-workspace-' + ++sequence + '-';\n const composer = createComposerView({ ...options.composer, prefix: '' }); element.querySelector('[data-composer-slot]')!.replaceWith(composer.element);\n identify(element, prefix);\n const part = <T extends HTMLElement = HTMLElement>(name: string) => element.querySelector<T>('[id=\"' + prefix + name + '\"]')!;\n let destroyed = false;\n const parts = adoptProductParts(element);\n const dialogs = new Map(Array.from(element.querySelectorAll<HTMLDialogElement>('dialog'), dialog => {\n const name = dialog.id.slice(prefix.length).replace(/-dialog$/, '') as WorkspaceDialogName;\n return [name, installDialogLifecycle(dialog, { onClose: () => options.onDialogClose?.(name) })] as const;\n }));\n const setSidebarOpen = (open: boolean) => { if (destroyed) return; part('sidebar').classList.toggle('pui-open', open); part('sidebar-scrim').classList.toggle('pui-visible', open); };\n const sidebarClick = (event: MouseEvent) => { const target = event.target as Element; if (target === part('sidebar-scrim') || target.closest('[data-action=\"menu\"]')) { setSidebarOpen(target !== part('sidebar-scrim')); event.stopPropagation(); } };\n const search = part<HTMLInputElement>('history-search'); const onSearch = () => options.onSearch?.(search.value);\n search.addEventListener('input', onSearch); element.addEventListener('click', sidebarClick);\n const busy = part('workspace-busy');\n const onBusy = (event: MouseEvent) => { if ((event.target as Element).closest('button') && busy.dataset.key) { event.stopPropagation(); options.onBusyAction?.(busy.dataset.key); } };\n busy.addEventListener('click', onBusy);\n return { element, composer, part, update(state: Readonly<WorkspaceShellState>) {\n if (destroyed) return;\n if (state.workspace !== undefined) part('workspace-label').textContent = state.workspace;\n if (state.conversation !== undefined) part('conversation-label').textContent = state.conversation;\n part('connection-status').hidden = !state.reconnecting;\n if (state.error) { part('inline-error').textContent = state.error.message; part('inline-error').hidden = !!state.error.hidden || !state.error.message; }\n if (state.busy !== undefined) {\n busy.hidden = !state.busy;\n if (state.busy) {\n if (!busy.firstChild) { busy.append(document.createElement('span'), document.createElement('button')); const button = busy.lastElementChild as HTMLButtonElement; button.type = 'button'; button.className = 'pui-text-button'; }\n busy.dataset.key = state.busy.key;\n if (busy.firstElementChild!.textContent !== state.busy.message) busy.firstElementChild!.textContent = state.busy.message;\n if (busy.lastElementChild!.textContent !== state.busy.actionLabel) busy.lastElementChild!.textContent = state.busy.actionLabel;\n }\n }\n parts.update();\n }, setSidebarOpen,\n openDialog(name: WorkspaceDialogName) { if (!destroyed) { setSidebarOpen(false); dialogs.get(name)?.open(); } },\n closeDialog(name: WorkspaceDialogName) { if (!destroyed) dialogs.get(name)?.close(); },\n isDialogOpen(name: WorkspaceDialogName) { return !destroyed && !!dialogs.get(name)?.isOpen(); },\n updateActionAvailability(unavailable: (scope: ActionScope) => boolean, root: ParentNode = element) {\n if (destroyed) return;\n for (const button of root.querySelectorAll<HTMLButtonElement>('[data-idle-action], [data-global-idle], [data-mcp-edit], [data-action=\"new-mcp\"]')) {\n const scope: ActionScope = button.hasAttribute('data-global-idle') || button.hasAttribute('data-mcp-edit') || button.dataset.action === 'new-mcp' ? { kind: 'global' } : button.dataset.idleConversation ? { kind: 'conversation', id: button.dataset.idleConversation } : button.dataset.idleWorkspace ? { kind: 'workspace', id: button.dataset.idleWorkspace } : { kind: 'active' };\n button.disabled = controlDisabled(button, unavailable(scope));\n }\n for (const link of root.querySelectorAll<HTMLAnchorElement>('a[data-download-conversation]')) link.setAttribute('aria-disabled', String(unavailable({ kind: 'conversation', id: link.dataset.downloadConversation })));\n },\n destroy() { if (destroyed) return; destroyed = true; for (const dialog of dialogs.values()) dialog.destroy(); parts.destroy(); search.removeEventListener('input', onSearch); element.removeEventListener('click', sidebarClick); busy.removeEventListener('click', onBusy); composer.destroy(); element.remove(); } };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pith-ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Native TypeScript building blocks with explicit behavior and a human-verifiable component showroom.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "AGPL-3.0-only",
|
|
7
|
+
"repository": { "type": "git", "url": "git+https://github.com/minifish-org/pith-ui.git" },
|
|
8
|
+
"exports": {
|
|
9
|
+
".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
|
|
10
|
+
"./styles.css": "./dist/styles.css"
|
|
11
|
+
},
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"files": ["dist", "README.md", "AI.md", "API.md", "LICENSE"],
|
|
15
|
+
"sideEffects": ["**/*.css"],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"check": "tsc --noEmit",
|
|
18
|
+
"build": "tsc -p tsconfig.build.json && node scripts/build.ts",
|
|
19
|
+
"test": "tsc -p tsconfig.test.json && node --test test-dist/tests/*.test.js",
|
|
20
|
+
"test:browser": "playwright test",
|
|
21
|
+
"dev": "vite --host 127.0.0.1",
|
|
22
|
+
"showroom:build": "vite build",
|
|
23
|
+
"preview": "vite preview --host 127.0.0.1",
|
|
24
|
+
"prepack": "npm run build"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": { "dompurify": "3.4.16", "marked": "16.4.2" },
|
|
27
|
+
"devDependencies": { "@playwright/test": "1.64.0", "@types/node": "^25.0.0", "typescript": "5.9.3", "vite": "7.3.6" },
|
|
28
|
+
"engines": { "node": ">=22.18.0" }
|
|
29
|
+
}
|