@uptimizr/agent-core 1.1.1 → 1.2.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/AGENTS.md +221 -34
- package/README.md +57 -21
- package/dist/client.d.ts +22 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +39 -10
- package/dist/client.js.map +1 -1
- package/dist/context.d.ts +93 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +137 -0
- package/dist/context.js.map +1 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -2
- package/dist/index.js.map +1 -1
- package/dist/nonRegistryTools.d.ts +34 -0
- package/dist/nonRegistryTools.d.ts.map +1 -0
- package/dist/nonRegistryTools.js +70 -0
- package/dist/nonRegistryTools.js.map +1 -0
- package/dist/prompt.d.ts +33 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +49 -0
- package/dist/prompt.js.map +1 -0
- package/dist/provider.d.ts +18 -0
- package/dist/provider.d.ts.map +1 -1
- package/dist/providers/anthropic.d.ts +18 -1
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +35 -3
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/openai.d.ts +14 -1
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +23 -1
- package/dist/providers/openai.js.map +1 -1
- package/dist/queryTool.d.ts +36 -0
- package/dist/queryTool.d.ts.map +1 -0
- package/dist/queryTool.js +123 -0
- package/dist/queryTool.js.map +1 -0
- package/dist/registryTools.d.ts +23 -1
- package/dist/registryTools.d.ts.map +1 -1
- package/dist/registryTools.js +185 -31
- package/dist/registryTools.js.map +1 -1
- package/dist/skills.d.ts +105 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.generated.d.ts +44 -0
- package/dist/skills.generated.d.ts.map +1 -0
- package/dist/skills.generated.js +511 -0
- package/dist/skills.generated.js.map +1 -0
- package/dist/skills.js +144 -0
- package/dist/skills.js.map +1 -0
- package/dist/tools.d.ts +55 -8
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +41 -1
- package/dist/tools.js.map +1 -1
- package/dist/writeTools.d.ts +68 -0
- package/dist/writeTools.d.ts.map +1 -0
- package/dist/writeTools.js +256 -0
- package/dist/writeTools.js.map +1 -0
- package/llms.txt +148 -20
- package/package.json +7 -5
- package/skills/attention-hotspots/SKILL.md +88 -0
- package/skills/conversion-investigation/SKILL.md +97 -0
- package/skills/performance-regression-triage/SKILL.md +106 -0
- package/skills/weekly-scene-health/SKILL.md +105 -0
- package/skills/xr-comfort-audit/SKILL.md +95 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rendering the collector's **project context document** for a system prompt
|
|
3
|
+
* (ADR 0051 §5, design sketch §E.1).
|
|
4
|
+
*
|
|
5
|
+
* `GET /api/v1/context` answers, in one read, everything an agent would
|
|
6
|
+
* otherwise guess about the project in front of it: the scene ids and their
|
|
7
|
+
* named regions, the custom events the application emits and the props they
|
|
8
|
+
* carry, which capture channels are off (and so which metrics will be
|
|
9
|
+
* legitimately empty), whether raw session retention is enabled, and how fresh
|
|
10
|
+
* the data is.
|
|
11
|
+
*
|
|
12
|
+
* The document is JSON and bounded, but it is still several kilobytes — too much
|
|
13
|
+
* to paste into the system prompt of a 1–3 B local model, which has to carry ~69
|
|
14
|
+
* tool schemas in the same budget. {@link renderContextForPrompt} turns it into a
|
|
15
|
+
* compact, ordered block of prose-and-lists: a few hundred tokens that put the
|
|
16
|
+
* *names* an agent needs in front of it, and say plainly which questions the data
|
|
17
|
+
* cannot answer. Anything a model would only need after it has already decided
|
|
18
|
+
* what to ask (per-channel volumes, the full metric list, the window bounds) is
|
|
19
|
+
* left out — it can read the resource itself.
|
|
20
|
+
*
|
|
21
|
+
* Pure and dependency-free: a plain function from a structural view of the
|
|
22
|
+
* document to a string. It is deliberately **tolerant** of a partial or
|
|
23
|
+
* unfamiliar document — an older collector, a newer field, a proxy that trimmed
|
|
24
|
+
* something — because degrading to a shorter block is always better than an
|
|
25
|
+
* assistant that will not start.
|
|
26
|
+
*/
|
|
27
|
+
/** Hard cap on the rendered block, in characters (~1.5 k tokens). */
|
|
28
|
+
export declare const CONTEXT_PROMPT_MAX_CHARS = 6000;
|
|
29
|
+
/** Structural view of the parts of the context document the rendering uses. */
|
|
30
|
+
export interface PromptContextDocument {
|
|
31
|
+
project?: {
|
|
32
|
+
id?: string;
|
|
33
|
+
store?: string;
|
|
34
|
+
collectorVersion?: string;
|
|
35
|
+
} | null;
|
|
36
|
+
dataQuality?: {
|
|
37
|
+
lastEventAt?: number | null;
|
|
38
|
+
sessions24h?: number;
|
|
39
|
+
events24h?: number;
|
|
40
|
+
retention?: {
|
|
41
|
+
rawSessions?: boolean;
|
|
42
|
+
} | null;
|
|
43
|
+
} | null;
|
|
44
|
+
scenes?: readonly {
|
|
45
|
+
id?: string;
|
|
46
|
+
label?: string | null;
|
|
47
|
+
regions?: readonly {
|
|
48
|
+
id?: string;
|
|
49
|
+
label?: string;
|
|
50
|
+
}[];
|
|
51
|
+
proxy?: boolean;
|
|
52
|
+
}[];
|
|
53
|
+
vocabulary?: {
|
|
54
|
+
customEvents?: readonly {
|
|
55
|
+
name?: string;
|
|
56
|
+
count28d?: number;
|
|
57
|
+
props?: Record<string, string>;
|
|
58
|
+
}[];
|
|
59
|
+
meshes?: {
|
|
60
|
+
count?: number;
|
|
61
|
+
top?: readonly string[];
|
|
62
|
+
} | null;
|
|
63
|
+
inputActions?: readonly string[];
|
|
64
|
+
} | null;
|
|
65
|
+
definitions?: {
|
|
66
|
+
glossary?: readonly {
|
|
67
|
+
term?: string;
|
|
68
|
+
meaning?: string;
|
|
69
|
+
}[];
|
|
70
|
+
} | null;
|
|
71
|
+
annotations?: {
|
|
72
|
+
recent?: readonly {
|
|
73
|
+
text?: string;
|
|
74
|
+
at?: number;
|
|
75
|
+
}[];
|
|
76
|
+
} | null;
|
|
77
|
+
metrics?: {
|
|
78
|
+
disabledByCapture?: readonly string[];
|
|
79
|
+
} | null;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Render a project context document as a compact system-prompt block.
|
|
83
|
+
*
|
|
84
|
+
* Returns `""` when there is nothing useful to say, so a caller can append the
|
|
85
|
+
* result unconditionally. The output is truncated to
|
|
86
|
+
* {@link CONTEXT_PROMPT_MAX_CHARS} on a line boundary, with a marker, so a
|
|
87
|
+
* pathological project can never crowd out the tool schemas.
|
|
88
|
+
*
|
|
89
|
+
* @param context The document from `GET /api/v1/context` (any subset of it).
|
|
90
|
+
* @param nowMs Current time, for the "last event" phrasing. Defaults to `Date.now()`.
|
|
91
|
+
*/
|
|
92
|
+
export declare function renderContextForPrompt(context: PromptContextDocument | null | undefined, nowMs?: number): string;
|
|
93
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,qEAAqE;AACrE,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAE7C,+EAA+E;AAC/E,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC5E,WAAW,CAAC,EAAE;QACZ,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE;YAAE,WAAW,CAAC,EAAE,OAAO,CAAA;SAAE,GAAG,IAAI,CAAC;KAC9C,GAAG,IAAI,CAAC;IACT,MAAM,CAAC,EAAE,SAAS;QAChB,EAAE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B,MAAM,CAsFR"}
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rendering the collector's **project context document** for a system prompt
|
|
3
|
+
* (ADR 0051 §5, design sketch §E.1).
|
|
4
|
+
*
|
|
5
|
+
* `GET /api/v1/context` answers, in one read, everything an agent would
|
|
6
|
+
* otherwise guess about the project in front of it: the scene ids and their
|
|
7
|
+
* named regions, the custom events the application emits and the props they
|
|
8
|
+
* carry, which capture channels are off (and so which metrics will be
|
|
9
|
+
* legitimately empty), whether raw session retention is enabled, and how fresh
|
|
10
|
+
* the data is.
|
|
11
|
+
*
|
|
12
|
+
* The document is JSON and bounded, but it is still several kilobytes — too much
|
|
13
|
+
* to paste into the system prompt of a 1–3 B local model, which has to carry ~69
|
|
14
|
+
* tool schemas in the same budget. {@link renderContextForPrompt} turns it into a
|
|
15
|
+
* compact, ordered block of prose-and-lists: a few hundred tokens that put the
|
|
16
|
+
* *names* an agent needs in front of it, and say plainly which questions the data
|
|
17
|
+
* cannot answer. Anything a model would only need after it has already decided
|
|
18
|
+
* what to ask (per-channel volumes, the full metric list, the window bounds) is
|
|
19
|
+
* left out — it can read the resource itself.
|
|
20
|
+
*
|
|
21
|
+
* Pure and dependency-free: a plain function from a structural view of the
|
|
22
|
+
* document to a string. It is deliberately **tolerant** of a partial or
|
|
23
|
+
* unfamiliar document — an older collector, a newer field, a proxy that trimmed
|
|
24
|
+
* something — because degrading to a shorter block is always better than an
|
|
25
|
+
* assistant that will not start.
|
|
26
|
+
*/
|
|
27
|
+
/** Hard cap on the rendered block, in characters (~1.5 k tokens). */
|
|
28
|
+
export const CONTEXT_PROMPT_MAX_CHARS = 6000;
|
|
29
|
+
/** Join a list for prose, capping it and saying how many were left out. */
|
|
30
|
+
function capped(values, max) {
|
|
31
|
+
if (values.length <= max)
|
|
32
|
+
return values.join(", ");
|
|
33
|
+
return `${values.slice(0, max).join(", ")} (+${values.length - max} more)`;
|
|
34
|
+
}
|
|
35
|
+
/** `name(sku: string, qty: number)` — a custom event and what it carries. */
|
|
36
|
+
function renderCustomEvent(event) {
|
|
37
|
+
const props = Object.entries(event.props ?? {})
|
|
38
|
+
.slice(0, 8)
|
|
39
|
+
.map(([key, type]) => `${key}: ${type}`)
|
|
40
|
+
.join(", ");
|
|
41
|
+
const count = typeof event.count28d === "number" ? ` ×${event.count28d}` : "";
|
|
42
|
+
return `${event.name ?? "?"}${count}${props ? ` {${props}}` : ""}`;
|
|
43
|
+
}
|
|
44
|
+
/** `lobby "Main Lobby" [regions: counter, door]` — one scene line. */
|
|
45
|
+
function renderScene(scene) {
|
|
46
|
+
const label = scene.label ? ` "${scene.label}"` : "";
|
|
47
|
+
const regions = (scene.regions ?? []).map((region) => region.id).filter(Boolean);
|
|
48
|
+
const regionPart = regions.length > 0 ? ` [regions: ${capped(regions, 8)}]` : "";
|
|
49
|
+
return `- ${scene.id ?? "?"}${label}${regionPart}`;
|
|
50
|
+
}
|
|
51
|
+
/** How long ago, in whole units, for the freshness line. */
|
|
52
|
+
function ago(lastEventAt, nowMs) {
|
|
53
|
+
const minutes = Math.max(0, Math.round((nowMs - lastEventAt) / 60_000));
|
|
54
|
+
if (minutes < 60)
|
|
55
|
+
return `${minutes} min ago`;
|
|
56
|
+
const hours = Math.round(minutes / 60);
|
|
57
|
+
if (hours < 48)
|
|
58
|
+
return `${hours} h ago`;
|
|
59
|
+
return `${Math.round(hours / 24)} days ago`;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Render a project context document as a compact system-prompt block.
|
|
63
|
+
*
|
|
64
|
+
* Returns `""` when there is nothing useful to say, so a caller can append the
|
|
65
|
+
* result unconditionally. The output is truncated to
|
|
66
|
+
* {@link CONTEXT_PROMPT_MAX_CHARS} on a line boundary, with a marker, so a
|
|
67
|
+
* pathological project can never crowd out the tool schemas.
|
|
68
|
+
*
|
|
69
|
+
* @param context The document from `GET /api/v1/context` (any subset of it).
|
|
70
|
+
* @param nowMs Current time, for the "last event" phrasing. Defaults to `Date.now()`.
|
|
71
|
+
*/
|
|
72
|
+
export function renderContextForPrompt(context, nowMs = Date.now()) {
|
|
73
|
+
if (context == null || typeof context !== "object")
|
|
74
|
+
return "";
|
|
75
|
+
const lines = [];
|
|
76
|
+
const scenes = (context.scenes ?? []).filter((scene) => typeof scene.id === "string");
|
|
77
|
+
if (scenes.length > 0) {
|
|
78
|
+
lines.push("Scenes (use these exact ids for the `scene` filter; region ids for `region`):");
|
|
79
|
+
for (const scene of scenes.slice(0, 20))
|
|
80
|
+
lines.push(renderScene(scene));
|
|
81
|
+
if (scenes.length > 20)
|
|
82
|
+
lines.push(`- (+${scenes.length - 20} more scenes)`);
|
|
83
|
+
}
|
|
84
|
+
const customEvents = (context.vocabulary?.customEvents ?? []).filter((event) => typeof event.name === "string");
|
|
85
|
+
if (customEvents.length > 0) {
|
|
86
|
+
lines.push("", "Custom events this app emits (name ×count {props}) — use these exact names:", ...customEvents.slice(0, 15).map((event) => `- ${renderCustomEvent(event)}`));
|
|
87
|
+
if (customEvents.length > 15)
|
|
88
|
+
lines.push(`- (+${customEvents.length - 15} more)`);
|
|
89
|
+
}
|
|
90
|
+
const meshes = context.vocabulary?.meshes?.top ?? [];
|
|
91
|
+
if (meshes.length > 0)
|
|
92
|
+
lines.push("", `Most-interacted meshes: ${capped([...meshes], 10)}.`);
|
|
93
|
+
const actions = context.vocabulary?.inputActions ?? [];
|
|
94
|
+
if (actions.length > 0)
|
|
95
|
+
lines.push(`Bound input actions: ${capped([...actions], 12)}.`);
|
|
96
|
+
const glossary = (context.definitions?.glossary ?? []).filter((entry) => entry.term);
|
|
97
|
+
if (glossary.length > 0) {
|
|
98
|
+
lines.push("", "Project glossary:", ...glossary.slice(0, 12).map((entry) => `- ${entry.term}: ${entry.meaning ?? ""}`));
|
|
99
|
+
}
|
|
100
|
+
const annotations = (context.annotations?.recent ?? []).filter((entry) => entry.text);
|
|
101
|
+
if (annotations.length > 0) {
|
|
102
|
+
lines.push("", "Recent annotations (project notes, newest first):", ...annotations.slice(0, 5).map((entry) => `- ${entry.text ?? ""}`));
|
|
103
|
+
}
|
|
104
|
+
const disabled = context.metrics?.disabledByCapture ?? [];
|
|
105
|
+
if (disabled.length > 0) {
|
|
106
|
+
lines.push("", `No data is captured for these metrics, so they WILL return empty — say the channel is off ` +
|
|
107
|
+
`rather than reporting a zero: ${capped([...disabled], 20)}.`);
|
|
108
|
+
}
|
|
109
|
+
const quality = context.dataQuality;
|
|
110
|
+
if (quality != null) {
|
|
111
|
+
const parts = [];
|
|
112
|
+
if (typeof quality.lastEventAt === "number") {
|
|
113
|
+
parts.push(`last event ${ago(quality.lastEventAt, nowMs)}`);
|
|
114
|
+
}
|
|
115
|
+
else if (quality.lastEventAt === null) {
|
|
116
|
+
parts.push("no events recorded yet");
|
|
117
|
+
}
|
|
118
|
+
if (typeof quality.sessions24h === "number") {
|
|
119
|
+
parts.push(`${quality.sessions24h} sessions in the last 24 h`);
|
|
120
|
+
}
|
|
121
|
+
if (parts.length > 0)
|
|
122
|
+
lines.push("", `Data: ${parts.join(", ")}.`);
|
|
123
|
+
if (quality.retention?.rawSessions === false) {
|
|
124
|
+
lines.push("Raw per-session retention is OFF: session timelines and replay are unavailable by design.");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (lines.length === 0)
|
|
128
|
+
return "";
|
|
129
|
+
const header = "Project context (read from this collector; prefer these real names over any you infer):";
|
|
130
|
+
const body = [header, "", ...lines].join("\n").trimEnd();
|
|
131
|
+
if (body.length <= CONTEXT_PROMPT_MAX_CHARS)
|
|
132
|
+
return body;
|
|
133
|
+
const truncated = body.slice(0, CONTEXT_PROMPT_MAX_CHARS);
|
|
134
|
+
const lastBreak = truncated.lastIndexOf("\n");
|
|
135
|
+
return `${truncated.slice(0, lastBreak > 0 ? lastBreak : CONTEXT_PROMPT_MAX_CHARS)}\n… (context truncated)`;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,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AAM,MAAM,GACV,yFAAyF,CAAC;IAC5F,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;IACzD,IAAI,IAAI,CAAC,MAAM,IAAI,wBAAwB;QAAE,OAAO,IAAI,CAAC;IAEzD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,wBAAwB,CAAC,CAAC;IAC1D,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC9C,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,wBAAwB,CAAC,yBAAyB,CAAC;AAC9G,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
export { createCollectorClient, CollectorError, type CollectorClient, type CollectorClientConfig, type QueryParams, } from "./client.js";
|
|
2
|
-
export { readTools, coreReadTools, selectReadTools, filterReadTools, CORE_READ_TOOL_NAMES, type ReadTool, type ReadToolRequest, type ReadToolSetKind, } from "./tools.js";
|
|
3
|
-
export { registryToTools, metricToTool, describeMetric } from "./registryTools.js";
|
|
4
|
-
export
|
|
2
|
+
export { readTools, rawTools, coreReadTools, selectReadTools, filterReadTools, CORE_READ_TOOL_NAMES, type ReadTool, type ReadToolRequest, type ReadToolSetKind, } from "./tools.js";
|
|
3
|
+
export { registryToTools, metricToTool, describeMetric, DEFAULT_TOOL_FORMAT, } from "./registryTools.js";
|
|
4
|
+
export { QUERY_TOOL_NAME, queryTool } from "./queryTool.js";
|
|
5
|
+
export { writeTools, mutatingWriteTools, annotateTool, defineTermTool, saveAnalysisTool, pinPanelTool, unpinPanelTool, listAnnotationsTool, listGlossaryTool, listAnalysesTool, listPanelsTool, WriteNotSupportedError, type WriteTool, } from "./writeTools.js";
|
|
6
|
+
export { renderContextForPrompt, CONTEXT_PROMPT_MAX_CHARS } from "./context.js";
|
|
7
|
+
export type { PromptContextDocument } from "./context.js";
|
|
8
|
+
export { NON_REGISTRY_READ_TOOLS } from "./nonRegistryTools.js";
|
|
9
|
+
export type { AgentMessage, AgentToolCall, AgentToolSchema, LlmProvider, ProviderRequest, ProviderResponse, ProviderUsage, } from "./provider.js";
|
|
10
|
+
export { ANALYTICS_AGENT_GUIDELINES, renderCurrentTimeLine } from "./prompt.js";
|
|
11
|
+
export { AGENT_SKILLS, AGENT_SKILL_NAMES, getAgentSkill, renderAgentSkill, type AgentSkill, type AgentSkillArg, } from "./skills.js";
|
|
5
12
|
export { runAgent, toToolSchemas, truncateToolResult, DEFAULT_MAX_STEPS, DEFAULT_MAX_TOOL_RESULT_CHARS, type AgentStreamEvent, type RunAgentOptions, type RunAgentResult, } from "./loop.js";
|
|
6
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,SAAS,EACT,aAAa,EACb,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,SAAS,EACT,QAAQ,EACR,aAAa,EACb,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,eAAe,EACf,YAAY,EACZ,cAAc,EACd,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG5D,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,KAAK,SAAS,GACf,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAChF,YAAY,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAG1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,YAAY,EACV,YAAY,EACZ,aAAa,EACb,eAAe,EACf,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,aAAa,GACd,MAAM,eAAe,CAAC;AAIvB,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAIhF,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,KAAK,UAAU,EACf,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,6BAA6B,EAC7B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
export { createCollectorClient, CollectorError, } from "./client.js";
|
|
2
|
-
export { readTools, coreReadTools, selectReadTools, filterReadTools, CORE_READ_TOOL_NAMES, } from "./tools.js";
|
|
3
|
-
export { registryToTools, metricToTool, describeMetric } from "./registryTools.js";
|
|
2
|
+
export { readTools, rawTools, coreReadTools, selectReadTools, filterReadTools, CORE_READ_TOOL_NAMES, } from "./tools.js";
|
|
3
|
+
export { registryToTools, metricToTool, describeMetric, DEFAULT_TOOL_FORMAT, } from "./registryTools.js";
|
|
4
|
+
export { QUERY_TOOL_NAME, queryTool } from "./queryTool.js";
|
|
5
|
+
// Metadata write tools (#310, #315) — a separate export from `readTools` on
|
|
6
|
+
// purpose, so ADR 0017's read-only stance stays inspectable at a glance.
|
|
7
|
+
export { writeTools, mutatingWriteTools, annotateTool, defineTermTool, saveAnalysisTool, pinPanelTool, unpinPanelTool, listAnnotationsTool, listGlossaryTool, listAnalysesTool, listPanelsTool, WriteNotSupportedError, } from "./writeTools.js";
|
|
8
|
+
// --- Project context (ADR 0051 §5, design sketch §E.1) ---
|
|
9
|
+
// The compact system-prompt rendering of the collector context document.
|
|
10
|
+
export { renderContextForPrompt, CONTEXT_PROMPT_MAX_CHARS } from "./context.js";
|
|
11
|
+
// Collector reads that are configuration rather than measurements, and so have
|
|
12
|
+
// no registry entry to generate a tool from (#311, ADR 0051 §6).
|
|
13
|
+
export { NON_REGISTRY_READ_TOOLS } from "./nonRegistryTools.js";
|
|
14
|
+
// --- Shared system-prompt fragments (ADR 0050 §4, ADR 0051 §6) ---
|
|
15
|
+
// What every analytics agent says about the data, shared by the browser
|
|
16
|
+
// assistant and the headless report CLI.
|
|
17
|
+
export { ANALYTICS_AGENT_GUIDELINES, renderCurrentTimeLine } from "./prompt.js";
|
|
18
|
+
// --- Agent skills (ADR 0050 §7, ADR 0051 §6) ---
|
|
19
|
+
// The curated investigation methodologies shared by the MCP prompt templates and
|
|
20
|
+
// the headless `uptimizr agent report` CLI.
|
|
21
|
+
export { AGENT_SKILLS, AGENT_SKILL_NAMES, getAgentSkill, renderAgentSkill, } from "./skills.js";
|
|
4
22
|
export { runAgent, toToolSchemas, truncateToolResult, DEFAULT_MAX_STEPS, DEFAULT_MAX_TOOL_RESULT_CHARS, } from "./loop.js";
|
|
5
23
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,cAAc,GAIf,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,SAAS,EACT,aAAa,EACb,eAAe,EACf,eAAe,EACf,oBAAoB,GAIrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,cAAc,GAIf,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,SAAS,EACT,QAAQ,EACR,aAAa,EACb,eAAe,EACf,eAAe,EACf,oBAAoB,GAIrB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,eAAe,EACf,YAAY,EACZ,cAAc,EACd,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC5D,4EAA4E;AAC5E,yEAAyE;AACzE,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,sBAAsB,GAEvB,MAAM,iBAAiB,CAAC;AACzB,4DAA4D;AAC5D,yEAAyE;AACzE,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAEhF,+EAA+E;AAC/E,iEAAiE;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAUhE,oEAAoE;AACpE,wEAAwE;AACxE,yCAAyC;AACzC,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAChF,kDAAkD;AAClD,iFAAiF;AACjF,4CAA4C;AAC5C,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,gBAAgB,GAGjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,6BAA6B,GAI9B,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ReadTool } from "./tools.js";
|
|
2
|
+
/**
|
|
3
|
+
* **Read tools that are not registry metrics** (ADR 0051 §1).
|
|
4
|
+
*
|
|
5
|
+
* The catalog in `tools.ts` is generated from `@uptimizr/metrics`, and that is
|
|
6
|
+
* the rule: a new aggregation reaches agents by getting a registry entry, never
|
|
7
|
+
* by being added to a hand-written list. This module is the narrow, deliberate
|
|
8
|
+
* exception — collector surfaces that an agent needs but that are **not
|
|
9
|
+
* metrics** and so have no registry entry to generate from.
|
|
10
|
+
*
|
|
11
|
+
* There is exactly one today: `list_subscriptions` (#311, ADR 0051 §6). A
|
|
12
|
+
* subscription is project *configuration*, not a measurement; it has no rows, no
|
|
13
|
+
* unit, no comparable column, and no window. Inventing a registry entry for it
|
|
14
|
+
* would put a non-metric into the catalog that every other consumer (OpenAPI,
|
|
15
|
+
* the docs tables, the insight primitives' "comparable metrics" lists) treats as
|
|
16
|
+
* a measurement.
|
|
17
|
+
*
|
|
18
|
+
* Anything that *is* a measurement belongs in the registry instead. If this file
|
|
19
|
+
* grows past a handful of entries, that is the signal that the boundary has
|
|
20
|
+
* moved and the registry should absorb them.
|
|
21
|
+
*
|
|
22
|
+
* ## Writing subscriptions
|
|
23
|
+
*
|
|
24
|
+
* `create_subscription` / `delete_subscription` are deliberately absent. They
|
|
25
|
+
* are mutations, and the MCP server has no write path at all on this branch (see
|
|
26
|
+
* `@uptimizr/mcp`'s `server.ts`: `CollectorClient` exposes only `get`). They land
|
|
27
|
+
* with the `annotate`-gated write-tool surface introduced by the metadata write
|
|
28
|
+
* path (#310); until then an agent creates a subscription over plain HTTP with
|
|
29
|
+
* an `annotate` key, or an operator does it with
|
|
30
|
+
* `uptimizr subscriptions add --file`.
|
|
31
|
+
*/
|
|
32
|
+
/** One `ReadTool` per non-metric collector read an agent should have. */
|
|
33
|
+
export declare const NON_REGISTRY_READ_TOOLS: readonly ReadTool[];
|
|
34
|
+
//# sourceMappingURL=nonRegistryTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nonRegistryTools.d.ts","sourceRoot":"","sources":["../src/nonRegistryTools.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,yEAAyE;AACzE,eAAO,MAAM,uBAAuB,EAAE,SAAS,QAAQ,EAuCtD,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* **Read tools that are not registry metrics** (ADR 0051 §1).
|
|
4
|
+
*
|
|
5
|
+
* The catalog in `tools.ts` is generated from `@uptimizr/metrics`, and that is
|
|
6
|
+
* the rule: a new aggregation reaches agents by getting a registry entry, never
|
|
7
|
+
* by being added to a hand-written list. This module is the narrow, deliberate
|
|
8
|
+
* exception — collector surfaces that an agent needs but that are **not
|
|
9
|
+
* metrics** and so have no registry entry to generate from.
|
|
10
|
+
*
|
|
11
|
+
* There is exactly one today: `list_subscriptions` (#311, ADR 0051 §6). A
|
|
12
|
+
* subscription is project *configuration*, not a measurement; it has no rows, no
|
|
13
|
+
* unit, no comparable column, and no window. Inventing a registry entry for it
|
|
14
|
+
* would put a non-metric into the catalog that every other consumer (OpenAPI,
|
|
15
|
+
* the docs tables, the insight primitives' "comparable metrics" lists) treats as
|
|
16
|
+
* a measurement.
|
|
17
|
+
*
|
|
18
|
+
* Anything that *is* a measurement belongs in the registry instead. If this file
|
|
19
|
+
* grows past a handful of entries, that is the signal that the boundary has
|
|
20
|
+
* moved and the registry should absorb them.
|
|
21
|
+
*
|
|
22
|
+
* ## Writing subscriptions
|
|
23
|
+
*
|
|
24
|
+
* `create_subscription` / `delete_subscription` are deliberately absent. They
|
|
25
|
+
* are mutations, and the MCP server has no write path at all on this branch (see
|
|
26
|
+
* `@uptimizr/mcp`'s `server.ts`: `CollectorClient` exposes only `get`). They land
|
|
27
|
+
* with the `annotate`-gated write-tool surface introduced by the metadata write
|
|
28
|
+
* path (#310); until then an agent creates a subscription over plain HTTP with
|
|
29
|
+
* an `annotate` key, or an operator does it with
|
|
30
|
+
* `uptimizr subscriptions add --file`.
|
|
31
|
+
*/
|
|
32
|
+
/** One `ReadTool` per non-metric collector read an agent should have. */
|
|
33
|
+
export const NON_REGISTRY_READ_TOOLS = [
|
|
34
|
+
{
|
|
35
|
+
name: "list_subscriptions",
|
|
36
|
+
title: "List conditional subscriptions",
|
|
37
|
+
description: "The project's standing conditional subscriptions (ADR 0051 §6): what the collector is " +
|
|
38
|
+
"watching for, how often it checks, where a firing is delivered, and how each one last " +
|
|
39
|
+
"went (`lastFiredAt`, `failures`, `lastError`). Configuration, not a measurement — it " +
|
|
40
|
+
"takes no time range. Any webhook secret is masked and never returned. Needs only the " +
|
|
41
|
+
"`query` capability; creating or deleting one needs `annotate` and is not available as a " +
|
|
42
|
+
"tool.\n\nCaveats: this is what the project is configured to watch for, not a measurement " +
|
|
43
|
+
"of anything. A subscription that has never fired may mean the condition never occurred, " +
|
|
44
|
+
"or that it is disabled, or that its `minSample` gate was never cleared — check `enabled` " +
|
|
45
|
+
"and the subscription's own firing log (`GET /api/v1/subscriptions/:id/events`) before " +
|
|
46
|
+
"concluding anything about the underlying metric.",
|
|
47
|
+
inputSchema: {},
|
|
48
|
+
outputSchema: z.object({
|
|
49
|
+
rows: z
|
|
50
|
+
.array(z.object({
|
|
51
|
+
id: z.string(),
|
|
52
|
+
name: z.string(),
|
|
53
|
+
metric: z.string().describe("Registry metric id the subscription watches."),
|
|
54
|
+
predicate: z
|
|
55
|
+
.record(z.string(), z.unknown())
|
|
56
|
+
.describe("Closed union discriminated on `kind`."),
|
|
57
|
+
enabled: z.boolean(),
|
|
58
|
+
lastFiredAt: z
|
|
59
|
+
.string()
|
|
60
|
+
.nullable()
|
|
61
|
+
.describe("ISO timestamp of the last firing, or null if it never fired."),
|
|
62
|
+
failures: z.number().describe("Consecutive delivery failures since the last success."),
|
|
63
|
+
lastError: z.string().nullable(),
|
|
64
|
+
}))
|
|
65
|
+
.describe("One row per subscription, oldest first."),
|
|
66
|
+
}),
|
|
67
|
+
buildRequest: () => ({ path: "api/v1/subscriptions", params: {} }),
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
//# sourceMappingURL=nonRegistryTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nonRegistryTools.js","sourceRoot":"","sources":["../src/nonRegistryTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,yEAAyE;AACzE,MAAM,CAAC,MAAM,uBAAuB,GAAwB;IAC1D;QACE,IAAI,EAAE,oBAAoB;QAC1B,KAAK,EAAE,gCAAgC;QACvC,WAAW,EACT,wFAAwF;YACxF,wFAAwF;YACxF,uFAAuF;YACvF,uFAAuF;YACvF,0FAA0F;YAC1F,2FAA2F;YAC3F,0FAA0F;YAC1F,2FAA2F;YAC3F,wFAAwF;YACxF,kDAAkD;QACpD,WAAW,EAAE,EAAE;QACf,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC;YACrB,IAAI,EAAE,CAAC;iBACJ,KAAK,CACJ,CAAC,CAAC,MAAM,CAAC;gBACP,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;gBACd,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;gBAChB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8CAA8C,CAAC;gBAC3E,SAAS,EAAE,CAAC;qBACT,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;qBAC/B,QAAQ,CAAC,uCAAuC,CAAC;gBACpD,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;gBACpB,WAAW,EAAE,CAAC;qBACX,MAAM,EAAE;qBACR,QAAQ,EAAE;qBACV,QAAQ,CAAC,8DAA8D,CAAC;gBAC3E,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uDAAuD,CAAC;gBACtF,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;aACjC,CAAC,CACH;iBACA,QAAQ,CAAC,yCAAyC,CAAC;SACvD,CAAC;QACF,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;KACnE;CACF,CAAC"}
|
package/dist/prompt.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The system-prompt fragments every Uptimizr analytics agent shares.
|
|
3
|
+
*
|
|
4
|
+
* Two clients now prime a model to read this collector's analytics: the
|
|
5
|
+
* in-browser assistant (`@uptimizr/react`) and the headless
|
|
6
|
+
* `uptimizr agent report` CLI (`@uptimizr/collector-server`, ADR 0051 §6). What
|
|
7
|
+
* they say about the *data* must not diverge — that the figures come from tools
|
|
8
|
+
* and are never invented, that everything is aggregate and privacy-preserving
|
|
9
|
+
* (ADR 0003 / 0017), that timestamps are epoch milliseconds, that a tool error
|
|
10
|
+
* is explained rather than papered over. Only the opening role sentence and the
|
|
11
|
+
* output format legitimately differ between them, so only those live in the
|
|
12
|
+
* clients.
|
|
13
|
+
*
|
|
14
|
+
* Pure strings and one pure function — no I/O, no regex over prompt text.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The shared behavioural guidelines, verbatim, as a `Guidelines:`-headed block.
|
|
18
|
+
* A client prepends its own one-paragraph role statement and may append its own
|
|
19
|
+
* output-format instructions.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ANALYTICS_AGENT_GUIDELINES: string;
|
|
22
|
+
/**
|
|
23
|
+
* The single line that gives the model a clock.
|
|
24
|
+
*
|
|
25
|
+
* The guidelines tell it to convert relative ranges, but a model has no inherent
|
|
26
|
+
* clock — without a "now" reference it drops the range or invents timestamps and
|
|
27
|
+
* answers over all time. Callers stamp it at send time so a long-lived session
|
|
28
|
+
* keeps resolving "today" against the real current day.
|
|
29
|
+
*
|
|
30
|
+
* @param nowMs The current time in epoch milliseconds (e.g. `Date.now()`).
|
|
31
|
+
*/
|
|
32
|
+
export declare function renderCurrentTimeLine(nowMs: number): string;
|
|
33
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,QAU3B,CAAC;AAEb;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ3D"}
|
package/dist/prompt.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The system-prompt fragments every Uptimizr analytics agent shares.
|
|
3
|
+
*
|
|
4
|
+
* Two clients now prime a model to read this collector's analytics: the
|
|
5
|
+
* in-browser assistant (`@uptimizr/react`) and the headless
|
|
6
|
+
* `uptimizr agent report` CLI (`@uptimizr/collector-server`, ADR 0051 §6). What
|
|
7
|
+
* they say about the *data* must not diverge — that the figures come from tools
|
|
8
|
+
* and are never invented, that everything is aggregate and privacy-preserving
|
|
9
|
+
* (ADR 0003 / 0017), that timestamps are epoch milliseconds, that a tool error
|
|
10
|
+
* is explained rather than papered over. Only the opening role sentence and the
|
|
11
|
+
* output format legitimately differ between them, so only those live in the
|
|
12
|
+
* clients.
|
|
13
|
+
*
|
|
14
|
+
* Pure strings and one pure function — no I/O, no regex over prompt text.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The shared behavioural guidelines, verbatim, as a `Guidelines:`-headed block.
|
|
18
|
+
* A client prepends its own one-paragraph role statement and may append its own
|
|
19
|
+
* output-format instructions.
|
|
20
|
+
*/
|
|
21
|
+
export const ANALYTICS_AGENT_GUIDELINES = [
|
|
22
|
+
"Guidelines:",
|
|
23
|
+
"- Use the provided tools to fetch data before answering; never invent numbers.",
|
|
24
|
+
"- All data is aggregate and privacy-preserving — there are no raw per-session events,",
|
|
25
|
+
" no PII, and no way to ingest or modify data. Do not claim otherwise.",
|
|
26
|
+
"- Timestamps are epoch milliseconds. When the user gives a relative range",
|
|
27
|
+
' ("this week", "last 24h"), convert it to `since`/`until` before calling a tool.',
|
|
28
|
+
"- Prefer a short, direct answer with the key figures. Call out caveats (small sample",
|
|
29
|
+
" sizes, missing scenes) when relevant.",
|
|
30
|
+
"- If a tool returns an error, explain what went wrong and, if useful, try a corrected call.",
|
|
31
|
+
].join("\n");
|
|
32
|
+
/**
|
|
33
|
+
* The single line that gives the model a clock.
|
|
34
|
+
*
|
|
35
|
+
* The guidelines tell it to convert relative ranges, but a model has no inherent
|
|
36
|
+
* clock — without a "now" reference it drops the range or invents timestamps and
|
|
37
|
+
* answers over all time. Callers stamp it at send time so a long-lived session
|
|
38
|
+
* keeps resolving "today" against the real current day.
|
|
39
|
+
*
|
|
40
|
+
* @param nowMs The current time in epoch milliseconds (e.g. `Date.now()`).
|
|
41
|
+
*/
|
|
42
|
+
export function renderCurrentTimeLine(nowMs) {
|
|
43
|
+
const iso = new Date(nowMs).toISOString();
|
|
44
|
+
return (`Current time: ${iso} (epoch milliseconds: ${nowMs}). ` +
|
|
45
|
+
"Resolve any relative time range in the question against this — " +
|
|
46
|
+
'"today" is the current calendar day, "this week" the last 7 days, ' +
|
|
47
|
+
'"last 24h" the preceding 24 hours — into concrete `since`/`until` epoch-ms arguments.');
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,aAAa;IACb,gFAAgF;IAChF,uFAAuF;IACvF,wEAAwE;IACxE,2EAA2E;IAC3E,mFAAmF;IACnF,sFAAsF;IACtF,yCAAyC;IACzC,6FAA6F;CAC9F,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAa;IACjD,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1C,OAAO,CACL,iBAAiB,GAAG,yBAAyB,KAAK,KAAK;QACvD,iEAAiE;QACjE,oEAAoE;QACpE,uFAAuF,CACxF,CAAC;AACJ,CAAC"}
|
package/dist/provider.d.ts
CHANGED
|
@@ -44,14 +44,32 @@ export interface AgentToolSchema {
|
|
|
44
44
|
description: string;
|
|
45
45
|
parameters: Record<string, unknown>;
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Token accounting for one provider turn, when the provider reports it.
|
|
49
|
+
*
|
|
50
|
+
* Every field is optional: a provider may report neither, one or both, and a
|
|
51
|
+
* local backend reports nothing at all. Consumers therefore treat a missing
|
|
52
|
+
* number as "not reported" and never as zero — the distinction matters in the
|
|
53
|
+
* cost line of a scheduled report.
|
|
54
|
+
*/
|
|
55
|
+
export interface ProviderUsage {
|
|
56
|
+
/** Prompt tokens billed for this turn. */
|
|
57
|
+
inputTokens?: number;
|
|
58
|
+
/** Generated tokens billed for this turn. */
|
|
59
|
+
outputTokens?: number;
|
|
60
|
+
}
|
|
47
61
|
/** The two possible outcomes of a provider turn. */
|
|
48
62
|
export type ProviderResponse = {
|
|
49
63
|
kind: "tool_calls";
|
|
50
64
|
toolCalls: AgentToolCall[];
|
|
51
65
|
content?: string;
|
|
66
|
+
/** Token accounting for this turn, when the provider reported any. */
|
|
67
|
+
usage?: ProviderUsage;
|
|
52
68
|
} | {
|
|
53
69
|
kind: "final";
|
|
54
70
|
content: string;
|
|
71
|
+
/** Token accounting for this turn, when the provider reported any. */
|
|
72
|
+
usage?: ProviderUsage;
|
|
55
73
|
};
|
|
56
74
|
/** A single provider completion request. */
|
|
57
75
|
export interface ProviderRequest {
|
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,kDAAkD;AAClD,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,aAAa,EAAE,CAAA;CAAE,GACnE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE,gDAAgD;AAChD,MAAM,WAAW,aAAa;IAC5B,6EAA6E;IAC7E,EAAE,EAAE,MAAM,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,CAAC;CACrC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6CAA6C;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,oDAAoD;AACpD,MAAM,MAAM,gBAAgB,GACxB;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC;AAEN,4CAA4C;AAC5C,MAAM,WAAW,eAAe;IAC9B,4EAA4E;IAC5E,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,wDAAwD;IACxD,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,2DAA2D;IAC3D,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC/D"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* `tool_use` content blocks, and tool results are `tool_result` blocks carried
|
|
7
7
|
* in a following user turn.
|
|
8
8
|
*/
|
|
9
|
-
import type { AgentMessage, AgentToolSchema, ProviderResponse } from "../provider.js";
|
|
9
|
+
import type { AgentMessage, AgentToolSchema, ProviderResponse, ProviderUsage } from "../provider.js";
|
|
10
10
|
/** An Anthropic content block (the subset used here). */
|
|
11
11
|
export type AnthropicContentBlock = {
|
|
12
12
|
type: "text";
|
|
@@ -39,10 +39,21 @@ export interface AnthropicRequestBody {
|
|
|
39
39
|
/** Omitted when no tools are advertised (e.g. a forced plain-text turn). */
|
|
40
40
|
tools?: AnthropicTool[];
|
|
41
41
|
}
|
|
42
|
+
/** Anthropic's token accounting, as the Messages API spells it. */
|
|
43
|
+
export interface AnthropicUsage {
|
|
44
|
+
input_tokens?: number;
|
|
45
|
+
output_tokens?: number;
|
|
46
|
+
}
|
|
42
47
|
/** The subset of an Anthropic Messages response this module reads. */
|
|
43
48
|
export interface AnthropicCompletion {
|
|
44
49
|
content?: AnthropicContentBlock[];
|
|
50
|
+
usage?: AnthropicUsage;
|
|
45
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Normalise Anthropic's `usage` into {@link ProviderUsage}, or `undefined` when
|
|
54
|
+
* the response carried none — so a caller can tell "not reported" from zero.
|
|
55
|
+
*/
|
|
56
|
+
export declare function toProviderUsage(usage: AnthropicUsage | undefined): ProviderUsage | undefined;
|
|
46
57
|
/**
|
|
47
58
|
* Build the Anthropic request pieces (system prompt, messages, tools) from the
|
|
48
59
|
* agent conversation and tool schemas.
|
|
@@ -74,6 +85,12 @@ export interface AnthropicStreamEvent {
|
|
|
74
85
|
text?: string;
|
|
75
86
|
partial_json?: string;
|
|
76
87
|
};
|
|
88
|
+
/** `message_start` reports the prompt tokens on the message it opens. */
|
|
89
|
+
message?: {
|
|
90
|
+
usage?: AnthropicUsage;
|
|
91
|
+
};
|
|
92
|
+
/** `message_delta` reports the generated tokens as they accrue. */
|
|
93
|
+
usage?: AnthropicUsage;
|
|
77
94
|
}
|
|
78
95
|
/**
|
|
79
96
|
* Accumulates {@link AnthropicStreamEvent}s into a complete
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/providers/anthropic.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,YAAY,EAEZ,eAAe,EACf,gBAAgB,
|
|
1
|
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