@sagmans/dsh-tui 0.1.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +196 -17
- package/cordis.patch.yml +4 -2
- package/lib/agent/host.d.ts +14 -0
- package/lib/agent/host.d.ts.map +1 -1
- package/lib/agent/host.js +20 -4
- package/lib/agent/host.js.map +1 -1
- package/lib/agent/model.d.ts +50 -0
- package/lib/agent/model.d.ts.map +1 -1
- package/lib/agent/model.js +87 -1
- package/lib/agent/model.js.map +1 -1
- package/lib/agent/present.d.ts +7 -1
- package/lib/agent/present.d.ts.map +1 -1
- package/lib/agent/present.js +33 -4
- package/lib/agent/present.js.map +1 -1
- package/lib/agent/presets.d.ts +7 -1
- package/lib/agent/presets.d.ts.map +1 -1
- package/lib/agent/presets.js +7 -3
- package/lib/agent/presets.js.map +1 -1
- package/lib/agent/status.d.ts +10 -0
- package/lib/agent/status.d.ts.map +1 -1
- package/lib/agent/status.js +2 -0
- package/lib/agent/status.js.map +1 -1
- package/lib/cards.d.ts +127 -7
- package/lib/cards.d.ts.map +1 -1
- package/lib/cards.js +381 -52
- package/lib/cards.js.map +1 -1
- package/lib/export.d.ts +5 -4
- package/lib/export.d.ts.map +1 -1
- package/lib/export.js +62 -13
- package/lib/export.js.map +1 -1
- package/lib/fold-cursor.d.ts +23 -0
- package/lib/fold-cursor.d.ts.map +1 -0
- package/lib/fold-cursor.js +31 -0
- package/lib/fold-cursor.js.map +1 -0
- package/lib/gates.d.ts +145 -2
- package/lib/gates.d.ts.map +1 -1
- package/lib/gates.js +335 -40
- package/lib/gates.js.map +1 -1
- package/lib/index.d.ts +7 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +651 -92
- package/lib/index.js.map +1 -1
- package/lib/input/actions.d.ts +136 -0
- package/lib/input/actions.d.ts.map +1 -0
- package/lib/input/actions.js +740 -0
- package/lib/input/actions.js.map +1 -0
- package/lib/input/keymap-settings.d.ts +21 -0
- package/lib/input/keymap-settings.d.ts.map +1 -0
- package/lib/input/keymap-settings.js +28 -0
- package/lib/input/keymap-settings.js.map +1 -0
- package/lib/input/keymap.d.ts +91 -0
- package/lib/input/keymap.d.ts.map +1 -0
- package/lib/input/keymap.js +170 -0
- package/lib/input/keymap.js.map +1 -0
- package/lib/input/match.d.ts +10 -0
- package/lib/input/match.d.ts.map +1 -0
- package/lib/input/match.js +83 -0
- package/lib/input/match.js.map +1 -0
- package/lib/input/submission.d.ts +8 -1
- package/lib/input/submission.d.ts.map +1 -1
- package/lib/input/submission.js +9 -2
- package/lib/input/submission.js.map +1 -1
- package/lib/input.d.ts +17 -0
- package/lib/input.d.ts.map +1 -0
- package/lib/input.js +27 -0
- package/lib/input.js.map +1 -0
- package/lib/keys-command.d.ts +16 -0
- package/lib/keys-command.d.ts.map +1 -0
- package/lib/keys-command.js +60 -0
- package/lib/keys-command.js.map +1 -0
- package/lib/queue.d.ts +6 -0
- package/lib/queue.d.ts.map +1 -0
- package/lib/queue.js +68 -0
- package/lib/queue.js.map +1 -0
- package/lib/settings-notice.d.ts +19 -0
- package/lib/settings-notice.d.ts.map +1 -0
- package/lib/settings-notice.js +30 -0
- package/lib/settings-notice.js.map +1 -0
- package/lib/terminal/warning-screen.d.ts +8 -0
- package/lib/terminal/warning-screen.d.ts.map +1 -0
- package/lib/terminal/warning-screen.js +66 -0
- package/lib/terminal/warning-screen.js.map +1 -0
- package/lib/theme-capability.d.ts +36 -0
- package/lib/theme-capability.d.ts.map +1 -0
- package/lib/theme-capability.js +190 -0
- package/lib/theme-capability.js.map +1 -0
- package/lib/theme-command.d.ts +10 -0
- package/lib/theme-command.d.ts.map +1 -0
- package/lib/theme-command.js +61 -0
- package/lib/theme-command.js.map +1 -0
- package/lib/theme-settings.d.ts +196 -0
- package/lib/theme-settings.d.ts.map +1 -0
- package/lib/theme-settings.js +229 -0
- package/lib/theme-settings.js.map +1 -0
- package/lib/theme-tokens.d.ts +110 -0
- package/lib/theme-tokens.d.ts.map +1 -0
- package/lib/theme-tokens.js +427 -0
- package/lib/theme-tokens.js.map +1 -0
- package/lib/theme.d.ts +32 -35
- package/lib/theme.d.ts.map +1 -1
- package/lib/theme.js +112 -63
- package/lib/theme.js.map +1 -1
- package/lib/tokens.d.ts +15 -0
- package/lib/tokens.d.ts.map +1 -0
- package/lib/tokens.js +29 -0
- package/lib/tokens.js.map +1 -0
- package/lib/transcript.d.ts +26 -1
- package/lib/transcript.d.ts.map +1 -1
- package/lib/transcript.js +153 -25
- package/lib/transcript.js.map +1 -1
- package/lib/ui/dock.d.ts.map +1 -1
- package/lib/ui/dock.js +67 -28
- package/lib/ui/dock.js.map +1 -1
- package/lib/ui/editor.d.ts +51 -0
- package/lib/ui/editor.d.ts.map +1 -0
- package/lib/ui/editor.js +159 -0
- package/lib/ui/editor.js.map +1 -0
- package/lib/ui/frame.d.ts +54 -0
- package/lib/ui/frame.d.ts.map +1 -0
- package/lib/ui/frame.js +79 -0
- package/lib/ui/frame.js.map +1 -0
- package/lib/ui/gate-input.d.ts +20 -0
- package/lib/ui/gate-input.d.ts.map +1 -0
- package/lib/ui/gate-input.js +96 -0
- package/lib/ui/gate-input.js.map +1 -0
- package/lib/ui/markdown.d.ts +19 -2
- package/lib/ui/markdown.d.ts.map +1 -1
- package/lib/ui/markdown.js +37 -6
- package/lib/ui/markdown.js.map +1 -1
- package/lib/ui/mermaid.d.ts +44 -0
- package/lib/ui/mermaid.d.ts.map +1 -0
- package/lib/ui/mermaid.js +178 -0
- package/lib/ui/mermaid.js.map +1 -0
- package/lib/ui/picker.d.ts +66 -7
- package/lib/ui/picker.d.ts.map +1 -1
- package/lib/ui/picker.js +112 -19
- package/lib/ui/picker.js.map +1 -1
- package/lib/ui/prompt.d.ts +30 -0
- package/lib/ui/prompt.d.ts.map +1 -0
- package/lib/ui/prompt.js +45 -0
- package/lib/ui/prompt.js.map +1 -0
- package/lib/ui/queue.d.ts +24 -0
- package/lib/ui/queue.d.ts.map +1 -0
- package/lib/ui/queue.js +57 -0
- package/lib/ui/queue.js.map +1 -0
- package/lib/ui/status.d.ts +7 -1
- package/lib/ui/status.d.ts.map +1 -1
- package/lib/ui/status.js +84 -24
- package/lib/ui/status.js.map +1 -1
- package/lib/ui/view.d.ts +65 -2
- package/lib/ui/view.d.ts.map +1 -1
- package/lib/ui/view.js +319 -59
- package/lib/ui/view.js.map +1 -1
- package/lib/work.d.ts +48 -0
- package/lib/work.d.ts.map +1 -1
- package/lib/work.js +44 -0
- package/lib/work.js.map +1 -1
- package/package.json +5 -2
package/lib/theme.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,WAAW,EAAE,KAAK,aAAa,EAAwB,MAAM,wBAAwB,CAAA;AACpH,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACzE,OAAO,EAAoF,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACnI,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAazD;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,8BAA8B;IAC9B,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IAC5C,4EAA4E;IAC5E,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC3D,4EAA4E;IAC5E,KAAK,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAAA;IAC9B,0CAA0C;IAC1C,OAAO,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAA;IACjC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAC5B,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAA;CACjC;AA2CD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,IAAI,GAAE,UAA0C,EAAE,SAAS,GAAE,cAA6B,GAAG,QAAQ,CAoChI;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,WAAW,GAAG,WAAW,CAWzE;AAED,8DAA8D;AAC9D,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,aAAa,GAAG,aAAa,CAiB/E"}
|
package/lib/theme.js
CHANGED
|
@@ -1,84 +1,133 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { truncateToWidth } from '@earendil-works/pi-tui';
|
|
2
|
+
import { detectColourMode } from "./theme-capability.js";
|
|
3
|
+
import { DEFAULT_PALETTE, DEFAULT_TOKENS, resetSequence, resolveToken } from "./theme-tokens.js";
|
|
4
|
+
/** What a caller gets when it has written no settings at all. */
|
|
5
|
+
const NO_OVERRIDES = { palette: DEFAULT_PALETTE, tokens: new Map() };
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
+
* Distinguishes one theme table from the next.
|
|
7
8
|
*
|
|
8
|
-
*
|
|
9
|
-
* its
|
|
10
|
-
* terminal theme.
|
|
9
|
+
* A renderer caches rows against the theme that produced them, so the revision
|
|
10
|
+
* is how a cache learns its rows were drawn under a table that is now stale.
|
|
11
11
|
*/
|
|
12
|
+
let themeRevision = 0;
|
|
13
|
+
/** Style markdown through the same table as the rest of the surface. */
|
|
12
14
|
function markdownTheme(style) {
|
|
13
15
|
return {
|
|
14
|
-
heading: text => style
|
|
15
|
-
link: text => style
|
|
16
|
-
linkUrl: style.
|
|
17
|
-
code: style.
|
|
18
|
-
codeBlock: text => text,
|
|
19
|
-
codeBlockBorder: style.
|
|
20
|
-
quote: style.
|
|
21
|
-
quoteBorder: style.
|
|
22
|
-
hr: style.
|
|
23
|
-
listBullet: style.
|
|
24
|
-
bold: style.bold,
|
|
25
|
-
italic: style.italic,
|
|
26
|
-
strikethrough: style.
|
|
27
|
-
underline: style.underline,
|
|
16
|
+
heading: text => style('markdown.heading', text),
|
|
17
|
+
link: text => style('markdown.link', text),
|
|
18
|
+
linkUrl: text => style('markdown.linkUrl', text),
|
|
19
|
+
code: text => style('markdown.code', text),
|
|
20
|
+
codeBlock: text => style('markdown.codeBlock', text),
|
|
21
|
+
codeBlockBorder: text => style('markdown.codeBlockBorder', text),
|
|
22
|
+
quote: text => style('markdown.quote', text),
|
|
23
|
+
quoteBorder: text => style('markdown.quoteBorder', text),
|
|
24
|
+
hr: text => style('markdown.hr', text),
|
|
25
|
+
listBullet: text => style('markdown.listBullet', text),
|
|
26
|
+
bold: text => style('markdown.bold', text),
|
|
27
|
+
italic: text => style('markdown.italic', text),
|
|
28
|
+
strikethrough: text => style('markdown.strikethrough', text),
|
|
29
|
+
underline: text => style('markdown.underline', text),
|
|
28
30
|
};
|
|
29
31
|
}
|
|
30
|
-
|
|
32
|
+
/** The editor keeps only a border colour and a select list, so both come from tokens. */
|
|
33
|
+
function editorTheme(style, visible) {
|
|
31
34
|
return {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
// Hiding the border has to remove it: returning the text unstyled would draw
|
|
36
|
+
// it louder than the muted default the reader was trying to remove.
|
|
37
|
+
borderColor: text => (visible('editor.border') ? style('editor.border', text) : ''),
|
|
38
|
+
// A select-list row is framework-owned text, so a hidden entry can only be
|
|
39
|
+
// unstyled rather than absent; the README records that limit.
|
|
40
|
+
selectList: {
|
|
41
|
+
selectedPrefix: text => style('editor.selectList.selectedPrefix', text),
|
|
42
|
+
selectedText: text => style('editor.selectList.selectedText', text),
|
|
43
|
+
description: text => style('editor.selectList.description', text),
|
|
44
|
+
scrollInfo: text => style('editor.selectList.scrollInfo', text),
|
|
45
|
+
noMatch: text => style('editor.selectList.noMatch', text),
|
|
46
|
+
},
|
|
37
47
|
};
|
|
38
48
|
}
|
|
39
49
|
/**
|
|
40
|
-
*
|
|
50
|
+
* Build the surface theme.
|
|
41
51
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
52
|
+
* Every token is resolved once, when the theme is built, rather than per frame:
|
|
53
|
+
* a repaint walks the whole transcript and re-resolving a palette chain for
|
|
54
|
+
* every row would pay for the same answer thousands of times. A settings change
|
|
55
|
+
* builds a new theme instead, which is also what makes the swap atomic.
|
|
46
56
|
*/
|
|
47
|
-
export function
|
|
48
|
-
const
|
|
49
|
-
|
|
57
|
+
export function createTheme(mode = detectColourMode(process.env), overrides = NO_OVERRIDES) {
|
|
58
|
+
const resolved = new Map();
|
|
59
|
+
const resolve = (token) => {
|
|
60
|
+
const cached = resolved.get(token);
|
|
61
|
+
if (cached !== undefined)
|
|
62
|
+
return cached;
|
|
63
|
+
const style = resolveToken(token, overrides.tokens, overrides.palette, mode);
|
|
64
|
+
resolved.set(token, style);
|
|
65
|
+
return style;
|
|
66
|
+
};
|
|
67
|
+
const style = (token, text) => {
|
|
68
|
+
const { prefix, suffix } = resolve(token);
|
|
69
|
+
return prefix === '' ? text : `${prefix}${text}${suffix}`;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Truncate to a width, honouring the promise that `none` emits nothing.
|
|
73
|
+
*
|
|
74
|
+
* pi-tui closes a cut by writing a reset unconditionally, whether or not the
|
|
75
|
+
* text carried any styling, so a truncated row leaks escapes even when
|
|
76
|
+
* colour is off. Those resets close styles this surface never opened, so
|
|
77
|
+
* dropping them restores the contract without changing what is drawn.
|
|
78
|
+
*/
|
|
79
|
+
const cut = (text, width, ellipsis = '') => {
|
|
80
|
+
const truncated = truncateToWidth(text, width, ellipsis);
|
|
81
|
+
return mode === 'none' ? truncated.replaceAll(resetSequence(), '') : truncated;
|
|
82
|
+
};
|
|
83
|
+
const visible = (token) => !resolve(token).hidden;
|
|
84
|
+
return {
|
|
85
|
+
revision: ++themeRevision,
|
|
86
|
+
color: mode !== 'none',
|
|
87
|
+
style,
|
|
88
|
+
cut,
|
|
89
|
+
glyph: token => resolve(token).glyph,
|
|
90
|
+
visible,
|
|
91
|
+
editor: editorTheme(style, visible),
|
|
92
|
+
markdown: markdownTheme(style),
|
|
93
|
+
};
|
|
50
94
|
}
|
|
51
95
|
/**
|
|
52
|
-
*
|
|
96
|
+
* An editor theme that follows a moving source.
|
|
53
97
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
98
|
+
* The editor keeps the theme it was built with for the life of the session, so
|
|
99
|
+
* a settings change has to reach it through a stable object instead of by
|
|
100
|
+
* replacing the one it captured.
|
|
57
101
|
*/
|
|
58
|
-
export function
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
102
|
+
export function forwardEditorTheme(source) {
|
|
103
|
+
return {
|
|
104
|
+
borderColor: text => source().borderColor(text),
|
|
105
|
+
selectList: {
|
|
106
|
+
selectedPrefix: text => source().selectList.selectedPrefix(text),
|
|
107
|
+
selectedText: text => source().selectList.selectedText(text),
|
|
108
|
+
description: text => source().selectList.description(text),
|
|
109
|
+
scrollInfo: text => source().selectList.scrollInfo(text),
|
|
110
|
+
noMatch: text => source().selectList.noMatch(text),
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/** The markdown counterpart of {@link forwardEditorTheme}. */
|
|
115
|
+
export function forwardMarkdownTheme(source) {
|
|
68
116
|
return {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
117
|
+
heading: text => source().heading(text),
|
|
118
|
+
link: text => source().link(text),
|
|
119
|
+
linkUrl: text => source().linkUrl(text),
|
|
120
|
+
code: text => source().code(text),
|
|
121
|
+
codeBlock: text => source().codeBlock(text),
|
|
122
|
+
codeBlockBorder: text => source().codeBlockBorder(text),
|
|
123
|
+
quote: text => source().quote(text),
|
|
124
|
+
quoteBorder: text => source().quoteBorder(text),
|
|
125
|
+
hr: text => source().hr(text),
|
|
126
|
+
listBullet: text => source().listBullet(text),
|
|
127
|
+
bold: text => source().bold(text),
|
|
128
|
+
italic: text => source().italic(text),
|
|
129
|
+
strikethrough: text => source().strikethrough(text),
|
|
130
|
+
underline: text => source().underline(text),
|
|
82
131
|
};
|
|
83
132
|
}
|
|
84
133
|
//# sourceMappingURL=theme.js.map
|
package/lib/theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA8D,MAAM,wBAAwB,CAAA;AACpH,OAAO,EAAE,gBAAgB,EAAmB,MAAM,uBAAuB,CAAA;AACzE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAqC,MAAM,mBAAmB,CAAA;AAGnI,iEAAiE;AACjE,MAAM,YAAY,GAAmB,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,IAAI,GAAG,EAAE,EAAE,CAAA;AAEpF;;;;;GAKG;AACH,IAAI,aAAa,GAAG,CAAC,CAAA;AAuBrB,wEAAwE;AACxE,SAAS,aAAa,CAAC,KAAgD;IACrE,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,kBAAkB,EAAE,IAAI,CAAC;QAChD,IAAI,EA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,CAAC,UAAU,CAAC,IAAI,CAAC;QAC7C,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;QACjC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;QACrC,aAAa,EAAE,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC;QACnD,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC;KAC5C,CAAA;AACH,CAAC"}
|
package/lib/tokens.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token estimates shared by every row that reports a size.
|
|
3
|
+
*
|
|
4
|
+
* The exact count needs the provider's own tokenizer, which a terminal does not
|
|
5
|
+
* have; four characters per token is the estimate a reader can compare against,
|
|
6
|
+
* and one definition keeps a reasoning row, a status row, and a tool card from
|
|
7
|
+
* disagreeing about the same text.
|
|
8
|
+
*/
|
|
9
|
+
/** Characters a provider bills as roughly one token. */
|
|
10
|
+
export declare const CHARS_PER_TOKEN = 4;
|
|
11
|
+
/** A thought's or a payload's size in tokens, rounded up so a non-empty text never reads as zero. */
|
|
12
|
+
export declare function countTokens(text: string): number;
|
|
13
|
+
/** Compact a token count, because the exact number changes nothing a reader decides. */
|
|
14
|
+
export declare function formatTokens(count: number): string;
|
|
15
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,wDAAwD;AACxD,eAAO,MAAM,eAAe,IAAI,CAAA;AAMhC,qGAAqG;AACrG,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wFAAwF;AACxF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMlD"}
|
package/lib/tokens.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token estimates shared by every row that reports a size.
|
|
3
|
+
*
|
|
4
|
+
* The exact count needs the provider's own tokenizer, which a terminal does not
|
|
5
|
+
* have; four characters per token is the estimate a reader can compare against,
|
|
6
|
+
* and one definition keeps a reasoning row, a status row, and a tool card from
|
|
7
|
+
* disagreeing about the same text.
|
|
8
|
+
*/
|
|
9
|
+
/** Characters a provider bills as roughly one token. */
|
|
10
|
+
export const CHARS_PER_TOKEN = 4;
|
|
11
|
+
const THOUSAND = 1000;
|
|
12
|
+
const HUNDRED_THOUSAND = 100 * THOUSAND;
|
|
13
|
+
const MILLION = 1_000_000;
|
|
14
|
+
/** A thought's or a payload's size in tokens, rounded up so a non-empty text never reads as zero. */
|
|
15
|
+
export function countTokens(text) {
|
|
16
|
+
return Math.ceil(text.length / CHARS_PER_TOKEN);
|
|
17
|
+
}
|
|
18
|
+
/** Compact a token count, because the exact number changes nothing a reader decides. */
|
|
19
|
+
export function formatTokens(count) {
|
|
20
|
+
if (count >= MILLION)
|
|
21
|
+
return `${(count / MILLION).toFixed(1)}M`;
|
|
22
|
+
// A decimal on a five-digit count is noise: 128.0k reads worse than 128k.
|
|
23
|
+
if (count >= HUNDRED_THOUSAND)
|
|
24
|
+
return `${Math.round(count / THOUSAND)}k`;
|
|
25
|
+
if (count >= THOUSAND)
|
|
26
|
+
return `${(count / THOUSAND).toFixed(1)}k`;
|
|
27
|
+
return String(count);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,wDAAwD;AACxD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAA;AAEhC,MAAM,QAAQ,GAAG,IAAI,CAAA;AACrB,MAAM,gBAAgB,GAAG,GAAG,GAAG,QAAQ,CAAA;AACvC,MAAM,OAAO,GAAG,SAAS,CAAA;AAEzB,qGAAqG;AACrG,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC,CAAA;AACjD,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,IAAI,KAAK,IAAI,OAAO;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAA;IAC/D,0EAA0E;IAC1E,IAAI,KAAK,IAAI,gBAAgB;QAAE,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAA;IACxE,IAAI,KAAK,IAAI,QAAQ;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAA;IACjE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;AACtB,CAAC"}
|
package/lib/transcript.d.ts
CHANGED
|
@@ -49,9 +49,23 @@ export declare class TranscriptModel {
|
|
|
49
49
|
private readonly now;
|
|
50
50
|
private readonly settled;
|
|
51
51
|
private readonly pending;
|
|
52
|
+
/**
|
|
53
|
+
* Where each nested call landed on its root card.
|
|
54
|
+
*
|
|
55
|
+
* A dispatch logs a start and then a settle, so the second event has to find
|
|
56
|
+
* the row the first one drew instead of adding a second line for one call.
|
|
57
|
+
*/
|
|
58
|
+
private readonly pendingSub;
|
|
52
59
|
private live;
|
|
53
60
|
private liveReasoning;
|
|
54
61
|
private reasoningStartedAt;
|
|
62
|
+
/**
|
|
63
|
+
* Whether this step already painted a thought from the stream.
|
|
64
|
+
*
|
|
65
|
+
* A live turn streams the thinking and then records the same text in the
|
|
66
|
+
* message, so the recorded copy is a repeat rather than a second thought.
|
|
67
|
+
*/
|
|
68
|
+
private reasoningPaintedThisStep;
|
|
55
69
|
constructor(presenter?: ToolPresenter | undefined,
|
|
56
70
|
/** Clock for "how long has this been thinking"; injected so a test can pin it. */
|
|
57
71
|
now?: () => number);
|
|
@@ -79,13 +93,24 @@ export declare class TranscriptModel {
|
|
|
79
93
|
/** Report a live agent failure the durable log never carries as a message. */
|
|
80
94
|
reportError(error: unknown): void;
|
|
81
95
|
/**
|
|
82
|
-
* Settle
|
|
96
|
+
* Settle one thought into a row of its own.
|
|
83
97
|
*
|
|
84
98
|
* The row lands where the reasoning happened, which is before the answer it
|
|
85
99
|
* produced, so reading order still matches the order the model thought in.
|
|
86
100
|
*/
|
|
101
|
+
private paintReasoning;
|
|
102
|
+
/** Settle the reasoning streamed so far into a row of its own. */
|
|
87
103
|
private settleReasoning;
|
|
88
104
|
apply(event: FoldableEvent): void;
|
|
105
|
+
/**
|
|
106
|
+
* Fold one nested PTC call onto the card of the run_code call that dispatched it.
|
|
107
|
+
*
|
|
108
|
+
* Dispatches are logged while the program runs, so the root is still pending;
|
|
109
|
+
* a dispatch whose root is not in this fold belongs to a window that starts
|
|
110
|
+
* mid-run, and attaching it to another card would claim a call that card
|
|
111
|
+
* never made.
|
|
112
|
+
*/
|
|
113
|
+
private applySubCall;
|
|
89
114
|
private settleToolResult;
|
|
90
115
|
}
|
|
91
116
|
//# sourceMappingURL=transcript.d.ts.map
|
package/lib/transcript.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../src/transcript.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../src/transcript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAA;AAGhI,qCAAqC;AACrC,MAAM,MAAM,eAAe,GACvB;IA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