@getcliqio/cliq-sdk 0.0.0-stage → 1.15.32
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 +28 -2
- package/dist/agent_api.d.ts +39 -0
- package/dist/agent_api.d.ts.map +1 -0
- package/dist/agent_api.js +105 -0
- package/dist/agent_api.js.map +1 -0
- package/dist/agent_manifest.d.ts +162 -0
- package/dist/agent_manifest.d.ts.map +1 -0
- package/dist/agent_manifest.js +242 -0
- package/dist/agent_manifest.js.map +1 -0
- package/dist/agent_payloads.d.ts +103 -0
- package/dist/agent_payloads.d.ts.map +1 -0
- package/dist/agent_payloads.js +56 -0
- package/dist/agent_payloads.js.map +1 -0
- package/dist/agents/base_agent.d.ts +113 -0
- package/dist/agents/base_agent.d.ts.map +1 -0
- package/dist/agents/base_agent.js +413 -0
- package/dist/agents/base_agent.js.map +1 -0
- package/dist/agents/cli_agent.d.ts +98 -0
- package/dist/agents/cli_agent.d.ts.map +1 -0
- package/dist/agents/cli_agent.js +303 -0
- package/dist/agents/cli_agent.js.map +1 -0
- package/dist/agents/cli_rehydrate.d.ts +29 -0
- package/dist/agents/cli_rehydrate.d.ts.map +1 -0
- package/dist/agents/cli_rehydrate.js +32 -0
- package/dist/agents/cli_rehydrate.js.map +1 -0
- package/dist/agents/connector_agent.d.ts +20 -0
- package/dist/agents/connector_agent.d.ts.map +1 -0
- package/dist/agents/connector_agent.js +110 -0
- package/dist/agents/connector_agent.js.map +1 -0
- package/dist/agents/event_artifacts.d.ts +33 -0
- package/dist/agents/event_artifacts.d.ts.map +1 -0
- package/dist/agents/event_artifacts.js +73 -0
- package/dist/agents/event_artifacts.js.map +1 -0
- package/dist/agents/gate_agent.d.ts +40 -0
- package/dist/agents/gate_agent.d.ts.map +1 -0
- package/dist/agents/gate_agent.js +121 -0
- package/dist/agents/gate_agent.js.map +1 -0
- package/dist/agents/index.d.ts +32 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +26 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/llm_agent.d.ts +109 -0
- package/dist/agents/llm_agent.d.ts.map +1 -0
- package/dist/agents/llm_agent.js +285 -0
- package/dist/agents/llm_agent.js.map +1 -0
- package/dist/agents/llm_contract.d.ts +7 -0
- package/dist/agents/llm_contract.d.ts.map +1 -0
- package/dist/agents/llm_contract.js +7 -0
- package/dist/agents/llm_contract.js.map +1 -0
- package/dist/agents/standard_agent.d.ts +15 -0
- package/dist/agents/standard_agent.d.ts.map +1 -0
- package/dist/agents/standard_agent.js +34 -0
- package/dist/agents/standard_agent.js.map +1 -0
- package/dist/agents/turn_result.d.ts +67 -0
- package/dist/agents/turn_result.d.ts.map +1 -0
- package/dist/agents/turn_result.js +81 -0
- package/dist/agents/turn_result.js.map +1 -0
- package/dist/agents/types.d.ts +314 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +20 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/builtin_teams/hello_hug.d.ts +9 -0
- package/dist/builtin_teams/hello_hug.d.ts.map +1 -0
- package/dist/builtin_teams/hello_hug.js +68 -0
- package/dist/builtin_teams/hello_hug.js.map +1 -0
- package/dist/builtin_teams/hello_world.d.ts +8 -0
- package/dist/builtin_teams/hello_world.d.ts.map +1 -0
- package/dist/builtin_teams/hello_world.js +65 -0
- package/dist/builtin_teams/hello_world.js.map +1 -0
- package/dist/builtin_teams/hug_example.d.ts +10 -0
- package/dist/builtin_teams/hug_example.d.ts.map +1 -0
- package/dist/builtin_teams/hug_example.js +94 -0
- package/dist/builtin_teams/hug_example.js.map +1 -0
- package/dist/builtin_teams/index.d.ts +12 -0
- package/dist/builtin_teams/index.d.ts.map +1 -0
- package/dist/builtin_teams/index.js +18 -0
- package/dist/builtin_teams/index.js.map +1 -0
- package/dist/builtin_teams/types.d.ts +29 -0
- package/dist/builtin_teams/types.d.ts.map +1 -0
- package/dist/builtin_teams/types.js +3 -0
- package/dist/builtin_teams/types.js.map +1 -0
- package/dist/core_api_client.d.ts +48 -0
- package/dist/core_api_client.d.ts.map +1 -0
- package/dist/core_api_client.js +132 -0
- package/dist/core_api_client.js.map +1 -0
- package/dist/daemon_wire.d.ts +122 -0
- package/dist/daemon_wire.d.ts.map +1 -0
- package/dist/daemon_wire.js +105 -0
- package/dist/daemon_wire.js.map +1 -0
- package/dist/events/catalog.d.ts +40 -0
- package/dist/events/catalog.d.ts.map +1 -0
- package/dist/events/catalog.js +76 -0
- package/dist/events/catalog.js.map +1 -0
- package/dist/http_daemon_client.d.ts +136 -0
- package/dist/http_daemon_client.d.ts.map +1 -0
- package/dist/http_daemon_client.js +192 -0
- package/dist/http_daemon_client.js.map +1 -0
- package/dist/hug/ask.d.ts +160 -0
- package/dist/hug/ask.d.ts.map +1 -0
- package/dist/hug/ask.js +318 -0
- package/dist/hug/ask.js.map +1 -0
- package/dist/hug/attach.d.ts +60 -0
- package/dist/hug/attach.d.ts.map +1 -0
- package/dist/hug/attach.js +103 -0
- package/dist/hug/attach.js.map +1 -0
- package/dist/hug/bridge/index.d.ts +16 -0
- package/dist/hug/bridge/index.d.ts.map +1 -0
- package/dist/hug/bridge/index.js +13 -0
- package/dist/hug/bridge/index.js.map +1 -0
- package/dist/hug/bridge/messages.d.ts +559 -0
- package/dist/hug/bridge/messages.d.ts.map +1 -0
- package/dist/hug/bridge/messages.js +165 -0
- package/dist/hug/bridge/messages.js.map +1 -0
- package/dist/hug/client.d.ts +70 -0
- package/dist/hug/client.d.ts.map +1 -0
- package/dist/hug/client.js +144 -0
- package/dist/hug/client.js.map +1 -0
- package/dist/hug/context.d.ts +54 -0
- package/dist/hug/context.d.ts.map +1 -0
- package/dist/hug/context.js +27 -0
- package/dist/hug/context.js.map +1 -0
- package/dist/hug/define.d.ts +116 -0
- package/dist/hug/define.d.ts.map +1 -0
- package/dist/hug/define.js +119 -0
- package/dist/hug/define.js.map +1 -0
- package/dist/hug/definitions/approval.d.ts +216 -0
- package/dist/hug/definitions/approval.d.ts.map +1 -0
- package/dist/hug/definitions/approval.js +50 -0
- package/dist/hug/definitions/approval.js.map +1 -0
- package/dist/hug/definitions/common.d.ts +122 -0
- package/dist/hug/definitions/common.d.ts.map +1 -0
- package/dist/hug/definitions/common.js +70 -0
- package/dist/hug/definitions/common.js.map +1 -0
- package/dist/hug/definitions/form.d.ts +197 -0
- package/dist/hug/definitions/form.d.ts.map +1 -0
- package/dist/hug/definitions/form.js +29 -0
- package/dist/hug/definitions/form.js.map +1 -0
- package/dist/hug/definitions/index.d.ts +10 -0
- package/dist/hug/definitions/index.d.ts.map +1 -0
- package/dist/hug/definitions/index.js +8 -0
- package/dist/hug/definitions/index.js.map +1 -0
- package/dist/hug/errors.d.ts +30 -0
- package/dist/hug/errors.d.ts.map +1 -0
- package/dist/hug/errors.js +46 -0
- package/dist/hug/errors.js.map +1 -0
- package/dist/hug/file_checks.d.ts +41 -0
- package/dist/hug/file_checks.d.ts.map +1 -0
- package/dist/hug/file_checks.js +105 -0
- package/dist/hug/file_checks.js.map +1 -0
- package/dist/hug/files.d.ts +137 -0
- package/dist/hug/files.d.ts.map +1 -0
- package/dist/hug/files.js +283 -0
- package/dist/hug/files.js.map +1 -0
- package/dist/hug/hug_bundle.d.ts +70 -0
- package/dist/hug/hug_bundle.d.ts.map +1 -0
- package/dist/hug/hug_bundle.js +299 -0
- package/dist/hug/hug_bundle.js.map +1 -0
- package/dist/hug/hug_catalog.d.ts +38 -0
- package/dist/hug/hug_catalog.d.ts.map +1 -0
- package/dist/hug/hug_catalog.js +67 -0
- package/dist/hug/hug_catalog.js.map +1 -0
- package/dist/hug/hug_definitions.d.ts +32 -0
- package/dist/hug/hug_definitions.d.ts.map +1 -0
- package/dist/hug/hug_definitions.js +74 -0
- package/dist/hug/hug_definitions.js.map +1 -0
- package/dist/hug/index.d.ts +37 -0
- package/dist/hug/index.d.ts.map +1 -0
- package/dist/hug/index.js +23 -0
- package/dist/hug/index.js.map +1 -0
- package/dist/hug/llm.d.ts +106 -0
- package/dist/hug/llm.d.ts.map +1 -0
- package/dist/hug/llm.js +250 -0
- package/dist/hug/llm.js.map +1 -0
- package/dist/hug/policies.d.ts +65 -0
- package/dist/hug/policies.d.ts.map +1 -0
- package/dist/hug/policies.js +80 -0
- package/dist/hug/policies.js.map +1 -0
- package/dist/hug/problems.d.ts +35 -0
- package/dist/hug/problems.d.ts.map +1 -0
- package/dist/hug/problems.js +53 -0
- package/dist/hug/problems.js.map +1 -0
- package/dist/hug/requested_inputs.d.ts +190 -0
- package/dist/hug/requested_inputs.d.ts.map +1 -0
- package/dist/hug/requested_inputs.js +220 -0
- package/dist/hug/requested_inputs.js.map +1 -0
- package/dist/hug/schema_for_inputs.d.ts +20 -0
- package/dist/hug/schema_for_inputs.d.ts.map +1 -0
- package/dist/hug/schema_for_inputs.js +95 -0
- package/dist/hug/schema_for_inputs.js.map +1 -0
- package/dist/hug/session.d.ts +113 -0
- package/dist/hug/session.d.ts.map +1 -0
- package/dist/hug/session.js +210 -0
- package/dist/hug/session.js.map +1 -0
- package/dist/hug/types.d.ts +141 -0
- package/dist/hug/types.d.ts.map +1 -0
- package/dist/hug/types.js +80 -0
- package/dist/hug/types.js.map +1 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/logging.d.ts +172 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +306 -0
- package/dist/logging.js.map +1 -0
- package/dist/mcp.d.ts +119 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +259 -0
- package/dist/mcp.js.map +1 -0
- package/dist/mcp_client.d.ts +145 -0
- package/dist/mcp_client.d.ts.map +1 -0
- package/dist/mcp_client.js +374 -0
- package/dist/mcp_client.js.map +1 -0
- package/dist/paths.d.ts +20 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +20 -0
- package/dist/paths.js.map +1 -0
- package/dist/protocol/factory.d.ts +32 -0
- package/dist/protocol/factory.d.ts.map +1 -0
- package/dist/protocol/factory.js +31 -0
- package/dist/protocol/factory.js.map +1 -0
- package/dist/protocol/framing.d.ts +35 -0
- package/dist/protocol/framing.d.ts.map +1 -0
- package/dist/protocol/framing.js +73 -0
- package/dist/protocol/framing.js.map +1 -0
- package/dist/protocol/index.d.ts +13 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +13 -0
- package/dist/protocol/index.js.map +1 -0
- package/dist/protocol/types/agent.d.ts +42 -0
- package/dist/protocol/types/agent.d.ts.map +1 -0
- package/dist/protocol/types/agent.js +9 -0
- package/dist/protocol/types/agent.js.map +1 -0
- package/dist/protocol/types/cliq_core.d.ts +79 -0
- package/dist/protocol/types/cliq_core.d.ts.map +1 -0
- package/dist/protocol/types/cliq_core.js +17 -0
- package/dist/protocol/types/cliq_core.js.map +1 -0
- package/dist/protocol/types/foundations.d.ts +41 -0
- package/dist/protocol/types/foundations.d.ts.map +1 -0
- package/dist/protocol/types/foundations.js +10 -0
- package/dist/protocol/types/foundations.js.map +1 -0
- package/dist/protocol/types/index.d.ts +32 -0
- package/dist/protocol/types/index.d.ts.map +1 -0
- package/dist/protocol/types/index.js +27 -0
- package/dist/protocol/types/index.js.map +1 -0
- package/dist/protocol/types/messages.d.ts +827 -0
- package/dist/protocol/types/messages.d.ts.map +1 -0
- package/dist/protocol/types/messages.js +117 -0
- package/dist/protocol/types/messages.js.map +1 -0
- package/dist/protocol/types/pipeline.d.ts +122 -0
- package/dist/protocol/types/pipeline.d.ts.map +1 -0
- package/dist/protocol/types/pipeline.js +16 -0
- package/dist/protocol/types/pipeline.js.map +1 -0
- package/dist/protocol/types/schemas.d.ts +814 -0
- package/dist/protocol/types/schemas.d.ts.map +1 -0
- package/dist/protocol/types/schemas.js +772 -0
- package/dist/protocol/types/schemas.js.map +1 -0
- package/dist/protocol/types/team.d.ts +42 -0
- package/dist/protocol/types/team.d.ts.map +1 -0
- package/dist/protocol/types/team.js +15 -0
- package/dist/protocol/types/team.js.map +1 -0
- package/dist/protocol/types/workspace.d.ts +46 -0
- package/dist/protocol/types/workspace.d.ts.map +1 -0
- package/dist/protocol/types/workspace.js +9 -0
- package/dist/protocol/types/workspace.js.map +1 -0
- package/dist/settings_keys.d.ts +12 -0
- package/dist/settings_keys.d.ts.map +1 -0
- package/dist/settings_keys.js +35 -0
- package/dist/settings_keys.js.map +1 -0
- package/dist/tcp/client.d.ts +15 -0
- package/dist/tcp/client.d.ts.map +1 -0
- package/dist/tcp/client.js +28 -0
- package/dist/tcp/client.js.map +1 -0
- package/dist/tcp/connection.d.ts +79 -0
- package/dist/tcp/connection.d.ts.map +1 -0
- package/dist/tcp/connection.js +153 -0
- package/dist/tcp/connection.js.map +1 -0
- package/dist/tcp/index.d.ts +10 -0
- package/dist/tcp/index.d.ts.map +1 -0
- package/dist/tcp/index.js +7 -0
- package/dist/tcp/index.js.map +1 -0
- package/dist/tcp/server.d.ts +31 -0
- package/dist/tcp/server.d.ts.map +1 -0
- package/dist/tcp/server.js +54 -0
- package/dist/tcp/server.js.map +1 -0
- package/dist/team/bundle.d.ts +88 -0
- package/dist/team/bundle.d.ts.map +1 -0
- package/dist/team/bundle.js +214 -0
- package/dist/team/bundle.js.map +1 -0
- package/dist/team/identity.d.ts +31 -0
- package/dist/team/identity.d.ts.map +1 -0
- package/dist/team/identity.js +83 -0
- package/dist/team/identity.js.map +1 -0
- package/dist/team/index.d.ts +13 -0
- package/dist/team/index.d.ts.map +1 -0
- package/dist/team/index.js +8 -0
- package/dist/team/index.js.map +1 -0
- package/dist/team/lint_bundle.d.ts +16 -0
- package/dist/team/lint_bundle.d.ts.map +1 -0
- package/dist/team/lint_bundle.js +35 -0
- package/dist/team/lint_bundle.js.map +1 -0
- package/dist/team/ref.d.ts +48 -0
- package/dist/team/ref.d.ts.map +1 -0
- package/dist/team/ref.js +70 -0
- package/dist/team/ref.js.map +1 -0
- package/dist/team/roles.d.ts +22 -0
- package/dist/team/roles.d.ts.map +1 -0
- package/dist/team/roles.js +33 -0
- package/dist/team/roles.js.map +1 -0
- package/dist/team/tree.d.ts +101 -0
- package/dist/team/tree.d.ts.map +1 -0
- package/dist/team/tree.js +125 -0
- package/dist/team/tree.js.map +1 -0
- package/dist/team_lint.d.ts +57 -0
- package/dist/team_lint.d.ts.map +1 -0
- package/dist/team_lint.js +277 -0
- package/dist/team_lint.js.map +1 -0
- package/dist/telemetry/stream_json_usage.d.ts +39 -0
- package/dist/telemetry/stream_json_usage.d.ts.map +1 -0
- package/dist/telemetry/stream_json_usage.js +139 -0
- package/dist/telemetry/stream_json_usage.js.map +1 -0
- package/dist/telemetry/usage.d.ts +288 -0
- package/dist/telemetry/usage.d.ts.map +1 -0
- package/dist/telemetry/usage.js +421 -0
- package/dist/telemetry/usage.js.map +1 -0
- package/dist/utils/duration.d.ts +11 -0
- package/dist/utils/duration.d.ts.map +1 -0
- package/dist/utils/duration.js +22 -0
- package/dist/utils/duration.js.map +1 -0
- package/dist/utils/redact.d.ts +26 -0
- package/dist/utils/redact.d.ts.map +1 -0
- package/dist/utils/redact.js +52 -0
- package/dist/utils/redact.js.map +1 -0
- package/dist/utils/url.d.ts +6 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/utils/url.js +11 -0
- package/dist/utils/url.js.map +1 -0
- package/package.json +72 -5
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UsageRecord — the common structure every agent reports (or has
|
|
3
|
+
* synthesized on its behalf) so we can aggregate telemetry across
|
|
4
|
+
* LLM, connector, shell, gate, and builder agents in one query.
|
|
5
|
+
*
|
|
6
|
+
* The record is versioned (`version: 1`) and has a *closed* core of
|
|
7
|
+
* aggregable fields plus a namespaced `extras` bag for provider- /
|
|
8
|
+
* agent-specific facts. Dashboards SUM the closed core; they SEARCH
|
|
9
|
+
* the extras.
|
|
10
|
+
*
|
|
11
|
+
* The record is emitted by the SDK via `report_usage(...)` (which
|
|
12
|
+
* POSTs an `event_type: 'usage'` to the daemon's `/v1/runs/events`)
|
|
13
|
+
* and merged onto the still-open `agent.execute` OTEL span by the
|
|
14
|
+
* daemon. Every agent — whether it participates or not — gets a
|
|
15
|
+
* baseline record synthesized from what the daemon already sees
|
|
16
|
+
* (`synthesize_baseline_usage`), so the "every agent is measurable"
|
|
17
|
+
* property does not depend on agent-author cooperation.
|
|
18
|
+
*
|
|
19
|
+
* See `CONVENTIONS.md` in this folder for the per-agent-kind mapping
|
|
20
|
+
* of `unit_kind` / `units_in` / `units_out` and copy/paste snippets.
|
|
21
|
+
*/
|
|
22
|
+
import { z } from 'zod';
|
|
23
|
+
// ─── Enums ─────────────────────────────────────────────────────────
|
|
24
|
+
/** Broad categorisation of an agent invocation. */
|
|
25
|
+
export const AGENT_KINDS = [
|
|
26
|
+
'llm', // Cursor CLI, Claude Code, claude-api, openai-api, ...
|
|
27
|
+
'connector', // JIRA, GitHub, Slack, S3, HTTP — external systems
|
|
28
|
+
'shell', // Raw shell commands / scripts
|
|
29
|
+
'gate', // Gate agents that vote / route
|
|
30
|
+
'builder', // Team/agent builders, code generators, scaffolders
|
|
31
|
+
'custom', // Anything that doesn't fit above
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* The unit of work an agent counts. Each `agent_kind` maps its
|
|
35
|
+
* native concept onto this shared enum so aggregation queries can
|
|
36
|
+
* `GROUP BY unit_kind` without adding tokens to bytes.
|
|
37
|
+
*
|
|
38
|
+
* llm → tokens
|
|
39
|
+
* connector → calls
|
|
40
|
+
* shell → bytes
|
|
41
|
+
* builder → files
|
|
42
|
+
* gate → records (criteria evaluated)
|
|
43
|
+
* custom → none (or agent's choice)
|
|
44
|
+
*/
|
|
45
|
+
export const UNIT_KINDS = [
|
|
46
|
+
'tokens',
|
|
47
|
+
'calls',
|
|
48
|
+
'bytes',
|
|
49
|
+
'records',
|
|
50
|
+
'files',
|
|
51
|
+
'none',
|
|
52
|
+
];
|
|
53
|
+
/** How an agent invocation ended. */
|
|
54
|
+
export const OUTCOMES = ['success', 'failure', 'cancelled', 'timeout'];
|
|
55
|
+
// ─── Schema ────────────────────────────────────────────────────────
|
|
56
|
+
/**
|
|
57
|
+
* Bump when adding required fields or changing semantics. Optional
|
|
58
|
+
* additions can go into the current version and be safely ignored
|
|
59
|
+
* by older daemons.
|
|
60
|
+
*/
|
|
61
|
+
export const USAGE_RECORD_VERSION = 1;
|
|
62
|
+
const extras_primitive = z.union([
|
|
63
|
+
z.string(),
|
|
64
|
+
z.number().finite(),
|
|
65
|
+
z.boolean(),
|
|
66
|
+
]);
|
|
67
|
+
/**
|
|
68
|
+
* The full record. `report_usage` accepts a partial and fills the
|
|
69
|
+
* required fields from environment + timing where possible; the
|
|
70
|
+
* daemon then merges + validates the full record before stamping
|
|
71
|
+
* it on the agent.execute span.
|
|
72
|
+
*/
|
|
73
|
+
export const usage_record_schema = z.object({
|
|
74
|
+
version: z.literal(USAGE_RECORD_VERSION),
|
|
75
|
+
// Identity — daemon owns final values (agent can lie about its own name).
|
|
76
|
+
agent_name: z.string().min(1),
|
|
77
|
+
agent_kind: z.enum(AGENT_KINDS),
|
|
78
|
+
provider: z.string().min(1).optional(),
|
|
79
|
+
model: z.string().min(1).optional(),
|
|
80
|
+
// Timing — daemon owns; monotonic clocks preferred but wall-clock is fine.
|
|
81
|
+
started_at_unix_ms: z.number().finite().nonnegative(),
|
|
82
|
+
ended_at_unix_ms: z.number().finite().nonnegative(),
|
|
83
|
+
duration_ms: z.number().finite().nonnegative(),
|
|
84
|
+
// Outcome — daemon owns exit_code; agent supplies outcome + error_class.
|
|
85
|
+
outcome: z.enum(OUTCOMES),
|
|
86
|
+
exit_code: z.number().int().nullable(),
|
|
87
|
+
error_class: z.string().min(1).optional(),
|
|
88
|
+
// Work volume — the aggregation trick.
|
|
89
|
+
unit_kind: z.enum(UNIT_KINDS).optional(),
|
|
90
|
+
units_in: z.number().finite().nonnegative().optional(),
|
|
91
|
+
units_out: z.number().finite().nonnegative().optional(),
|
|
92
|
+
// Cost — USD only for v1. Non-cost agents leave undefined.
|
|
93
|
+
cost_usd: z.number().finite().nonnegative().optional(),
|
|
94
|
+
// Effort — 1 = happy path; >1 means retried.
|
|
95
|
+
attempts: z.number().int().positive().optional(),
|
|
96
|
+
external_calls: z.number().int().nonnegative().optional(),
|
|
97
|
+
// Escape hatch — searchable via JSONB, NOT summed in generic queries.
|
|
98
|
+
extras: z.record(z.string().min(1), extras_primitive).optional(),
|
|
99
|
+
});
|
|
100
|
+
/**
|
|
101
|
+
* Shape accepted from agents at `report_usage(...)` time. Every
|
|
102
|
+
* field except `agent_kind` + at least one of the volume fields is
|
|
103
|
+
* optional; the SDK / daemon fill the rest. `agent_kind` is
|
|
104
|
+
* required because it drives the unit-kind mapping and the rollup
|
|
105
|
+
* bucket, and only the agent knows what it is.
|
|
106
|
+
*/
|
|
107
|
+
export const usage_record_partial_schema = usage_record_schema.partial().extend({
|
|
108
|
+
agent_kind: z.enum(AGENT_KINDS),
|
|
109
|
+
});
|
|
110
|
+
/**
|
|
111
|
+
* Flatten a UsageRecord onto `usage.*` attribute keys ready to apply
|
|
112
|
+
* to an OTEL span via `span.setAttribute(key, value)`. Extras become
|
|
113
|
+
* `usage.extras.<key>`. Dashboard queries read these back from
|
|
114
|
+
* `run_spans.attributes`.
|
|
115
|
+
*/
|
|
116
|
+
export function usage_to_span_attrs(record) {
|
|
117
|
+
const out = {
|
|
118
|
+
'usage.version': record.version,
|
|
119
|
+
'usage.agent_name': record.agent_name,
|
|
120
|
+
'usage.agent_kind': record.agent_kind,
|
|
121
|
+
'usage.started_at_unix_ms': record.started_at_unix_ms,
|
|
122
|
+
'usage.ended_at_unix_ms': record.ended_at_unix_ms,
|
|
123
|
+
'usage.duration_ms': record.duration_ms,
|
|
124
|
+
'usage.outcome': record.outcome,
|
|
125
|
+
};
|
|
126
|
+
if (record.provider)
|
|
127
|
+
out['usage.provider'] = record.provider;
|
|
128
|
+
if (record.model)
|
|
129
|
+
out['usage.model'] = record.model;
|
|
130
|
+
if (record.error_class)
|
|
131
|
+
out['usage.error_class'] = record.error_class;
|
|
132
|
+
if (record.exit_code !== null && record.exit_code !== undefined) {
|
|
133
|
+
out['usage.exit_code'] = record.exit_code;
|
|
134
|
+
}
|
|
135
|
+
if (record.unit_kind !== undefined)
|
|
136
|
+
out['usage.unit_kind'] = record.unit_kind;
|
|
137
|
+
if (record.units_in !== undefined)
|
|
138
|
+
out['usage.units_in'] = record.units_in;
|
|
139
|
+
if (record.units_out !== undefined)
|
|
140
|
+
out['usage.units_out'] = record.units_out;
|
|
141
|
+
if (record.cost_usd !== undefined)
|
|
142
|
+
out['usage.cost_usd'] = record.cost_usd;
|
|
143
|
+
if (record.attempts !== undefined)
|
|
144
|
+
out['usage.attempts'] = record.attempts;
|
|
145
|
+
if (record.external_calls !== undefined)
|
|
146
|
+
out['usage.external_calls'] = record.external_calls;
|
|
147
|
+
if (record.extras) {
|
|
148
|
+
for (const [key, value] of Object.entries(record.extras)) {
|
|
149
|
+
out[`usage.extras.${key}`] = value;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return out;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Read a UsageRecord back from a span's flat `usage.*` attributes.
|
|
156
|
+
* Returns `null` if the span predates Phase 1 usage or the stored
|
|
157
|
+
* data doesn't validate (e.g. mid-migration schema drift).
|
|
158
|
+
*
|
|
159
|
+
* Numeric attributes may arrive as strings when read from JSONB via
|
|
160
|
+
* Postgres row_to_json — coerce those before validating.
|
|
161
|
+
*/
|
|
162
|
+
export function span_attrs_to_usage(attrs) {
|
|
163
|
+
const raw = {};
|
|
164
|
+
const extras = {};
|
|
165
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
166
|
+
if (!key.startsWith('usage.'))
|
|
167
|
+
continue;
|
|
168
|
+
if (key.startsWith('usage.extras.')) {
|
|
169
|
+
extras[key.slice('usage.extras.'.length)] = _coerce_extras_primitive(value);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
raw[key.slice('usage.'.length)] = value;
|
|
173
|
+
}
|
|
174
|
+
if (Object.keys(extras).length > 0)
|
|
175
|
+
raw.extras = extras;
|
|
176
|
+
_coerce_numeric(raw, 'version');
|
|
177
|
+
_coerce_numeric(raw, 'started_at_unix_ms');
|
|
178
|
+
_coerce_numeric(raw, 'ended_at_unix_ms');
|
|
179
|
+
_coerce_numeric(raw, 'duration_ms');
|
|
180
|
+
_coerce_numeric(raw, 'exit_code');
|
|
181
|
+
_coerce_numeric(raw, 'units_in');
|
|
182
|
+
_coerce_numeric(raw, 'units_out');
|
|
183
|
+
_coerce_numeric(raw, 'cost_usd');
|
|
184
|
+
_coerce_numeric(raw, 'attempts');
|
|
185
|
+
_coerce_numeric(raw, 'external_calls');
|
|
186
|
+
if (raw.exit_code === undefined)
|
|
187
|
+
raw.exit_code = null;
|
|
188
|
+
const parsed = usage_record_schema.safeParse(raw);
|
|
189
|
+
if (!parsed.success)
|
|
190
|
+
return null;
|
|
191
|
+
return parsed.data;
|
|
192
|
+
}
|
|
193
|
+
// ─── Rollup (phase / run finalisation) ─────────────────────────────
|
|
194
|
+
/**
|
|
195
|
+
* Aggregate a set of agent records into totals, by-unit-kind, and
|
|
196
|
+
* by-agent-kind subtotals. Used by the run executor when closing a
|
|
197
|
+
* phase.execute span and the root run.execute span.
|
|
198
|
+
*/
|
|
199
|
+
export function roll_up_usage(records) {
|
|
200
|
+
const totals = _zero_totals();
|
|
201
|
+
const by_unit = {};
|
|
202
|
+
const by_kind = {};
|
|
203
|
+
for (const record of records) {
|
|
204
|
+
totals.duration_ms += record.duration_ms;
|
|
205
|
+
totals.cost_usd += record.cost_usd ?? 0;
|
|
206
|
+
totals.attempts += record.attempts ?? 0;
|
|
207
|
+
totals.external_calls += record.external_calls ?? 0;
|
|
208
|
+
totals.invocations += 1;
|
|
209
|
+
if (record.outcome === 'failure' || record.outcome === 'timeout') {
|
|
210
|
+
totals.failures += 1;
|
|
211
|
+
}
|
|
212
|
+
const kind_bucket = by_kind[record.agent_kind] ?? _zero_totals();
|
|
213
|
+
kind_bucket.duration_ms += record.duration_ms;
|
|
214
|
+
kind_bucket.cost_usd += record.cost_usd ?? 0;
|
|
215
|
+
kind_bucket.attempts += record.attempts ?? 0;
|
|
216
|
+
kind_bucket.external_calls += record.external_calls ?? 0;
|
|
217
|
+
kind_bucket.invocations += 1;
|
|
218
|
+
if (record.outcome === 'failure' || record.outcome === 'timeout') {
|
|
219
|
+
kind_bucket.failures += 1;
|
|
220
|
+
}
|
|
221
|
+
by_kind[record.agent_kind] = kind_bucket;
|
|
222
|
+
if (!record.unit_kind || record.unit_kind === 'none')
|
|
223
|
+
continue;
|
|
224
|
+
const unit_bucket = by_unit[record.unit_kind] ?? {
|
|
225
|
+
unit_kind: record.unit_kind,
|
|
226
|
+
units_in: 0,
|
|
227
|
+
units_out: 0,
|
|
228
|
+
invocations: 0,
|
|
229
|
+
};
|
|
230
|
+
unit_bucket.units_in += record.units_in ?? 0;
|
|
231
|
+
unit_bucket.units_out += record.units_out ?? 0;
|
|
232
|
+
unit_bucket.invocations += 1;
|
|
233
|
+
by_unit[record.unit_kind] = unit_bucket;
|
|
234
|
+
}
|
|
235
|
+
return { totals, by_unit, by_kind };
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Flatten a rollup onto dotted-key attributes ready to stamp on a
|
|
239
|
+
* parent span. `prefix` is typically `'run.usage'` or `'phase.usage'`.
|
|
240
|
+
* Keys look like:
|
|
241
|
+
* {prefix}.total_cost_usd
|
|
242
|
+
* {prefix}.total_duration_ms
|
|
243
|
+
* {prefix}.total_invocations
|
|
244
|
+
* {prefix}.total_failures
|
|
245
|
+
* {prefix}.total_attempts
|
|
246
|
+
* {prefix}.<unit_kind>.units_in
|
|
247
|
+
* {prefix}.<unit_kind>.units_out
|
|
248
|
+
* {prefix}.<agent_kind>.cost_usd
|
|
249
|
+
* {prefix}.<agent_kind>.duration_ms
|
|
250
|
+
* {prefix}.<agent_kind>.invocations
|
|
251
|
+
* {prefix}.<agent_kind>.failures
|
|
252
|
+
*/
|
|
253
|
+
export function rollup_to_span_attrs(rollup, prefix) {
|
|
254
|
+
const out = {
|
|
255
|
+
[`${prefix}.total_cost_usd`]: rollup.totals.cost_usd,
|
|
256
|
+
[`${prefix}.total_duration_ms`]: rollup.totals.duration_ms,
|
|
257
|
+
[`${prefix}.total_invocations`]: rollup.totals.invocations,
|
|
258
|
+
[`${prefix}.total_failures`]: rollup.totals.failures,
|
|
259
|
+
[`${prefix}.total_attempts`]: rollup.totals.attempts,
|
|
260
|
+
};
|
|
261
|
+
for (const [unit, bucket] of Object.entries(rollup.by_unit)) {
|
|
262
|
+
if (!bucket)
|
|
263
|
+
continue;
|
|
264
|
+
out[`${prefix}.${unit}.units_in`] = bucket.units_in;
|
|
265
|
+
out[`${prefix}.${unit}.units_out`] = bucket.units_out;
|
|
266
|
+
out[`${prefix}.${unit}.invocations`] = bucket.invocations;
|
|
267
|
+
}
|
|
268
|
+
for (const [kind, bucket] of Object.entries(rollup.by_kind)) {
|
|
269
|
+
if (!bucket)
|
|
270
|
+
continue;
|
|
271
|
+
out[`${prefix}.${kind}.cost_usd`] = bucket.cost_usd;
|
|
272
|
+
out[`${prefix}.${kind}.duration_ms`] = bucket.duration_ms;
|
|
273
|
+
out[`${prefix}.${kind}.invocations`] = bucket.invocations;
|
|
274
|
+
out[`${prefix}.${kind}.failures`] = bucket.failures;
|
|
275
|
+
}
|
|
276
|
+
return out;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Produce a valid UsageRecord entirely from what the daemon
|
|
280
|
+
* observes. For shell/connector agents this is often the only
|
|
281
|
+
* record that will exist; LLM agents may `report_usage(...)` a
|
|
282
|
+
* richer record on top and the daemon calls `merge_usage`.
|
|
283
|
+
*/
|
|
284
|
+
export function synthesize_baseline_usage(input) {
|
|
285
|
+
const duration_ms = Math.max(0, input.exit_at_unix_ms - input.spawn_at_unix_ms);
|
|
286
|
+
const base = {
|
|
287
|
+
version: USAGE_RECORD_VERSION,
|
|
288
|
+
agent_name: input.agent_name,
|
|
289
|
+
agent_kind: input.agent_kind,
|
|
290
|
+
started_at_unix_ms: input.spawn_at_unix_ms,
|
|
291
|
+
ended_at_unix_ms: input.exit_at_unix_ms,
|
|
292
|
+
duration_ms,
|
|
293
|
+
outcome: input.outcome,
|
|
294
|
+
exit_code: input.exit_code,
|
|
295
|
+
...(input.error_class ? { error_class: input.error_class } : {}),
|
|
296
|
+
...(input.attempts !== undefined ? { attempts: input.attempts } : {}),
|
|
297
|
+
};
|
|
298
|
+
// Only shell agents naturally map stdin/stdout bytes onto units.
|
|
299
|
+
// For other kinds, leave unit_kind unset until the agent reports.
|
|
300
|
+
if (input.agent_kind === 'shell') {
|
|
301
|
+
base.unit_kind = 'bytes';
|
|
302
|
+
base.units_in = input.stdin_bytes ?? 0;
|
|
303
|
+
base.units_out = input.stdout_bytes ?? 0;
|
|
304
|
+
}
|
|
305
|
+
return base;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Merge an agent-reported record on top of a daemon-baseline record.
|
|
309
|
+
*
|
|
310
|
+
* Daemon owns (never overridden by agent):
|
|
311
|
+
* agent_name, agent_kind, started_at_unix_ms, ended_at_unix_ms,
|
|
312
|
+
* duration_ms, exit_code, outcome
|
|
313
|
+
*
|
|
314
|
+
* Everything else takes the agent's value if provided.
|
|
315
|
+
*/
|
|
316
|
+
export function merge_usage(baseline, agent_reported) {
|
|
317
|
+
const merged = { ...baseline };
|
|
318
|
+
if (agent_reported.provider !== undefined)
|
|
319
|
+
merged.provider = agent_reported.provider;
|
|
320
|
+
if (agent_reported.model !== undefined)
|
|
321
|
+
merged.model = agent_reported.model;
|
|
322
|
+
if (agent_reported.error_class !== undefined)
|
|
323
|
+
merged.error_class = agent_reported.error_class;
|
|
324
|
+
if (agent_reported.unit_kind !== undefined)
|
|
325
|
+
merged.unit_kind = agent_reported.unit_kind;
|
|
326
|
+
if (agent_reported.units_in !== undefined)
|
|
327
|
+
merged.units_in = agent_reported.units_in;
|
|
328
|
+
if (agent_reported.units_out !== undefined)
|
|
329
|
+
merged.units_out = agent_reported.units_out;
|
|
330
|
+
if (agent_reported.cost_usd !== undefined)
|
|
331
|
+
merged.cost_usd = agent_reported.cost_usd;
|
|
332
|
+
if (agent_reported.attempts !== undefined)
|
|
333
|
+
merged.attempts = agent_reported.attempts;
|
|
334
|
+
if (agent_reported.external_calls !== undefined)
|
|
335
|
+
merged.external_calls = agent_reported.external_calls;
|
|
336
|
+
if (agent_reported.extras) {
|
|
337
|
+
merged.extras = { ...(baseline.extras ?? {}), ...agent_reported.extras };
|
|
338
|
+
}
|
|
339
|
+
return merged;
|
|
340
|
+
}
|
|
341
|
+
/** A usage record failed schema validation; `issues` holds the Zod issues. */
|
|
342
|
+
export class UsageValidationError extends Error {
|
|
343
|
+
issues;
|
|
344
|
+
constructor(message, issues) {
|
|
345
|
+
super(message);
|
|
346
|
+
this.name = 'UsageValidationError';
|
|
347
|
+
this.issues = issues;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Report a usage record to the daemon. The daemon merges it onto
|
|
352
|
+
* the auto-baseline and stamps the final record on the agent.execute
|
|
353
|
+
* span attributes as `usage.*`.
|
|
354
|
+
*
|
|
355
|
+
* Fire-and-forget: the returned promise resolves on POST send (or
|
|
356
|
+
* catches the network error silently), so callers do not need to
|
|
357
|
+
* await it. Validation failures throw synchronously so agent-author
|
|
358
|
+
* tests catch them.
|
|
359
|
+
*/
|
|
360
|
+
export function report_usage(partial, options = {}) {
|
|
361
|
+
const parsed = usage_record_partial_schema.safeParse(partial);
|
|
362
|
+
if (!parsed.success) {
|
|
363
|
+
throw new UsageValidationError('report_usage: invalid UsageRecordPartial', parsed.error.issues);
|
|
364
|
+
}
|
|
365
|
+
const daemon_url = options.daemon_url ?? process.env['CLIQ_DAEMON_URL'] ?? '';
|
|
366
|
+
if (!daemon_url)
|
|
367
|
+
return Promise.resolve();
|
|
368
|
+
const run_id = options.run_id ?? process.env['CLIQ_RUN_ID'] ?? '';
|
|
369
|
+
if (!run_id)
|
|
370
|
+
return Promise.resolve();
|
|
371
|
+
const phase = options.phase ?? process.env['CLIQ_PHASE'] ?? '';
|
|
372
|
+
const agent_name = options.agent_name ?? process.env['CLIQ_AGENT'] ?? parsed.data.agent_name ?? '';
|
|
373
|
+
const body = JSON.stringify({
|
|
374
|
+
run_id,
|
|
375
|
+
event_type: 'usage',
|
|
376
|
+
phase,
|
|
377
|
+
agent: agent_name,
|
|
378
|
+
payload: { record: parsed.data },
|
|
379
|
+
});
|
|
380
|
+
const impl = options.fetch_impl ?? fetch;
|
|
381
|
+
return impl(`${daemon_url}/v1/runs/events`, {
|
|
382
|
+
method: 'POST',
|
|
383
|
+
headers: { 'Content-Type': 'application/json' },
|
|
384
|
+
body,
|
|
385
|
+
})
|
|
386
|
+
.then(() => undefined)
|
|
387
|
+
.catch(() => undefined);
|
|
388
|
+
}
|
|
389
|
+
// ─── Internal helpers ──────────────────────────────────────────────
|
|
390
|
+
function _zero_totals() {
|
|
391
|
+
return {
|
|
392
|
+
duration_ms: 0,
|
|
393
|
+
cost_usd: 0,
|
|
394
|
+
attempts: 0,
|
|
395
|
+
external_calls: 0,
|
|
396
|
+
failures: 0,
|
|
397
|
+
invocations: 0,
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
function _coerce_numeric(target, key) {
|
|
401
|
+
const raw = target[key];
|
|
402
|
+
if (raw === undefined || raw === null)
|
|
403
|
+
return;
|
|
404
|
+
if (typeof raw === 'number')
|
|
405
|
+
return;
|
|
406
|
+
if (typeof raw === 'string') {
|
|
407
|
+
const trimmed = raw.trim();
|
|
408
|
+
if (!trimmed)
|
|
409
|
+
return;
|
|
410
|
+
const n = Number(trimmed);
|
|
411
|
+
if (Number.isFinite(n))
|
|
412
|
+
target[key] = n;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
function _coerce_extras_primitive(value) {
|
|
416
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
417
|
+
return value;
|
|
418
|
+
}
|
|
419
|
+
return String(value);
|
|
420
|
+
}
|
|
421
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/telemetry/usage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,sEAAsE;AAEtE,mDAAmD;AACnD,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB,KAAK,EAAS,uDAAuD;IACrE,WAAW,EAAG,mDAAmD;IACjE,OAAO,EAAO,+BAA+B;IAC7C,MAAM,EAAQ,gCAAgC;IAC9C,SAAS,EAAK,oDAAoD;IAClE,QAAQ,EAAM,kCAAkC;CAC1C,CAAC;AAIX;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,QAAQ;IACR,OAAO;IACP,OAAO;IACP,SAAS;IACT,OAAO;IACP,MAAM;CACA,CAAC;AAIX,qCAAqC;AACrC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,CAAU,CAAC;AAKhF,sEAAsE;AAEtE;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAU,CAAC;AAE/C,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC;IAC7B,CAAC,CAAC,MAAM,EAAE;IACV,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE;IACnB,CAAC,CAAC,OAAO,EAAE;CACd,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC;IAExC,0EAA0E;IAC1E,UAA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,EAAE,CAAC;QACX,cAAc,EAAE,CAAC;QACjB,QAAQ,EAAE,CAAC;QACX,WAAW,EAAE,CAAC;KACjB,CAAC;AACN,CAAC;AAED,SAAS,eAAe,CAAC,MAA+B,EAAE,GAAW;IACjE,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACxB,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO;IAC9C,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO;IACpC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC1B,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QAC3B,IAAI,CAAC,OAAO;YAAE,OAAO;QACrB,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;QAC1B,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YAAE,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;AACL,CAAC;AAED,SAAS,wBAAwB,CAAC,KAAc;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QACvF,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Human-friendly durations in team.yml (`timeout`, `remind_every` on a phase's `hug:` block and a
|
|
3
|
+
* gate's `review:` block): a bare number of minutes, or a number with `s`, `m` or `h` — "90s",
|
|
4
|
+
* "30m", "2h", "1.5h". One parser for the SDK, the Hug gate and team lint.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Minutes in `value`, or null when it isn't a duration (empty, negative, not a number, unknown
|
|
8
|
+
* unit). A number is taken as minutes.
|
|
9
|
+
*/
|
|
10
|
+
export declare function parse_duration_minutes(value: unknown): number | null;
|
|
11
|
+
//# sourceMappingURL=duration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/utils/duration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAMpE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Human-friendly durations in team.yml (`timeout`, `remind_every` on a phase's `hug:` block and a
|
|
3
|
+
* gate's `review:` block): a bare number of minutes, or a number with `s`, `m` or `h` — "90s",
|
|
4
|
+
* "30m", "2h", "1.5h". One parser for the SDK, the Hug gate and team lint.
|
|
5
|
+
*/
|
|
6
|
+
/** Unit suffix → minutes per unit. */
|
|
7
|
+
const MINUTES_PER = { s: 1 / 60, m: 1, h: 60 };
|
|
8
|
+
/**
|
|
9
|
+
* Minutes in `value`, or null when it isn't a duration (empty, negative, not a number, unknown
|
|
10
|
+
* unit). A number is taken as minutes.
|
|
11
|
+
*/
|
|
12
|
+
export function parse_duration_minutes(value) {
|
|
13
|
+
if (typeof value === 'number')
|
|
14
|
+
return Number.isFinite(value) && value >= 0 ? value : null;
|
|
15
|
+
if (typeof value !== 'string')
|
|
16
|
+
return null;
|
|
17
|
+
const match = /^(\d+(?:\.\d+)?)\s*([smh])?$/.exec(value.trim().toLowerCase());
|
|
18
|
+
if (!match)
|
|
19
|
+
return null;
|
|
20
|
+
return Number(match[1]) * MINUTES_PER[match[2] ?? 'm'];
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=duration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.js","sourceRoot":"","sources":["../../src/utils/duration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,sCAAsC;AACtC,MAAM,WAAW,GAA2B,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;AAEvE;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACjD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1F,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3C,MAAM,KAAK,GAAG,8BAA8B,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IAC9E,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAE,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secret redaction helpers shared by every agent's error surfacing.
|
|
3
|
+
*
|
|
4
|
+
* When an agent captures stderr from a child process (git, curl, LLM
|
|
5
|
+
* CLIs) and forwards it to the run log, credentials embedded in URLs
|
|
6
|
+
* ("https://x-token-auth:<tok>@host") must not leak. This module owns
|
|
7
|
+
* the single canonical redaction the rest of the codebase relies on
|
|
8
|
+
* so we can't drift.
|
|
9
|
+
*/
|
|
10
|
+
/** Static redaction helpers for text headed to logs or the run trail. */
|
|
11
|
+
export declare class Redact {
|
|
12
|
+
/**
|
|
13
|
+
* Strip credentials from URL userinfo:
|
|
14
|
+
* https://user:pass@host/x → https://user:***@host/x
|
|
15
|
+
* https://x-token-auth:T@h/x → https://x-token-auth:***@h/x
|
|
16
|
+
* URLs without userinfo are left untouched.
|
|
17
|
+
*/
|
|
18
|
+
static secrets(text: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Return the last `n` chars of `text`, prefixed with `…` when
|
|
21
|
+
* truncation happened. Handy for keeping error tails bounded in
|
|
22
|
+
* length before logging to Hub.
|
|
23
|
+
*/
|
|
24
|
+
static tail(text: string, n: number): string;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=redact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../../src/utils/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAmBH,yEAAyE;AACzE,qBAAa,MAAM;IACf;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAOpC;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;CAK/C"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secret redaction helpers shared by every agent's error surfacing.
|
|
3
|
+
*
|
|
4
|
+
* When an agent captures stderr from a child process (git, curl, LLM
|
|
5
|
+
* CLIs) and forwards it to the run log, credentials embedded in URLs
|
|
6
|
+
* ("https://x-token-auth:<tok>@host") must not leak. This module owns
|
|
7
|
+
* the single canonical redaction the rest of the codebase relies on
|
|
8
|
+
* so we can't drift.
|
|
9
|
+
*/
|
|
10
|
+
/** Matches `://user:pass@` (the userinfo after a scheme separator); the scheme is checked separately. */
|
|
11
|
+
const USERINFO_RE = /:\/\/([^/\s@:]+):([^/\s@]+)@/g;
|
|
12
|
+
/** Characters allowed in a URL scheme after its first letter. */
|
|
13
|
+
const SCHEME_CHAR_RE = /[a-zA-Z0-9+.-]/;
|
|
14
|
+
/** True when the text just before `index` ends in a URL scheme (a letter, then letters, digits, `+`, `.`, `-`). */
|
|
15
|
+
function scheme_ends_at(text, index) {
|
|
16
|
+
let i = index;
|
|
17
|
+
let has_letter = false;
|
|
18
|
+
while (i > 0 && SCHEME_CHAR_RE.test(text[i - 1])) {
|
|
19
|
+
i--;
|
|
20
|
+
if (/[a-zA-Z]/.test(text[i]))
|
|
21
|
+
has_letter = true;
|
|
22
|
+
}
|
|
23
|
+
return has_letter;
|
|
24
|
+
}
|
|
25
|
+
/** Static redaction helpers for text headed to logs or the run trail. */
|
|
26
|
+
export class Redact {
|
|
27
|
+
/**
|
|
28
|
+
* Strip credentials from URL userinfo:
|
|
29
|
+
* https://user:pass@host/x → https://user:***@host/x
|
|
30
|
+
* https://x-token-auth:T@h/x → https://x-token-auth:***@h/x
|
|
31
|
+
* URLs without userinfo are left untouched.
|
|
32
|
+
*/
|
|
33
|
+
static secrets(text) {
|
|
34
|
+
if (!text)
|
|
35
|
+
return text;
|
|
36
|
+
// Anchored on "://" so a long run of letters is never rescanned (no backtracking blow-up).
|
|
37
|
+
return text.replace(USERINFO_RE, (match, user, _pass, offset) => scheme_ends_at(text, offset) ? `://${user}:***@` : match);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Return the last `n` chars of `text`, prefixed with `…` when
|
|
41
|
+
* truncation happened. Handy for keeping error tails bounded in
|
|
42
|
+
* length before logging to Hub.
|
|
43
|
+
*/
|
|
44
|
+
static tail(text, n) {
|
|
45
|
+
if (!text)
|
|
46
|
+
return '';
|
|
47
|
+
if (text.length <= n)
|
|
48
|
+
return text;
|
|
49
|
+
return `…${text.slice(-n)}`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=redact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.js","sourceRoot":"","sources":["../../src/utils/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,yGAAyG;AACzG,MAAM,WAAW,GAAG,+BAA+B,CAAC;AAEpD,iEAAiE;AACjE,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAExC,mHAAmH;AACnH,SAAS,cAAc,CAAC,IAAY,EAAE,KAAa;IAC/C,IAAI,CAAC,GAAG,KAAK,CAAC;IACd,IAAI,UAAU,GAAG,KAAK,CAAC;IACvB,OAAO,CAAC,GAAG,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAE,CAAC,EAAE,CAAC;QAChD,CAAC,EAAE,CAAC;QACJ,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC;YAAE,UAAU,GAAG,IAAI,CAAC;IACrD,CAAC;IACD,OAAO,UAAU,CAAC;AACtB,CAAC;AAED,yEAAyE;AACzE,MAAM,OAAO,MAAM;IACf;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,IAAY;QACvB,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QACvB,2FAA2F;QAC3F,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,KAAa,EAAE,IAAY,EAAE,KAAa,EAAE,MAAc,EAAE,EAAE,CAC5F,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAAC,IAAY,EAAE,CAAS;QAC/B,IAAI,CAAC,IAAI;YAAE,OAAO,EAAE,CAAC;QACrB,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QAClC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAChC,CAAC;CACJ"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Small URL string helpers shared by the HTTP clients (no regexes, so no backtracking).
|
|
3
|
+
*/
|
|
4
|
+
/** `url` without its trailing slashes, so `${base}${path}` never doubles them. */
|
|
5
|
+
export declare function strip_trailing_slashes(url: string): string;
|
|
6
|
+
//# sourceMappingURL=url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,kFAAkF;AAClF,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI1D"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Small URL string helpers shared by the HTTP clients (no regexes, so no backtracking).
|
|
3
|
+
*/
|
|
4
|
+
/** `url` without its trailing slashes, so `${base}${path}` never doubles them. */
|
|
5
|
+
export function strip_trailing_slashes(url) {
|
|
6
|
+
let end = url.length;
|
|
7
|
+
while (end > 0 && url[end - 1] === '/')
|
|
8
|
+
end--;
|
|
9
|
+
return url.slice(0, end);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,kFAAkF;AAClF,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAC9C,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC;IACrB,OAAO,GAAG,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,GAAG;QAAE,GAAG,EAAE,CAAC;IAC9C,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC7B,CAAC"}
|