@getmateo/protocol 0.0.0-stage → 0.18.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/LICENSE +211 -0
- package/README.md +11 -2
- package/dist/addresses.d.ts +6 -0
- package/dist/addresses.js +2 -0
- package/dist/agent-attention-notification.d.ts +57 -0
- package/dist/agent-attention-notification.js +177 -0
- package/dist/agent-deep-link.d.ts +8 -0
- package/dist/agent-deep-link.js +49 -0
- package/dist/agent-labels.d.ts +14 -0
- package/dist/agent-labels.js +38 -0
- package/dist/agent-lifecycle.d.ts +3 -0
- package/dist/agent-lifecycle.js +8 -0
- package/dist/agent-message.d.ts +20 -0
- package/dist/agent-message.js +12 -0
- package/dist/agent-profile.d.ts +31 -0
- package/dist/agent-profile.js +32 -0
- package/dist/agent-runtime-config.d.ts +4 -0
- package/dist/agent-runtime-config.js +5 -0
- package/dist/agent-shells.d.ts +25 -0
- package/dist/agent-shells.js +17 -0
- package/dist/agent-state-bucket.d.ts +15 -0
- package/dist/agent-state-bucket.js +41 -0
- package/dist/agent-title-limits.d.ts +2 -0
- package/dist/agent-title-limits.js +2 -0
- package/dist/agent-types.d.ts +484 -0
- package/dist/agent-types.js +33 -0
- package/dist/binary-frames/demux.d.ts +15 -0
- package/dist/binary-frames/demux.js +28 -0
- package/dist/binary-frames/file-transfer.d.ts +51 -0
- package/dist/binary-frames/file-transfer.js +108 -0
- package/dist/binary-frames/host-route.d.ts +13 -0
- package/dist/binary-frames/host-route.js +39 -0
- package/dist/binary-frames/index.d.ts +5 -0
- package/dist/binary-frames/index.js +5 -0
- package/dist/binary-frames/terminal.d.ts +35 -0
- package/dist/binary-frames/terminal.js +100 -0
- package/dist/branch-slug.d.ts +14 -0
- package/dist/branch-slug.js +49 -0
- package/dist/browser-automation/capabilities.d.ts +7 -0
- package/dist/browser-automation/capabilities.js +31 -0
- package/dist/browser-automation/rpc-schemas.d.ts +1224 -0
- package/dist/browser-automation/rpc-schemas.js +497 -0
- package/dist/browser-download-rules.d.ts +21 -0
- package/dist/browser-download-rules.js +54 -0
- package/dist/build-metadata.d.ts +17 -0
- package/dist/build-metadata.js +61 -0
- package/dist/chat/rpc-schemas.d.ts +158 -0
- package/dist/chat/rpc-schemas.js +104 -0
- package/dist/chat/types.d.ts +30 -0
- package/dist/chat/types.js +23 -0
- package/dist/check-traits.d.ts +11 -0
- package/dist/check-traits.js +10 -0
- package/dist/chunked-transport.d.ts +42 -0
- package/dist/chunked-transport.js +277 -0
- package/dist/client-capabilities.d.ts +24 -0
- package/dist/client-capabilities.js +52 -0
- package/dist/connection-offer.d.ts +36 -0
- package/dist/connection-offer.js +53 -0
- package/dist/daemon-auth.d.ts +548 -0
- package/dist/daemon-auth.js +152 -0
- package/dist/daemon-endpoints.d.ts +54 -0
- package/dist/daemon-endpoints.js +243 -0
- package/dist/error-utils.d.ts +11 -0
- package/dist/error-utils.js +27 -0
- package/dist/fleet.d.ts +381 -0
- package/dist/fleet.js +134 -0
- package/dist/forge-manifest.d.ts +66 -0
- package/dist/forge-manifest.js +92 -0
- package/dist/generated/validation/ws-outbound-schema-metadata.d.ts +14187 -0
- package/dist/generated/validation/ws-outbound-schema-metadata.js +262 -0
- package/dist/generated/validation/ws-outbound.aot.d.ts +520 -0
- package/dist/generated/validation/ws-outbound.aot.js +106677 -0
- package/dist/git-remote.d.ts +33 -0
- package/dist/git-remote.js +94 -0
- package/dist/gitea-status.d.ts +10 -0
- package/dist/gitea-status.js +23 -0
- package/dist/gitlab-pipeline.d.ts +10 -0
- package/dist/gitlab-pipeline.js +17 -0
- package/dist/global-terminal.d.ts +3 -0
- package/dist/global-terminal.js +8 -0
- package/dist/host-connection-schema.d.ts +11 -0
- package/dist/host-connection-schema.js +9 -0
- package/dist/host-target.d.ts +20 -0
- package/dist/host-target.js +137 -0
- package/dist/hosts.d.ts +133 -0
- package/dist/hosts.js +82 -0
- package/dist/literal-union.d.ts +2 -0
- package/dist/literal-union.js +2 -0
- package/dist/loop/rpc-schemas.d.ts +636 -0
- package/dist/loop/rpc-schemas.js +164 -0
- package/dist/mateo-config-schema.d.ts +138 -0
- package/dist/mateo-config-schema.js +98 -0
- package/dist/mateo-tool-call-detail.d.ts +2 -0
- package/dist/mateo-tool-call-detail.js +3 -0
- package/dist/mateo-tool-presentation/agent-message.d.ts +10 -0
- package/dist/mateo-tool-presentation/agent-message.js +23 -0
- package/dist/mateo-tool-presentation/catalog.d.ts +321 -0
- package/dist/mateo-tool-presentation/catalog.js +319 -0
- package/dist/mateo-tool-presentation/detail-sections.d.ts +15 -0
- package/dist/mateo-tool-presentation/detail-sections.js +161 -0
- package/dist/mateo-tool-presentation/index.d.ts +22 -0
- package/dist/mateo-tool-presentation/index.js +62 -0
- package/dist/mateo-tool-presentation/summary-text.d.ts +7 -0
- package/dist/mateo-tool-presentation/summary-text.js +22 -0
- package/dist/messages.d.ts +70260 -0
- package/dist/messages.js +6740 -0
- package/dist/path-utils.d.ts +2 -0
- package/dist/path-utils.js +16 -0
- package/dist/plugin-browser-consent-copy.d.ts +193 -0
- package/dist/plugin-browser-consent-copy.js +109 -0
- package/dist/plugin-browser-grants.d.ts +48 -0
- package/dist/plugin-browser-grants.js +56 -0
- package/dist/plugin-browser.d.ts +321 -0
- package/dist/plugin-browser.js +109 -0
- package/dist/plugin-config.d.ts +18 -0
- package/dist/plugin-config.js +13 -0
- package/dist/plugin-overview.d.ts +12 -0
- package/dist/plugin-overview.js +50 -0
- package/dist/plugin-registry.d.ts +153 -0
- package/dist/plugin-registry.js +83 -0
- package/dist/plugin-requirements.d.ts +11 -0
- package/dist/plugin-requirements.js +26 -0
- package/dist/plugin-source-reference.d.ts +11 -0
- package/dist/plugin-source-reference.js +68 -0
- package/dist/provider-config.d.ts +141 -0
- package/dist/provider-config.js +113 -0
- package/dist/provider-icon-names.d.ts +5 -0
- package/dist/provider-icon-names.js +54 -0
- package/dist/provider-manifest.d.ts +30 -0
- package/dist/provider-manifest.js +247 -0
- package/dist/provider-snapshot-codec.d.ts +18 -0
- package/dist/provider-snapshot-codec.js +71 -0
- package/dist/schedule/cadence.d.ts +6 -0
- package/dist/schedule/cadence.js +28 -0
- package/dist/schedule/cron-expression.d.ts +14 -0
- package/dist/schedule/cron-expression.js +107 -0
- package/dist/schedule/rpc-schemas.d.ts +570 -0
- package/dist/schedule/rpc-schemas.js +158 -0
- package/dist/schedule/types.d.ts +201 -0
- package/dist/schedule/types.js +68 -0
- package/dist/search/text-match.d.ts +78 -0
- package/dist/search/text-match.js +330 -0
- package/dist/service-defaults.d.ts +3 -0
- package/dist/service-defaults.js +5 -0
- package/dist/ssh-transport.d.ts +11 -0
- package/dist/ssh-transport.js +72 -0
- package/dist/terminal-activity.d.ts +21 -0
- package/dist/terminal-activity.js +25 -0
- package/dist/terminal-input-mode.d.ts +30 -0
- package/dist/terminal-input-mode.js +180 -0
- package/dist/terminal-key-input.d.ts +13 -0
- package/dist/terminal-key-input.js +210 -0
- package/dist/terminal-profile.d.ts +10 -0
- package/dist/terminal-profile.js +11 -0
- package/dist/terminal-profiles.d.ts +41 -0
- package/dist/terminal-profiles.js +276 -0
- package/dist/terminal-snapshot.d.ts +4 -0
- package/dist/terminal-snapshot.js +220 -0
- package/dist/terminal-stream-protocol.d.ts +2 -0
- package/dist/terminal-stream-protocol.js +2 -0
- package/dist/terminal-subscription-key.d.ts +2 -0
- package/dist/terminal-subscription-key.js +9 -0
- package/dist/timeline-identity.d.ts +3 -0
- package/dist/timeline-identity.js +8 -0
- package/dist/tool-call-display.d.ts +13 -0
- package/dist/tool-call-display.js +144 -0
- package/dist/tool-name-normalization.d.ts +9 -0
- package/dist/tool-name-normalization.js +82 -0
- package/dist/user-agent.d.ts +26 -0
- package/dist/user-agent.js +101 -0
- package/dist/validation/ws-outbound-envelope.d.ts +13413 -0
- package/dist/validation/ws-outbound-envelope.js +17 -0
- package/dist/validation/ws-outbound.d.ts +12 -0
- package/dist/validation/ws-outbound.js +38 -0
- package/dist/websocket-message-limit.d.ts +5 -0
- package/dist/websocket-message-limit.js +5 -0
- package/dist/workspace-labels.d.ts +9 -0
- package/dist/workspace-labels.js +19 -0
- package/package.json +48 -4
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { getMateoToolLeafName } from "../tool-name-normalization.js";
|
|
2
|
+
import { getMateoToolEntry } from "./catalog.js";
|
|
3
|
+
const FIELD_LABELS = {
|
|
4
|
+
agentId: "Agent",
|
|
5
|
+
archivedAgentIds: "Archived agents",
|
|
6
|
+
baseBranch: "Base branch",
|
|
7
|
+
branchName: "New branch",
|
|
8
|
+
browserId: "Browser tab",
|
|
9
|
+
clearExpires: "Clear expiry",
|
|
10
|
+
currentModeId: "Current mode",
|
|
11
|
+
cwd: "Working directory",
|
|
12
|
+
deltaX: "Horizontal delta",
|
|
13
|
+
deltaY: "Vertical delta",
|
|
14
|
+
doubleClick: "Double click",
|
|
15
|
+
expiresIn: "Expires in",
|
|
16
|
+
expiresAt: "Expires",
|
|
17
|
+
filePaths: "Files",
|
|
18
|
+
fullPage: "Full page",
|
|
19
|
+
initialPrompt: "Prompt",
|
|
20
|
+
id: "ID",
|
|
21
|
+
lastMessage: "Last message",
|
|
22
|
+
maxEntries: "Maximum entries",
|
|
23
|
+
maxRuns: "Maximum runs",
|
|
24
|
+
modeId: "Mode",
|
|
25
|
+
newMode: "New mode",
|
|
26
|
+
nextRunAt: "Next run",
|
|
27
|
+
notifyOnFinish: "Notify on finish",
|
|
28
|
+
internal: "Internal",
|
|
29
|
+
prNumber: "Change request",
|
|
30
|
+
projectId: "Project",
|
|
31
|
+
removedDirectory: "Removed directory",
|
|
32
|
+
requestId: "Request",
|
|
33
|
+
scriptName: "Script",
|
|
34
|
+
sessionMode: "Session mode",
|
|
35
|
+
sinceHours: "Since (hours)",
|
|
36
|
+
sourceRef: "Source",
|
|
37
|
+
targetRef: "Target",
|
|
38
|
+
terminalId: "Terminal",
|
|
39
|
+
thinkingOptionId: "Thinking",
|
|
40
|
+
timeoutMs: "Timeout (ms)",
|
|
41
|
+
updateCount: "Updates",
|
|
42
|
+
workspaceId: "Workspace",
|
|
43
|
+
worktreeSlug: "Worktree",
|
|
44
|
+
};
|
|
45
|
+
function isRecord(value) {
|
|
46
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
47
|
+
}
|
|
48
|
+
function humanizeKey(key) {
|
|
49
|
+
const known = FIELD_LABELS[key];
|
|
50
|
+
if (known)
|
|
51
|
+
return known;
|
|
52
|
+
const words = key
|
|
53
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
54
|
+
.replace(/[._-]+/g, " ")
|
|
55
|
+
.split(" ")
|
|
56
|
+
.filter(Boolean);
|
|
57
|
+
const sentence = words.join(" ").toLowerCase();
|
|
58
|
+
return `${sentence[0]?.toUpperCase() ?? ""}${sentence.slice(1)}`;
|
|
59
|
+
}
|
|
60
|
+
function formatValue(value, depth = 0) {
|
|
61
|
+
if (value === null)
|
|
62
|
+
return "None";
|
|
63
|
+
if (value === undefined)
|
|
64
|
+
return "";
|
|
65
|
+
if (typeof value === "boolean")
|
|
66
|
+
return value ? "Yes" : "No";
|
|
67
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "bigint") {
|
|
68
|
+
return String(value);
|
|
69
|
+
}
|
|
70
|
+
if (Array.isArray(value)) {
|
|
71
|
+
if (value.length === 0)
|
|
72
|
+
return "None";
|
|
73
|
+
return value.map((item) => `• ${indentMultiline(formatValue(item, depth + 1), 2)}`).join("\n");
|
|
74
|
+
}
|
|
75
|
+
if (isRecord(value)) {
|
|
76
|
+
const entries = Object.entries(value).filter(([, child]) => child !== undefined);
|
|
77
|
+
if (entries.length === 0)
|
|
78
|
+
return "None";
|
|
79
|
+
return entries
|
|
80
|
+
.map(([key, child]) => {
|
|
81
|
+
const formatted = formatValue(child, depth + 1);
|
|
82
|
+
return `${humanizeKey(key)}: ${indentMultiline(formatted, 2)}`;
|
|
83
|
+
})
|
|
84
|
+
.join("\n");
|
|
85
|
+
}
|
|
86
|
+
return String(value);
|
|
87
|
+
}
|
|
88
|
+
function indentMultiline(value, spaces) {
|
|
89
|
+
const indentation = " ".repeat(spaces);
|
|
90
|
+
return value.replace(/\n/g, `\n${indentation}`);
|
|
91
|
+
}
|
|
92
|
+
function orderedEntries(value, order = [], omittedKey, includedKeys) {
|
|
93
|
+
const included = includedKeys ? new Set(includedKeys) : null;
|
|
94
|
+
const keys = Object.keys(value).filter((key) => key !== omittedKey && value[key] !== undefined && (!included || included.has(key)));
|
|
95
|
+
const rank = new Map(order.map((key, index) => [key, index]));
|
|
96
|
+
keys.sort((left, right) => {
|
|
97
|
+
const leftRank = rank.get(left) ?? Number.MAX_SAFE_INTEGER;
|
|
98
|
+
const rightRank = rank.get(right) ?? Number.MAX_SAFE_INTEGER;
|
|
99
|
+
return leftRank - rightRank || left.localeCompare(right);
|
|
100
|
+
});
|
|
101
|
+
return keys.map((key) => [key, value[key]]);
|
|
102
|
+
}
|
|
103
|
+
function fieldsFromValue(value, order, omittedKey, includedKeys) {
|
|
104
|
+
if (value === null || value === undefined)
|
|
105
|
+
return [];
|
|
106
|
+
if (!isRecord(value)) {
|
|
107
|
+
const formatted = formatValue(value);
|
|
108
|
+
return formatted ? [{ label: "Value", value: formatted }] : [];
|
|
109
|
+
}
|
|
110
|
+
return orderedEntries(value, order, omittedKey, includedKeys).map(([key, child]) => ({
|
|
111
|
+
label: humanizeKey(key),
|
|
112
|
+
value: formatValue(child),
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
function parseJsonText(value) {
|
|
116
|
+
if (typeof value !== "string")
|
|
117
|
+
return undefined;
|
|
118
|
+
try {
|
|
119
|
+
return JSON.parse(value);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function unwrapMcpResult(output) {
|
|
126
|
+
if (!isRecord(output))
|
|
127
|
+
return output;
|
|
128
|
+
if (output.structuredContent !== undefined) {
|
|
129
|
+
return output.structuredContent;
|
|
130
|
+
}
|
|
131
|
+
if (Array.isArray(output.content) && output.content.length === 1) {
|
|
132
|
+
const item = output.content[0];
|
|
133
|
+
if (isRecord(item) && item.type === "text") {
|
|
134
|
+
return parseJsonText(item.text) ?? item.text;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return output;
|
|
138
|
+
}
|
|
139
|
+
export function buildMateoToolDetailSections(toolName, input, output) {
|
|
140
|
+
const leafName = getMateoToolLeafName(toolName);
|
|
141
|
+
if (!leafName)
|
|
142
|
+
return null;
|
|
143
|
+
const spec = getMateoToolEntry(leafName)?.detail ?? {};
|
|
144
|
+
const sections = [];
|
|
145
|
+
if (spec.promptField && isRecord(input)) {
|
|
146
|
+
const prompt = input[spec.promptField];
|
|
147
|
+
if (typeof prompt === "string" && prompt.length > 0) {
|
|
148
|
+
sections.push({ kind: "prose", title: "Prompt", text: prompt });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const inputFields = fieldsFromValue(input, spec.inputOrder, spec.promptField);
|
|
152
|
+
if (inputFields.length > 0) {
|
|
153
|
+
sections.push({ kind: "fields", title: "Details", fields: inputFields });
|
|
154
|
+
}
|
|
155
|
+
const outputFields = fieldsFromValue(unwrapMcpResult(output), spec.outputFields, undefined, spec.outputFields);
|
|
156
|
+
if (outputFields.length > 0) {
|
|
157
|
+
sections.push({ kind: "fields", title: "Result", fields: outputFields });
|
|
158
|
+
}
|
|
159
|
+
return sections;
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=detail-sections.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ToolCallDetail } from "../agent-types.js";
|
|
2
|
+
import { type MateoToolName } from "./catalog.js";
|
|
3
|
+
export { buildAgentMessageDisplay, type AgentMessageDisplay } from "./agent-message.js";
|
|
4
|
+
export { buildMateoToolDetailSections, type MateoToolDetailField, type MateoToolDetailSection, } from "./detail-sections.js";
|
|
5
|
+
export { MAX_SUMMARY_CHARS } from "./summary-text.js";
|
|
6
|
+
export type { MateoToolName };
|
|
7
|
+
export interface MateoToolDisplayInput {
|
|
8
|
+
toolName: string;
|
|
9
|
+
detail: ToolCallDetail;
|
|
10
|
+
/** Title of the agent named by the call's `agentId`, when the caller knows it. */
|
|
11
|
+
targetAgentTitle?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface MateoToolDisplay {
|
|
14
|
+
displayName: string;
|
|
15
|
+
summary?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const MATEO_TOOL_NAMES: readonly MateoToolName[];
|
|
18
|
+
/** Returns null for tools outside the Mateo namespace. */
|
|
19
|
+
export declare function buildMateoToolDisplay(input: MateoToolDisplayInput): MateoToolDisplay | null;
|
|
20
|
+
/** The agent a Mateo call acts on, so callers can resolve its title. */
|
|
21
|
+
export declare function getMateoToolTargetAgentId(toolName: string, detail: ToolCallDetail | undefined): string | null;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { getMateoToolLeafName, isMateoToolName } from "../tool-name-normalization.js";
|
|
2
|
+
import { getMateoToolEntry, MATEO_TOOL_CATALOG } from "./catalog.js";
|
|
3
|
+
import { toSummaryText } from "./summary-text.js";
|
|
4
|
+
export { buildAgentMessageDisplay } from "./agent-message.js";
|
|
5
|
+
export { buildMateoToolDetailSections, } from "./detail-sections.js";
|
|
6
|
+
export { MAX_SUMMARY_CHARS } from "./summary-text.js";
|
|
7
|
+
export const MATEO_TOOL_NAMES = Object.keys(MATEO_TOOL_CATALOG);
|
|
8
|
+
/** Returns null for tools outside the Mateo namespace. */
|
|
9
|
+
export function buildMateoToolDisplay(input) {
|
|
10
|
+
const leafName = mateoLeafName(input.toolName);
|
|
11
|
+
if (!leafName)
|
|
12
|
+
return null;
|
|
13
|
+
const entry = getMateoToolEntry(leafName);
|
|
14
|
+
if (!entry)
|
|
15
|
+
return { displayName: humanizeLeafName(leafName) };
|
|
16
|
+
const toolInput = readToolInput(input.detail);
|
|
17
|
+
const targetAgent = input.targetAgentTitle ?? readString(toolInput.agentId);
|
|
18
|
+
const summary = formatContext(entry.context?.(toolInput, targetAgent));
|
|
19
|
+
return { displayName: entry.label, ...(summary ? { summary } : {}) };
|
|
20
|
+
}
|
|
21
|
+
/** The agent a Mateo call acts on, so callers can resolve its title. */
|
|
22
|
+
export function getMateoToolTargetAgentId(toolName, detail) {
|
|
23
|
+
if (!detail || !mateoLeafName(toolName))
|
|
24
|
+
return null;
|
|
25
|
+
return readString(readToolInput(detail).agentId) ?? null;
|
|
26
|
+
}
|
|
27
|
+
function mateoLeafName(toolName) {
|
|
28
|
+
return isMateoToolName(toolName) ? getMateoToolLeafName(toolName) : null;
|
|
29
|
+
}
|
|
30
|
+
function readToolInput(detail) {
|
|
31
|
+
if (detail.type !== "unknown")
|
|
32
|
+
return {};
|
|
33
|
+
const value = detail.input;
|
|
34
|
+
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
35
|
+
? value
|
|
36
|
+
: {};
|
|
37
|
+
}
|
|
38
|
+
function readString(value) {
|
|
39
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
40
|
+
}
|
|
41
|
+
function formatContext(value) {
|
|
42
|
+
if (typeof value === "string")
|
|
43
|
+
return toSummaryText(value);
|
|
44
|
+
if (typeof value === "number")
|
|
45
|
+
return String(value);
|
|
46
|
+
if (Array.isArray(value)) {
|
|
47
|
+
const [first, ...rest] = value;
|
|
48
|
+
const head = typeof first === "string" ? toSummaryText(first) : undefined;
|
|
49
|
+
if (!head)
|
|
50
|
+
return undefined;
|
|
51
|
+
return rest.length > 0 ? `${head} +${rest.length}` : head;
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
function humanizeLeafName(leafName) {
|
|
56
|
+
const sentence = leafName
|
|
57
|
+
.replace(/[._-]+/g, " ")
|
|
58
|
+
.trim()
|
|
59
|
+
.toLowerCase();
|
|
60
|
+
return `${sentence[0]?.toUpperCase() ?? ""}${sentence.slice(1)}`;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompts and results can be one enormous line. Summaries are capped here so no
|
|
3
|
+
* consumer relies on its renderer to clip them.
|
|
4
|
+
*/
|
|
5
|
+
export declare const MAX_SUMMARY_CHARS = 120;
|
|
6
|
+
export declare function toSummaryText(value: string): string | undefined;
|
|
7
|
+
//# sourceMappingURL=summary-text.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompts and results can be one enormous line. Summaries are capped here so no
|
|
3
|
+
* consumer relies on its renderer to clip them.
|
|
4
|
+
*/
|
|
5
|
+
export const MAX_SUMMARY_CHARS = 120;
|
|
6
|
+
// Bounds the whitespace scan: inputs can be megabytes.
|
|
7
|
+
const SCAN_WINDOW_CHARS = MAX_SUMMARY_CHARS * 4;
|
|
8
|
+
export function toSummaryText(value) {
|
|
9
|
+
const isPartial = value.length > SCAN_WINDOW_CHARS;
|
|
10
|
+
const collapsed = value.slice(0, SCAN_WINDOW_CHARS).replace(/\s+/g, " ").trim();
|
|
11
|
+
if (!collapsed)
|
|
12
|
+
return undefined;
|
|
13
|
+
if (collapsed.length <= MAX_SUMMARY_CHARS && !isPartial)
|
|
14
|
+
return collapsed;
|
|
15
|
+
const kept = dropTrailingHighSurrogate(collapsed.slice(0, MAX_SUMMARY_CHARS - 1)).trimEnd();
|
|
16
|
+
return `${kept}…`;
|
|
17
|
+
}
|
|
18
|
+
function dropTrailingHighSurrogate(text) {
|
|
19
|
+
const last = text.charCodeAt(text.length - 1);
|
|
20
|
+
return last >= 0xd800 && last <= 0xdbff ? text.slice(0, -1) : text;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=summary-text.js.map
|