@tangle-network/agent-app 0.60.282 → 0.60.283
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/dist/app-auth/index.js +2 -2
- package/dist/assistant/index.js +6 -5
- package/dist/assistant/index.js.map +1 -1
- package/dist/chat-react/index.js +1 -1
- package/dist/chat-routes/index.js +18 -18
- package/dist/chunk-276PF4R6.js +342 -0
- package/dist/chunk-276PF4R6.js.map +1 -0
- package/dist/{chunk-VJBFCNAU.js → chunk-7D5MHMCP.js} +4 -4
- package/dist/{chunk-4P5NFBWX.js → chunk-BI5AZAOO.js} +4 -4
- package/dist/{chunk-FBVLEGEG.js → chunk-GDUT72VK.js} +34 -6
- package/dist/chunk-GDUT72VK.js.map +1 -0
- package/dist/{chunk-LO6VQ35O.js → chunk-U77HPL3I.js} +2 -2
- package/dist/{chunk-YI2XZCTP.js → chunk-WEUCLHAP.js} +5 -48
- package/dist/chunk-WEUCLHAP.js.map +1 -0
- package/dist/design-canvas/index.js +3 -3
- package/dist/design-canvas-react/index.js +4 -4
- package/dist/launch-invariants/index.js +8 -8
- package/dist/openui/index.js +3 -3
- package/dist/platform/index.js +12 -12
- package/dist/profile/index.js +1 -1
- package/dist/runtime/index.js +3 -3
- package/dist/runtime/router-turn.js +2 -2
- package/dist/sequences/index.js +5 -5
- package/dist/settings-react/index.js +1 -1
- package/dist/skills/index.js +3 -3
- package/dist/skills-placement/box.js +1 -1
- package/dist/skills-placement/index.js +1 -1
- package/dist/stories/chat-controls/discovery-waterfall-fixture.d.ts +3 -0
- package/dist/theme/tokens.css +72 -0
- package/dist/trace/flow-types.d.ts +9 -1
- package/dist/trace/index.d.ts +1 -0
- package/dist/trace/index.js +14 -1
- package/dist/trace/index.js.map +1 -1
- package/dist/trace/mission-flow.d.ts +2 -3
- package/dist/turn-stream/index.js +3 -3
- package/dist/web-react/flow-waterfall-model.d.ts +22 -0
- package/dist/web-react/flow-waterfall.css +72 -0
- package/dist/web-react/flow-waterfall.d.ts +14 -0
- package/dist/web-react/flow-waterfall.js +7 -0
- package/dist/web-react/flow-waterfall.js.map +1 -0
- package/dist/web-react/index.js +14 -12
- package/dist/web-react/mission-activity.d.ts +2 -20
- package/dist/work-product/index.js +10 -10
- package/package.json +14 -7
- package/dist/chunk-FBVLEGEG.js.map +0 -1
- package/dist/chunk-YI2XZCTP.js.map +0 -1
- /package/dist/{chunk-VJBFCNAU.js.map → chunk-7D5MHMCP.js.map} +0 -0
- /package/dist/{chunk-4P5NFBWX.js.map → chunk-BI5AZAOO.js.map} +0 -0
- /package/dist/{chunk-LO6VQ35O.js.map → chunk-U77HPL3I.js.map} +0 -0
|
@@ -37,13 +37,13 @@ import {
|
|
|
37
37
|
validateSceneOperations,
|
|
38
38
|
validateSlotValue
|
|
39
39
|
} from "../chunk-ZWJ3SZ2G.js";
|
|
40
|
+
import "../chunk-CQGEGPY7.js";
|
|
41
|
+
import "../chunk-RN4WPTBH.js";
|
|
42
|
+
import "../chunk-WP2GYFZ4.js";
|
|
40
43
|
import {
|
|
41
44
|
buildScopedMcpServerEntry,
|
|
42
45
|
createMcpToolHandler
|
|
43
46
|
} from "../chunk-6A7MYOUI.js";
|
|
44
|
-
import "../chunk-CQGEGPY7.js";
|
|
45
|
-
import "../chunk-RN4WPTBH.js";
|
|
46
|
-
import "../chunk-WP2GYFZ4.js";
|
|
47
47
|
import "../chunk-TXD5HXLE.js";
|
|
48
48
|
import "../chunk-6Z7TZVKZ.js";
|
|
49
49
|
import "../chunk-57XPEL7X.js";
|
|
@@ -41,10 +41,6 @@ import {
|
|
|
41
41
|
formatRulerLabel,
|
|
42
42
|
selectTickStep
|
|
43
43
|
} from "../chunk-NHYRIM4I.js";
|
|
44
|
-
import {
|
|
45
|
-
DesignCanvasChromeLazy,
|
|
46
|
-
DesignCanvasLazy
|
|
47
|
-
} from "../chunk-PDD5A43Y.js";
|
|
48
44
|
import "../chunk-ZN5J47UX.js";
|
|
49
45
|
import {
|
|
50
46
|
DEFAULT_INSERT_TEMPLATES,
|
|
@@ -87,6 +83,10 @@ import {
|
|
|
87
83
|
setPagePropsCommand,
|
|
88
84
|
ungroupElementCommand
|
|
89
85
|
} from "../chunk-BTKI4XMM.js";
|
|
86
|
+
import {
|
|
87
|
+
DesignCanvasChromeLazy,
|
|
88
|
+
DesignCanvasLazy
|
|
89
|
+
} from "../chunk-PDD5A43Y.js";
|
|
90
90
|
import {
|
|
91
91
|
assertSceneMediaSrc,
|
|
92
92
|
bleedAwareExportBounds,
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
D1_MAX_BOUND_PARAMETERS,
|
|
3
|
-
SIZED_READ_BYTES,
|
|
4
|
-
SIZED_READ_COMPOSITE_ROWS,
|
|
5
|
-
SIZED_READ_ROWS,
|
|
6
|
-
readInSizedBatches,
|
|
7
|
-
sizedBatches
|
|
8
|
-
} from "../chunk-5UQJ7F3P.js";
|
|
9
1
|
import {
|
|
10
2
|
DEFAULT_LIMIT_BUDGETS,
|
|
11
3
|
LIMIT_RESOURCES,
|
|
@@ -28,6 +20,14 @@ import {
|
|
|
28
20
|
LAUNCH_INVARIANT_IDS,
|
|
29
21
|
describeVerdict
|
|
30
22
|
} from "../chunk-LRYY3OX7.js";
|
|
23
|
+
import {
|
|
24
|
+
D1_MAX_BOUND_PARAMETERS,
|
|
25
|
+
SIZED_READ_BYTES,
|
|
26
|
+
SIZED_READ_COMPOSITE_ROWS,
|
|
27
|
+
SIZED_READ_ROWS,
|
|
28
|
+
readInSizedBatches,
|
|
29
|
+
sizedBatches
|
|
30
|
+
} from "../chunk-5UQJ7F3P.js";
|
|
31
31
|
import "../chunk-CD2LQXY6.js";
|
|
32
32
|
import "../chunk-F2VX6TTJ.js";
|
|
33
33
|
import {
|
package/dist/openui/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseJsonObjectBody
|
|
3
|
+
} from "../chunk-WP2GYFZ4.js";
|
|
1
4
|
import {
|
|
2
5
|
OPENUI_INPUT_KINDS,
|
|
3
6
|
OPENUI_INTERACTIVE_AUTHORING_GUIDE
|
|
4
7
|
} from "../chunk-UGWQLQDS.js";
|
|
5
|
-
import {
|
|
6
|
-
parseJsonObjectBody
|
|
7
|
-
} from "../chunk-WP2GYFZ4.js";
|
|
8
8
|
import "../chunk-TXD5HXLE.js";
|
|
9
9
|
|
|
10
10
|
// src/openui/segments.ts
|
package/dist/platform/index.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PLATFORM_AGENT_KEY_PROVISIONER,
|
|
3
|
+
PLATFORM_KEY_PREFIX,
|
|
4
|
+
agentOperatorScopes,
|
|
5
|
+
createApiKeyRequestAuth,
|
|
6
|
+
createPlatformAgentKeyVerifier,
|
|
7
|
+
platformKeyRefusal
|
|
8
|
+
} from "../chunk-XB4KZVUV.js";
|
|
1
9
|
import {
|
|
2
10
|
TangleSsoAccountConflictError,
|
|
3
11
|
TangleSsoUserCreateError,
|
|
@@ -13,29 +21,21 @@ import {
|
|
|
13
21
|
resolveTangleSsoAccount,
|
|
14
22
|
signSessionCookieValue,
|
|
15
23
|
verifySignedSsoState
|
|
16
|
-
} from "../chunk-
|
|
17
|
-
import {
|
|
18
|
-
PLATFORM_AGENT_KEY_PROVISIONER,
|
|
19
|
-
PLATFORM_KEY_PREFIX,
|
|
20
|
-
agentOperatorScopes,
|
|
21
|
-
createApiKeyRequestAuth,
|
|
22
|
-
createPlatformAgentKeyVerifier,
|
|
23
|
-
platformKeyRefusal
|
|
24
|
-
} from "../chunk-XB4KZVUV.js";
|
|
24
|
+
} from "../chunk-BI5AZAOO.js";
|
|
25
25
|
import {
|
|
26
26
|
assertWorkspaceKeyCryptoUsable
|
|
27
27
|
} from "../chunk-VGS2NXLB.js";
|
|
28
28
|
import {
|
|
29
29
|
createWarmCache
|
|
30
30
|
} from "../chunk-F4TUZYMX.js";
|
|
31
|
-
import {
|
|
32
|
-
resolveTangleExecutionEnvironment
|
|
33
|
-
} from "../chunk-D6UJEOZQ.js";
|
|
34
31
|
import "../chunk-CQGEGPY7.js";
|
|
35
32
|
import "../chunk-RN4WPTBH.js";
|
|
36
33
|
import {
|
|
37
34
|
parseJsonObjectBody
|
|
38
35
|
} from "../chunk-WP2GYFZ4.js";
|
|
36
|
+
import {
|
|
37
|
+
resolveTangleExecutionEnvironment
|
|
38
|
+
} from "../chunk-D6UJEOZQ.js";
|
|
39
39
|
import {
|
|
40
40
|
sha256Hex
|
|
41
41
|
} from "../chunk-HY57QRRW.js";
|
package/dist/profile/index.js
CHANGED
|
@@ -32,10 +32,10 @@ import {
|
|
|
32
32
|
skillMountPath,
|
|
33
33
|
skillRefs
|
|
34
34
|
} from "../chunk-TXUAGSFR.js";
|
|
35
|
-
import "../chunk-LTWJYNEC.js";
|
|
36
35
|
import {
|
|
37
36
|
parseSkillFrontmatter
|
|
38
37
|
} from "../chunk-PV33JZKV.js";
|
|
38
|
+
import "../chunk-LTWJYNEC.js";
|
|
39
39
|
import {
|
|
40
40
|
sha256Hex
|
|
41
41
|
} from "../chunk-HY57QRRW.js";
|
package/dist/runtime/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
ProtectedModelSettlementError,
|
|
3
3
|
createRouterProtectedModelPort,
|
|
4
4
|
runProtectedRouterTurn
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-U77HPL3I.js";
|
|
6
6
|
import {
|
|
7
7
|
DURABLE_HOP_BUDGET_MS,
|
|
8
8
|
asksForLanguage,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
turnKnowledgeInstructions,
|
|
27
27
|
workspaceKnowledgeForTurn,
|
|
28
28
|
workspaceTurnCheckpoints
|
|
29
|
-
} from "../chunk-
|
|
29
|
+
} from "../chunk-7D5MHMCP.js";
|
|
30
30
|
import "../chunk-UFQM46NV.js";
|
|
31
31
|
import {
|
|
32
32
|
DEFAULT_TANGLE_BILLING_ENFORCEMENT_ENV_VAR,
|
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
tangleExecutionKeyHttpError,
|
|
44
44
|
trimOrNull
|
|
45
45
|
} from "../chunk-D6UJEOZQ.js";
|
|
46
|
+
import "../chunk-ORQD4AUO.js";
|
|
46
47
|
import {
|
|
47
48
|
MAX_RECOMMENDED_MODELS,
|
|
48
49
|
__resetCatalogCache,
|
|
@@ -54,7 +55,6 @@ import {
|
|
|
54
55
|
resolveCatalogModelId,
|
|
55
56
|
sortModelsByFreshness
|
|
56
57
|
} from "../chunk-AMUXRAUO.js";
|
|
57
|
-
import "../chunk-ORQD4AUO.js";
|
|
58
58
|
|
|
59
59
|
// src/runtime/certified-delivery.ts
|
|
60
60
|
import {
|
|
@@ -13,11 +13,11 @@ import {
|
|
|
13
13
|
turnKnowledgeInstructions,
|
|
14
14
|
workspaceKnowledgeForTurn,
|
|
15
15
|
workspaceTurnCheckpoints
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-7D5MHMCP.js";
|
|
17
17
|
import "../chunk-UFQM46NV.js";
|
|
18
18
|
import "../chunk-D6UJEOZQ.js";
|
|
19
|
-
import "../chunk-AMUXRAUO.js";
|
|
20
19
|
import "../chunk-ORQD4AUO.js";
|
|
20
|
+
import "../chunk-AMUXRAUO.js";
|
|
21
21
|
export {
|
|
22
22
|
DURABLE_HOP_BUDGET_MS,
|
|
23
23
|
asksForLanguage,
|
package/dist/sequences/index.js
CHANGED
|
@@ -16,16 +16,16 @@ import {
|
|
|
16
16
|
requireEnum,
|
|
17
17
|
requireString
|
|
18
18
|
} from "../chunk-NMZUW6VJ.js";
|
|
19
|
-
import {
|
|
20
|
-
MCP_PROTOCOL_VERSIONS,
|
|
21
|
-
buildScopedMcpServerEntry,
|
|
22
|
-
createMcpToolHandler
|
|
23
|
-
} from "../chunk-6A7MYOUI.js";
|
|
24
19
|
import "../chunk-CQGEGPY7.js";
|
|
25
20
|
import "../chunk-RN4WPTBH.js";
|
|
26
21
|
import {
|
|
27
22
|
assertMediaUrl
|
|
28
23
|
} from "../chunk-WP2GYFZ4.js";
|
|
24
|
+
import {
|
|
25
|
+
MCP_PROTOCOL_VERSIONS,
|
|
26
|
+
buildScopedMcpServerEntry,
|
|
27
|
+
createMcpToolHandler
|
|
28
|
+
} from "../chunk-6A7MYOUI.js";
|
|
29
29
|
import "../chunk-TXD5HXLE.js";
|
|
30
30
|
import "../chunk-6Z7TZVKZ.js";
|
|
31
31
|
import "../chunk-57XPEL7X.js";
|
|
@@ -21,12 +21,12 @@ import {
|
|
|
21
21
|
useBrowserLayoutEffect,
|
|
22
22
|
usePopover
|
|
23
23
|
} from "../chunk-R4X5474U.js";
|
|
24
|
+
import "../chunk-RASGKEAL.js";
|
|
24
25
|
import {
|
|
25
26
|
confirmWrite,
|
|
26
27
|
rejectWrite,
|
|
27
28
|
useConfirmedMutation
|
|
28
29
|
} from "../chunk-AVP5SNIG.js";
|
|
29
|
-
import "../chunk-RASGKEAL.js";
|
|
30
30
|
import {
|
|
31
31
|
useWorkspaceExport
|
|
32
32
|
} from "../chunk-EZFBGW23.js";
|
package/dist/skills/index.js
CHANGED
|
@@ -13,6 +13,9 @@ import {
|
|
|
13
13
|
skillMountPath,
|
|
14
14
|
skillRefs
|
|
15
15
|
} from "../chunk-TXUAGSFR.js";
|
|
16
|
+
import {
|
|
17
|
+
parseSkillFrontmatter
|
|
18
|
+
} from "../chunk-PV33JZKV.js";
|
|
16
19
|
import {
|
|
17
20
|
MAX_MARKETPLACE_ENTRIES,
|
|
18
21
|
createInMemoryMarketplaceStore,
|
|
@@ -26,9 +29,6 @@ import {
|
|
|
26
29
|
validateMarketplaceCatalog,
|
|
27
30
|
validateMarketplaceSkill
|
|
28
31
|
} from "../chunk-LTWJYNEC.js";
|
|
29
|
-
import {
|
|
30
|
-
parseSkillFrontmatter
|
|
31
|
-
} from "../chunk-PV33JZKV.js";
|
|
32
32
|
export {
|
|
33
33
|
MAX_MARKETPLACE_ENTRIES,
|
|
34
34
|
assertSkillDeliveryDisjoint,
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
} from "../chunk-MDRH3SDA.js";
|
|
8
8
|
import "../chunk-FPNZMIAW.js";
|
|
9
9
|
import "../chunk-TXUAGSFR.js";
|
|
10
|
-
import "../chunk-LTWJYNEC.js";
|
|
11
10
|
import "../chunk-PV33JZKV.js";
|
|
11
|
+
import "../chunk-LTWJYNEC.js";
|
|
12
12
|
import {
|
|
13
13
|
sha256Hex
|
|
14
14
|
} from "../chunk-HY57QRRW.js";
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
} from "../chunk-MDRH3SDA.js";
|
|
8
8
|
import "../chunk-FPNZMIAW.js";
|
|
9
9
|
import "../chunk-TXUAGSFR.js";
|
|
10
|
-
import "../chunk-LTWJYNEC.js";
|
|
11
10
|
import "../chunk-PV33JZKV.js";
|
|
11
|
+
import "../chunk-LTWJYNEC.js";
|
|
12
12
|
export {
|
|
13
13
|
composeSkillsForHarness,
|
|
14
14
|
resolveSkillDir,
|
package/dist/theme/tokens.css
CHANGED
|
@@ -2056,6 +2056,78 @@
|
|
|
2056
2056
|
--agent-app-warning-text-hsl: 37.92 98.4252% 75.098%
|
|
2057
2057
|
}
|
|
2058
2058
|
}
|
|
2059
|
+
/* Standalone surface: consumes Brand/Agent App tokens; no Tailwind build required. */
|
|
2060
|
+
.fw-root {
|
|
2061
|
+
--fw-text: var(--text-primary, hsl(var(--foreground)));
|
|
2062
|
+
--fw-muted: var(--text-muted, hsl(var(--muted-foreground)));
|
|
2063
|
+
--fw-surface: var(--bg-card, hsl(var(--background)));
|
|
2064
|
+
--fw-border: var(--border-default, hsl(var(--border)));
|
|
2065
|
+
--fw-well: var(--md3-surface-container, hsl(var(--secondary)));
|
|
2066
|
+
--fw-accent: var(--accent-text, hsl(var(--primary)));
|
|
2067
|
+
color: var(--fw-text);
|
|
2068
|
+
background: var(--fw-surface);
|
|
2069
|
+
border: 1px solid var(--fw-border);
|
|
2070
|
+
border-radius: var(--radius-lg, .75rem);
|
|
2071
|
+
min-width: 0;
|
|
2072
|
+
font: inherit;
|
|
2073
|
+
font-size: .8125rem;
|
|
2074
|
+
line-height: 1.5;
|
|
2075
|
+
}
|
|
2076
|
+
.fw-root *, .fw-root *::before, .fw-root *::after { box-sizing: border-box; }
|
|
2077
|
+
.fw-root :is(p, dl, dd) { margin: 0; }
|
|
2078
|
+
.fw-root .fw-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding: .75rem; border-bottom: 1px solid var(--fw-border); }
|
|
2079
|
+
.fw-root .fw-title { display: flex; align-items: center; gap: .5rem; font-weight: 600; font-size: .875rem; }
|
|
2080
|
+
.fw-root .fw-search { display: flex; min-width: 0; gap: .25rem; align-items: center; }
|
|
2081
|
+
.fw-root .fw-control { appearance: auto; font: inherit; font-size: .75rem; line-height: 1.4; min-height: 2rem; padding: .25rem .5rem; border: 1px solid var(--fw-border); border-radius: var(--radius-sm, .375rem); color: var(--fw-text); background: var(--fw-surface); cursor: pointer; }
|
|
2082
|
+
.fw-root .fw-control:hover, .fw-root .fw-toggle:hover { background: var(--fw-well); }
|
|
2083
|
+
.fw-root :is(button, input, select, [tabindex]):focus-visible { outline: 2px solid var(--fw-accent); outline-offset: 2px; }
|
|
2084
|
+
.fw-root :is(button, input):disabled { opacity: .5; cursor: default; }
|
|
2085
|
+
.fw-root .fw-search-input { width: 10rem; min-width: 0; cursor: text; }
|
|
2086
|
+
.fw-root .fw-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem 1rem; padding: .75rem; border-bottom: 1px solid var(--fw-border); }
|
|
2087
|
+
.fw-root .fw-muted { color: var(--fw-muted); font-size: .75rem; }
|
|
2088
|
+
.fw-root .fw-value { margin-top: .125rem; font-family: var(--font-mono, monospace); font-size: .875rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
|
|
2089
|
+
.fw-root .fw-legend { display: flex; flex-wrap: wrap; gap: .25rem .75rem; padding: .5rem .75rem; border-bottom: 1px solid var(--fw-border); color: var(--fw-muted); font-size: .75rem; }
|
|
2090
|
+
.fw-root .fw-legend-item { display: inline-flex; align-items: center; gap: .25rem; }
|
|
2091
|
+
.fw-root .fw-dot { width: .375rem; height: .375rem; border-radius: 50%; }
|
|
2092
|
+
.fw-root .fw-orchestrator { background: var(--fw-muted); }
|
|
2093
|
+
.fw-root .fw-model { background: var(--chart-accent, hsl(var(--primary))); }
|
|
2094
|
+
.fw-root .fw-tool { background: var(--status-cold, hsl(var(--accent))); }
|
|
2095
|
+
.fw-root .fw-waiting { background: var(--status-stopped, hsl(var(--warning-strong))); }
|
|
2096
|
+
.fw-root .fw-handoff { background: var(--status-running, hsl(var(--success))); }
|
|
2097
|
+
.fw-root .fw-failed { background: var(--status-error, hsl(var(--destructive))); }
|
|
2098
|
+
.fw-root .fw-branches { display: flex; gap: .5rem; padding: .5rem .75rem 0; }
|
|
2099
|
+
.fw-root .fw-timeline { overflow-x: auto; padding: .75rem; }
|
|
2100
|
+
.fw-root .fw-track { min-width: 480px; }
|
|
2101
|
+
.fw-root .fw-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) 70px; align-items: center; gap: .5rem; }
|
|
2102
|
+
.fw-root .fw-axis { padding-bottom: .5rem; color: var(--fw-muted); font-size: .75rem; }
|
|
2103
|
+
.fw-root .fw-ticks { display: flex; justify-content: space-between; font-family: var(--font-mono, monospace); font-variant-numeric: tabular-nums; }
|
|
2104
|
+
.fw-root .fw-align-right { text-align: right; }
|
|
2105
|
+
.fw-root .fw-empty { padding: 2rem .5rem; text-align: center; color: var(--fw-muted); font-size: .875rem; }
|
|
2106
|
+
.fw-root .fw-row { border-radius: .25rem; padding: .375rem 0; }
|
|
2107
|
+
.fw-root .fw-slowest { background: var(--fw-well); outline: 1px solid var(--fw-border); }
|
|
2108
|
+
.fw-root .fw-pending { opacity: .4; }
|
|
2109
|
+
.fw-root .fw-name { display: flex; align-items: center; min-width: 0; }
|
|
2110
|
+
.fw-root .fw-toggle { appearance: none; width: 1.5rem; height: 1.5rem; margin-right: .25rem; flex-shrink: 0; border: 0; border-radius: .25rem; background: transparent; color: var(--fw-text); font: inherit; cursor: pointer; }
|
|
2111
|
+
.fw-root .fw-leaf { margin-right: .25rem; width: 1.5rem; flex-shrink: 0; text-align: center; color: var(--fw-muted); }
|
|
2112
|
+
.fw-root .fw-span-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .75rem; }
|
|
2113
|
+
.fw-root .fw-error-text { color: var(--text-danger, var(--status-error)); }
|
|
2114
|
+
.fw-root .fw-bar-track { position: relative; height: 1rem; overflow: hidden; border-radius: .125rem; background: var(--fw-well); }
|
|
2115
|
+
.fw-root .fw-bar { position: absolute; top: 0; bottom: 0; border-radius: .125rem; }
|
|
2116
|
+
.fw-root .fw-approx { opacity: .7; }
|
|
2117
|
+
.fw-root .fw-playhead { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--fw-text); }
|
|
2118
|
+
.fw-root .fw-duration { padding-right: .25rem; text-align: right; font-family: var(--font-mono, monospace); font-size: .75rem; font-variant-numeric: tabular-nums; }
|
|
2119
|
+
.fw-root .fw-slowest-caption { padding: 0 .75rem .5rem; color: var(--fw-muted); font-size: .75rem; overflow-wrap: anywhere; }
|
|
2120
|
+
.fw-root .fw-text { color: var(--fw-text); }
|
|
2121
|
+
.fw-root .fw-playback { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; border-top: 1px solid var(--fw-border); padding: .75rem; }
|
|
2122
|
+
.fw-root .fw-speed, .fw-root .fw-position { display: flex; align-items: center; gap: .25rem; color: var(--fw-muted); font-size: .75rem; }
|
|
2123
|
+
.fw-root .fw-position { flex: 1; min-width: 6rem; gap: .5rem; }
|
|
2124
|
+
.fw-root .fw-slider { min-width: 0; flex: 1; accent-color: var(--fw-accent); }
|
|
2125
|
+
.fw-root .fw-time { font-family: var(--font-mono, monospace); font-size: .75rem; font-variant-numeric: tabular-nums; color: var(--fw-muted); }
|
|
2126
|
+
.fw-root .fw-sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
|
|
2127
|
+
@media (max-width: 480px) {
|
|
2128
|
+
.fw-root .fw-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
2129
|
+
.fw-root .fw-position { flex-basis: 100%; }
|
|
2130
|
+
}
|
|
2059
2131
|
|
|
2060
2132
|
@layer theme {
|
|
2061
2133
|
:where(:root) {
|
|
@@ -5,7 +5,12 @@
|
|
|
5
5
|
* through the barrel. The barrel re-exports these names unchanged.
|
|
6
6
|
*/
|
|
7
7
|
export interface FlowSpan {
|
|
8
|
-
kind: 'pipeline' | 'model' | 'tool';
|
|
8
|
+
kind: 'pipeline' | 'model' | 'tool' | 'waiting' | 'handoff';
|
|
9
|
+
/** Stable identity and parent identity for nested, incrementally updated traces. */
|
|
10
|
+
id?: string;
|
|
11
|
+
parentId?: string;
|
|
12
|
+
/** Running spans extend from endMs to the viewer's observation time. */
|
|
13
|
+
status?: 'running' | 'done' | 'failed';
|
|
9
14
|
name: string;
|
|
10
15
|
startMs: number;
|
|
11
16
|
endMs: number;
|
|
@@ -21,4 +26,7 @@ export interface FlowTrace {
|
|
|
21
26
|
/** Computed when per-token pricing is supplied. */
|
|
22
27
|
costUsd?: number;
|
|
23
28
|
toolCalls: number;
|
|
29
|
+
/** Authoritative LLM request count when supplied; absent means unknown. */
|
|
30
|
+
modelCalls?: number;
|
|
31
|
+
errors?: number;
|
|
24
32
|
}
|
package/dist/trace/index.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export declare function buildFlowTrace(events: TimedEvent[], opts?: {
|
|
|
35
35
|
prompt?: string | number;
|
|
36
36
|
completion?: string | number;
|
|
37
37
|
};
|
|
38
|
+
running?: boolean;
|
|
38
39
|
}): FlowTrace;
|
|
39
40
|
/** ASCII waterfall cascade — the default artifact for explaining a flow. */
|
|
40
41
|
export declare function renderWaterfall(trace: FlowTrace, opts?: {
|
package/dist/trace/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
delegationActivityToFlowSpans,
|
|
4
4
|
loopTraceEventsToFlowSpans,
|
|
5
5
|
stepActivityFlowTrace
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-GDUT72VK.js";
|
|
7
7
|
|
|
8
8
|
// src/trace/mission-trace.ts
|
|
9
9
|
function createMissionTraceContext(missionId) {
|
|
@@ -108,6 +108,7 @@ function buildFlowTrace(events, opts) {
|
|
|
108
108
|
if (open) {
|
|
109
109
|
spans.push({
|
|
110
110
|
kind: "tool",
|
|
111
|
+
id,
|
|
111
112
|
name: open.name,
|
|
112
113
|
// Execution happens between the end of the model turn that emitted
|
|
113
114
|
// the call and the result landing in the buffer.
|
|
@@ -126,6 +127,18 @@ function buildFlowTrace(events, opts) {
|
|
|
126
127
|
}
|
|
127
128
|
closeSegment();
|
|
128
129
|
const totalMs = events.length ? events[events.length - 1].t : 0;
|
|
130
|
+
for (const [id, open] of openCalls) {
|
|
131
|
+
spans.push({
|
|
132
|
+
id,
|
|
133
|
+
kind: "tool",
|
|
134
|
+
name: open.name,
|
|
135
|
+
startMs: open.lastDeltaT,
|
|
136
|
+
endMs: totalMs,
|
|
137
|
+
status: opts?.running ? "running" : void 0,
|
|
138
|
+
approx: true
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
if (opts?.running && spans.at(-1)?.kind === "model") spans.at(-1).status = "running";
|
|
129
142
|
const trace = { spans, totalMs, promptTokens, completionTokens, toolCalls };
|
|
130
143
|
const p = opts?.pricing;
|
|
131
144
|
if (p && (p.prompt != null || p.completion != null)) {
|
package/dist/trace/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/trace/mission-trace.ts","../../src/trace/index.ts"],"sourcesContent":["/**\n * Mission trace context — mint + thread the trace ids that join a mission's\n * step attempts and its delegated agent runs into ONE trace tree.\n *\n * ID formats are byte-compatible with agent-runtime's trace propagation\n * (`readTraceContextFromEnv` / OTLP export): 32 lowercase hex chars for a\n * trace id (16 bytes), 16 for a span id (8 bytes). The env pair from\n * {@link traceEnv} is exactly what agent-runtime's MCP subprocess reads at\n * startup (`TRACE_ID` + `PARENT_SPAN_ID`), so a delegation dispatched with it\n * parents its loop→round→iteration spans under the mission's step span.\n *\n * Pure functions, no deps. Ids are DETERMINISTIC when a key is supplied\n * (missionId / step-attempt seed) so a crashed driver re-mints the identical\n * context on re-dispatch and the re-run joins the same trace instead of\n * forking a new one; without a key they are random.\n */\n\nexport interface MissionTraceContext {\n /** 32-hex trace id shared by every span in the mission's tree. */\n traceId: string\n /** 16-hex span id of the mission root — the parent of every step span. */\n rootSpanId: string\n}\n\n/** Define context information for a step span including trace, span, and parent span identifiers */\nexport interface StepSpanContext {\n traceId: string\n /** 16-hex span id of this step attempt (or any nested unit of work). */\n spanId: string\n /** The span this one nests under. */\n parentSpanId: string\n}\n\n/**\n * Mint a mission's trace context. With `missionId` the ids are a pure\n * function of it; omitted, both ids are random.\n */\nexport function createMissionTraceContext(missionId?: string): MissionTraceContext {\n if (missionId !== undefined && missionId !== '') {\n return {\n traceId: hex64(fnv1a64(`mission-trace:${missionId}`)) + hex64(fnv1a64(`mission-trace:2:${missionId}`)),\n rootSpanId: hex64(fnv1a64(`mission-root-span:${missionId}`)),\n }\n }\n return { traceId: randomHex(16), rootSpanId: randomHex(8) }\n}\n\n/**\n * Derive a child span context under `parent` — one per step attempt (seed\n * e.g. `\"${stepId}#${attempt}\"`), or nested under another step span. With a\n * seed the span id is deterministic for the same parent + seed; omitted, it\n * is random.\n */\nexport function childSpanContext(\n parent: MissionTraceContext | StepSpanContext,\n seed?: string,\n): StepSpanContext {\n const parentSpanId = 'rootSpanId' in parent ? parent.rootSpanId : parent.spanId\n const spanId =\n seed !== undefined && seed !== ''\n ? hex64(fnv1a64(`span:${parent.traceId}:${parentSpanId}:${seed}`))\n : randomHex(8)\n return { traceId: parent.traceId, spanId, parentSpanId }\n}\n\n/**\n * The env pair a delegation subprocess inherits — agent-runtime's\n * `readTraceContextFromEnv` reads exactly these names. `PARENT_SPAN_ID` is\n * the span the dispatched work nests under: the root for a mission context,\n * the step-attempt span for a step context.\n */\nexport function traceEnv(ctx: MissionTraceContext | StepSpanContext): {\n TRACE_ID: string\n PARENT_SPAN_ID: string\n} {\n return {\n TRACE_ID: ctx.traceId,\n PARENT_SPAN_ID: 'rootSpanId' in ctx ? ctx.rootSpanId : ctx.spanId,\n }\n}\n\n// FNV-1a 64-bit over UTF-16 code units — a stable, dependency-free digest for\n// deterministic ids. Not cryptographic; trace ids only need uniqueness within\n// a tenant's missions, not unforgeability.\nconst FNV_OFFSET = 0xcbf29ce484222325n\nconst FNV_PRIME = 0x100000001b3n\nconst MASK_64 = 0xffffffffffffffffn\n\nfunction fnv1a64(input: string): bigint {\n let hash = FNV_OFFSET\n for (let i = 0; i < input.length; i++) {\n hash ^= BigInt(input.charCodeAt(i))\n hash = (hash * FNV_PRIME) & MASK_64\n }\n return hash\n}\n\nfunction hex64(value: bigint): string {\n return value.toString(16).padStart(16, '0')\n}\n\nfunction randomHex(byteLength: number): string {\n const bytes = new Uint8Array(byteLength)\n globalThis.crypto.getRandomValues(bytes)\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('')\n}\n","/**\n * `@tangle-network/agent-app/trace` — flow observability for agent turns.\n *\n * The turn buffer stamps `_t` (ms since turn start) on every event, so any\n * live stream OR any historical turn replayed from a TurnEventStore can be\n * reconstructed into a span trace: pipeline overhead, model segments (with\n * thinking TTFT), tool executions, token usage, and cost. Renderers turn\n * traces and multi-run samples into ASCII waterfalls and histograms — the\n * default artifact for \"how did this run actually behave\" questions across\n * evals, hill-climbs, and production debugging.\n *\n * Span boundaries derived from a buffered stream are quantized by the\n * pump's flush window and the reader's poll cadence (~100–400ms); spans\n * carry `approx: true` to keep reports honest about that.\n */\n\nexport * from './mission-trace'\nexport * from './flow-types'\nexport * from './mission-flow'\n\nimport type { FlowSpan, FlowTrace } from './flow-types'\n\n/** Represent a timed event with a timestamp and associated event data */\nexport interface TimedEvent {\n /** ms since turn start (`_t` stamped by pumpBufferedTurn). */\n t: number\n event: Record<string, unknown>\n}\n\n/** Parse stored turn-event lines (JSON strings with `_t`) into TimedEvents. */\nexport function timedEventsFromLines(lines: string[]): TimedEvent[] {\n const out: TimedEvent[] = []\n for (const line of lines) {\n try {\n const parsed = JSON.parse(line) as Record<string, unknown>\n if (typeof parsed._t === 'number') out.push({ t: parsed._t, event: parsed })\n } catch {\n /* skip torn lines */\n }\n }\n return out.sort((a, b) => a.t - b.t)\n}\n\nfunction innerOf(e: Record<string, unknown>): Record<string, unknown> {\n return (e.kind === 'event' ? (e.event as Record<string, unknown>) : e) ?? {}\n}\n\n/**\n * Derive a span trace from timestamped turn events. Model segments are runs\n * of text/reasoning deltas; a tool span opens at the last delta before its\n * tool_call emission and closes at the matching tool_result.\n */\nexport function buildFlowTrace(\n events: TimedEvent[],\n opts?: { pricing?: { prompt?: string | number; completion?: string | number } },\n): FlowTrace {\n const spans: FlowSpan[] = []\n let promptTokens = 0\n let completionTokens = 0\n let toolCalls = 0\n\n const first = events[0]?.t ?? 0\n if (first > 0) {\n spans.push({ kind: 'pipeline', name: 'dispatch → first event', startMs: 0, endMs: first })\n }\n\n let segStart: number | null = null\n let segEnd = 0\n let segKinds = new Set<string>()\n let lastDeltaT = first\n const openCalls = new Map<string, { name: string; emitT: number; lastDeltaT: number }>()\n\n const closeSegment = () => {\n if (segStart !== null) {\n spans.push({\n kind: 'model',\n name: segKinds.has('reasoning') ? 'model turn (reasoning + text)' : 'model turn',\n startMs: segStart,\n endMs: segEnd,\n approx: true,\n })\n segStart = null\n segKinds = new Set()\n }\n }\n\n for (const { t, event } of events) {\n const inner = innerOf(event)\n const type = String(event.kind === 'tool_result' ? 'tool_result' : (inner.type ?? ''))\n\n if (type === 'text' || type === 'reasoning') {\n if (segStart === null) segStart = t\n segEnd = t\n segKinds.add(type)\n lastDeltaT = t\n } else if (type === 'tool_call') {\n closeSegment()\n toolCalls++\n const call = (inner.call ?? inner) as Record<string, unknown>\n const id = String(call.toolCallId ?? `call_${toolCalls}`)\n openCalls.set(id, { name: String(call.toolName ?? 'tool'), emitT: t, lastDeltaT })\n } else if (type === 'tool_result') {\n const id = String(event.toolCallId ?? inner.toolCallId ?? '')\n const open = openCalls.get(id)\n if (open) {\n spans.push({\n kind: 'tool',\n name: open.name,\n // Execution happens between the end of the model turn that emitted\n // the call and the result landing in the buffer.\n startMs: open.lastDeltaT,\n endMs: t,\n approx: true,\n meta: { ok: ((event.outcome ?? inner.outcome) as { ok?: boolean } | undefined)?.ok },\n })\n openCalls.delete(id)\n }\n } else if (type === 'usage') {\n const u = (inner.usage ?? {}) as { promptTokens?: number; completionTokens?: number }\n promptTokens += u.promptTokens ?? 0\n completionTokens += u.completionTokens ?? 0\n }\n }\n closeSegment()\n\n const totalMs = events.length ? events[events.length - 1]!.t : 0\n const trace: FlowTrace = { spans, totalMs, promptTokens, completionTokens, toolCalls }\n const p = opts?.pricing\n if (p && (p.prompt != null || p.completion != null)) {\n trace.costUsd = promptTokens * Number(p.prompt ?? 0) + completionTokens * Number(p.completion ?? 0)\n }\n return trace\n}\n\nconst fmtS = (ms: number) => `${(ms / 1000).toFixed(1)}s`\n\n/** ASCII waterfall cascade — the default artifact for explaining a flow. */\nexport function renderWaterfall(trace: FlowTrace, opts?: { width?: number }): string {\n const width = opts?.width ?? 40\n const scale = trace.totalMs > 0 ? width / trace.totalMs : 0\n const lines: string[] = []\n const spans = [...trace.spans].sort((a, b) => a.startMs - b.startMs)\n for (let i = 0; i < spans.length; i++) {\n const s = spans[i]!\n const offset = Math.round(s.startMs * scale)\n const len = Math.max(1, Math.round((s.endMs - s.startMs) * scale))\n const bar = ' '.repeat(offset) + (s.kind === 'tool' ? '▓' : s.kind === 'pipeline' ? '░' : '█').repeat(len)\n const branch = i === spans.length - 1 ? '└─' : '├─'\n const dur = `${fmtS(s.endMs - s.startMs)}${s.approx ? '~' : ''}`\n lines.push(`${fmtS(s.startMs).padStart(7)} ${branch} ${bar.padEnd(width + 2)} ${s.name} (${dur})`)\n }\n const cost = trace.costUsd != null ? ` $${trace.costUsd.toFixed(trace.costUsd < 0.01 ? 6 : 4)}` : ''\n lines.push(\n `${fmtS(trace.totalMs).padStart(7)} ── total · ${trace.promptTokens}p + ${trace.completionTokens}c tok · ${trace.toolCalls} tool calls${cost}`,\n )\n return lines.join('\\n')\n}\n\n/** Summarize key statistics of a numerical distribution including count, min, percentiles, and max */\nexport interface DistributionSummary {\n n: number\n min: number\n p50: number\n p90: number\n max: number\n}\n\n/** Summarize numeric values into a distribution summary including count, min, median, 90th percentile, and max */\nexport function summarize(values: number[]): DistributionSummary {\n const sorted = [...values].sort((a, b) => a - b)\n const q = (p: number) => sorted[Math.min(sorted.length - 1, Math.floor(p * sorted.length))] ?? 0\n return { n: sorted.length, min: sorted[0] ?? 0, p50: q(0.5), p90: q(0.9), max: sorted[sorted.length - 1] ?? 0 }\n}\n\n/** ASCII histogram for multi-run samples (eval latencies, costs, scores). */\nexport function renderHistogram(\n values: number[],\n opts?: { buckets?: number; width?: number; unit?: string; format?: (v: number) => string },\n): string {\n if (!values.length) return '(no samples)'\n const buckets = opts?.buckets ?? 6\n const width = opts?.width ?? 24\n const fmt = opts?.format ?? ((v: number) => `${Math.round(v)}${opts?.unit ?? ''}`)\n const s = summarize(values)\n const lo = s.min\n const hi = s.max === s.min ? s.min + 1 : s.max\n const counts = new Array<number>(buckets).fill(0)\n for (const v of values) {\n counts[Math.min(buckets - 1, Math.floor(((v - lo) / (hi - lo)) * buckets))]!++\n }\n const maxCount = Math.max(...counts)\n const lines = [\n `n=${s.n} min=${fmt(s.min)} p50=${fmt(s.p50)} p90=${fmt(s.p90)} max=${fmt(s.max)}`,\n ]\n for (let i = 0; i < buckets; i++) {\n const a = lo + ((hi - lo) * i) / buckets\n const b = lo + ((hi - lo) * (i + 1)) / buckets\n const bar = '█'.repeat(Math.max(counts[i]! > 0 ? 1 : 0, Math.round((counts[i]! / maxCount) * width)))\n lines.push(`${fmt(a).padStart(8)}-${fmt(b).padEnd(8)} ${bar} ${counts[i]}`)\n }\n return lines.join('\\n')\n}\n"],"mappings":";;;;;;;;AAqCO,SAAS,0BAA0B,WAAyC;AACjF,MAAI,cAAc,UAAa,cAAc,IAAI;AAC/C,WAAO;AAAA,MACL,SAAS,MAAM,QAAQ,iBAAiB,SAAS,EAAE,CAAC,IAAI,MAAM,QAAQ,mBAAmB,SAAS,EAAE,CAAC;AAAA,MACrG,YAAY,MAAM,QAAQ,qBAAqB,SAAS,EAAE,CAAC;AAAA,IAC7D;AAAA,EACF;AACA,SAAO,EAAE,SAAS,UAAU,EAAE,GAAG,YAAY,UAAU,CAAC,EAAE;AAC5D;AAQO,SAAS,iBACd,QACA,MACiB;AACjB,QAAM,eAAe,gBAAgB,SAAS,OAAO,aAAa,OAAO;AACzE,QAAM,SACJ,SAAS,UAAa,SAAS,KAC3B,MAAM,QAAQ,QAAQ,OAAO,OAAO,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC,IAC/D,UAAU,CAAC;AACjB,SAAO,EAAE,SAAS,OAAO,SAAS,QAAQ,aAAa;AACzD;AAQO,SAAS,SAAS,KAGvB;AACA,SAAO;AAAA,IACL,UAAU,IAAI;AAAA,IACd,gBAAgB,gBAAgB,MAAM,IAAI,aAAa,IAAI;AAAA,EAC7D;AACF;AAKA,IAAM,aAAa;AACnB,IAAM,YAAY;AAClB,IAAM,UAAU;AAEhB,SAAS,QAAQ,OAAuB;AACtC,MAAI,OAAO;AACX,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,YAAQ,OAAO,MAAM,WAAW,CAAC,CAAC;AAClC,WAAQ,OAAO,YAAa;AAAA,EAC9B;AACA,SAAO;AACT;AAEA,SAAS,MAAM,OAAuB;AACpC,SAAO,MAAM,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Z,KAAK,EAAE,CAAC,SAAS,IAAI,EAAE,GAAG,CAAC,SAAS,IAAI,EAAE,GAAG,CAAC,SAAS,IAAI,EAAE,GAAG,CAAC,SAAS,IAAI,EAAE,GAAG,CAAC;AAAA,EACtF;AACA,WAAS,IAAI,GAAG,IAAI,SAAS,KAAK;AAChC,UAAM,IAAI,MAAO,KAAK,MAAM,IAAK;AACjC,UAAM,IAAI,MAAO,KAAK,OAAO,IAAI,KAAM;AACvC,UAAM,MAAM,SAAI,OAAO,KAAK,IAAI,OAAO,CAAC,IAAK,IAAI,IAAI,GAAG,KAAK,MAAO,OAAO,CAAC,IAAK,WAAY,KAAK,CAAC,CAAC;AACpG,UAAM,KAAK,GAAG,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE;AAAA,EAC5E;AACA,SAAO,MAAM,KAAK,IAAI;AACxB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/trace/mission-trace.ts","../../src/trace/index.ts"],"sourcesContent":["/**\n * Mission trace context — mint + thread the trace ids that join a mission's\n * step attempts and its delegated agent runs into ONE trace tree.\n *\n * ID formats are byte-compatible with agent-runtime's trace propagation\n * (`readTraceContextFromEnv` / OTLP export): 32 lowercase hex chars for a\n * trace id (16 bytes), 16 for a span id (8 bytes). The env pair from\n * {@link traceEnv} is exactly what agent-runtime's MCP subprocess reads at\n * startup (`TRACE_ID` + `PARENT_SPAN_ID`), so a delegation dispatched with it\n * parents its loop→round→iteration spans under the mission's step span.\n *\n * Pure functions, no deps. Ids are DETERMINISTIC when a key is supplied\n * (missionId / step-attempt seed) so a crashed driver re-mints the identical\n * context on re-dispatch and the re-run joins the same trace instead of\n * forking a new one; without a key they are random.\n */\n\nexport interface MissionTraceContext {\n /** 32-hex trace id shared by every span in the mission's tree. */\n traceId: string\n /** 16-hex span id of the mission root — the parent of every step span. */\n rootSpanId: string\n}\n\n/** Define context information for a step span including trace, span, and parent span identifiers */\nexport interface StepSpanContext {\n traceId: string\n /** 16-hex span id of this step attempt (or any nested unit of work). */\n spanId: string\n /** The span this one nests under. */\n parentSpanId: string\n}\n\n/**\n * Mint a mission's trace context. With `missionId` the ids are a pure\n * function of it; omitted, both ids are random.\n */\nexport function createMissionTraceContext(missionId?: string): MissionTraceContext {\n if (missionId !== undefined && missionId !== '') {\n return {\n traceId: hex64(fnv1a64(`mission-trace:${missionId}`)) + hex64(fnv1a64(`mission-trace:2:${missionId}`)),\n rootSpanId: hex64(fnv1a64(`mission-root-span:${missionId}`)),\n }\n }\n return { traceId: randomHex(16), rootSpanId: randomHex(8) }\n}\n\n/**\n * Derive a child span context under `parent` — one per step attempt (seed\n * e.g. `\"${stepId}#${attempt}\"`), or nested under another step span. With a\n * seed the span id is deterministic for the same parent + seed; omitted, it\n * is random.\n */\nexport function childSpanContext(\n parent: MissionTraceContext | StepSpanContext,\n seed?: string,\n): StepSpanContext {\n const parentSpanId = 'rootSpanId' in parent ? parent.rootSpanId : parent.spanId\n const spanId =\n seed !== undefined && seed !== ''\n ? hex64(fnv1a64(`span:${parent.traceId}:${parentSpanId}:${seed}`))\n : randomHex(8)\n return { traceId: parent.traceId, spanId, parentSpanId }\n}\n\n/**\n * The env pair a delegation subprocess inherits — agent-runtime's\n * `readTraceContextFromEnv` reads exactly these names. `PARENT_SPAN_ID` is\n * the span the dispatched work nests under: the root for a mission context,\n * the step-attempt span for a step context.\n */\nexport function traceEnv(ctx: MissionTraceContext | StepSpanContext): {\n TRACE_ID: string\n PARENT_SPAN_ID: string\n} {\n return {\n TRACE_ID: ctx.traceId,\n PARENT_SPAN_ID: 'rootSpanId' in ctx ? ctx.rootSpanId : ctx.spanId,\n }\n}\n\n// FNV-1a 64-bit over UTF-16 code units — a stable, dependency-free digest for\n// deterministic ids. Not cryptographic; trace ids only need uniqueness within\n// a tenant's missions, not unforgeability.\nconst FNV_OFFSET = 0xcbf29ce484222325n\nconst FNV_PRIME = 0x100000001b3n\nconst MASK_64 = 0xffffffffffffffffn\n\nfunction fnv1a64(input: string): bigint {\n let hash = FNV_OFFSET\n for (let i = 0; i < input.length; i++) {\n hash ^= BigInt(input.charCodeAt(i))\n hash = (hash * FNV_PRIME) & MASK_64\n }\n return hash\n}\n\nfunction hex64(value: bigint): string {\n return value.toString(16).padStart(16, '0')\n}\n\nfunction randomHex(byteLength: number): string {\n const bytes = new Uint8Array(byteLength)\n globalThis.crypto.getRandomValues(bytes)\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('')\n}\n","/**\n * `@tangle-network/agent-app/trace` — flow observability for agent turns.\n *\n * The turn buffer stamps `_t` (ms since turn start) on every event, so any\n * live stream OR any historical turn replayed from a TurnEventStore can be\n * reconstructed into a span trace: pipeline overhead, model segments (with\n * thinking TTFT), tool executions, token usage, and cost. Renderers turn\n * traces and multi-run samples into ASCII waterfalls and histograms — the\n * default artifact for \"how did this run actually behave\" questions across\n * evals, hill-climbs, and production debugging.\n *\n * Span boundaries derived from a buffered stream are quantized by the\n * pump's flush window and the reader's poll cadence (~100–400ms); spans\n * carry `approx: true` to keep reports honest about that.\n */\n\nexport * from './mission-trace'\nexport * from './flow-types'\nexport * from './mission-flow'\n\nimport type { FlowSpan, FlowTrace } from './flow-types'\n\n/** Represent a timed event with a timestamp and associated event data */\nexport interface TimedEvent {\n /** ms since turn start (`_t` stamped by pumpBufferedTurn). */\n t: number\n event: Record<string, unknown>\n}\n\n/** Parse stored turn-event lines (JSON strings with `_t`) into TimedEvents. */\nexport function timedEventsFromLines(lines: string[]): TimedEvent[] {\n const out: TimedEvent[] = []\n for (const line of lines) {\n try {\n const parsed = JSON.parse(line) as Record<string, unknown>\n if (typeof parsed._t === 'number') out.push({ t: parsed._t, event: parsed })\n } catch {\n /* skip torn lines */\n }\n }\n return out.sort((a, b) => a.t - b.t)\n}\n\nfunction innerOf(e: Record<string, unknown>): Record<string, unknown> {\n return (e.kind === 'event' ? (e.event as Record<string, unknown>) : e) ?? {}\n}\n\n/**\n * Derive a span trace from timestamped turn events. Model segments are runs\n * of text/reasoning deltas; a tool span opens at the last delta before its\n * tool_call emission and closes at the matching tool_result.\n */\nexport function buildFlowTrace(\n events: TimedEvent[],\n opts?: { pricing?: { prompt?: string | number; completion?: string | number }; running?: boolean },\n): FlowTrace {\n const spans: FlowSpan[] = []\n let promptTokens = 0\n let completionTokens = 0\n let toolCalls = 0\n\n const first = events[0]?.t ?? 0\n if (first > 0) {\n spans.push({ kind: 'pipeline', name: 'dispatch → first event', startMs: 0, endMs: first })\n }\n\n let segStart: number | null = null\n let segEnd = 0\n let segKinds = new Set<string>()\n let lastDeltaT = first\n const openCalls = new Map<string, { name: string; emitT: number; lastDeltaT: number }>()\n\n const closeSegment = () => {\n if (segStart !== null) {\n spans.push({\n kind: 'model',\n name: segKinds.has('reasoning') ? 'model turn (reasoning + text)' : 'model turn',\n startMs: segStart,\n endMs: segEnd,\n approx: true,\n })\n segStart = null\n segKinds = new Set()\n }\n }\n\n for (const { t, event } of events) {\n const inner = innerOf(event)\n const type = String(event.kind === 'tool_result' ? 'tool_result' : (inner.type ?? ''))\n\n if (type === 'text' || type === 'reasoning') {\n if (segStart === null) segStart = t\n segEnd = t\n segKinds.add(type)\n lastDeltaT = t\n } else if (type === 'tool_call') {\n closeSegment()\n toolCalls++\n const call = (inner.call ?? inner) as Record<string, unknown>\n const id = String(call.toolCallId ?? `call_${toolCalls}`)\n openCalls.set(id, { name: String(call.toolName ?? 'tool'), emitT: t, lastDeltaT })\n } else if (type === 'tool_result') {\n const id = String(event.toolCallId ?? inner.toolCallId ?? '')\n const open = openCalls.get(id)\n if (open) {\n spans.push({\n kind: 'tool',\n id: id,\n name: open.name,\n // Execution happens between the end of the model turn that emitted\n // the call and the result landing in the buffer.\n startMs: open.lastDeltaT,\n endMs: t,\n approx: true,\n meta: { ok: ((event.outcome ?? inner.outcome) as { ok?: boolean } | undefined)?.ok },\n })\n openCalls.delete(id)\n }\n } else if (type === 'usage') {\n const u = (inner.usage ?? {}) as { promptTokens?: number; completionTokens?: number }\n promptTokens += u.promptTokens ?? 0\n completionTokens += u.completionTokens ?? 0\n }\n }\n closeSegment()\n\n const totalMs = events.length ? events[events.length - 1]!.t : 0\n for (const [id, open] of openCalls) {\n spans.push({ id, kind: 'tool', name: open.name, startMs: open.lastDeltaT,\n endMs: totalMs, status: opts?.running ? 'running' : undefined, approx: true })\n }\n if (opts?.running && spans.at(-1)?.kind === 'model') spans.at(-1)!.status = 'running'\n const trace: FlowTrace = { spans, totalMs, promptTokens, completionTokens, toolCalls }\n const p = opts?.pricing\n if (p && (p.prompt != null || p.completion != null)) {\n trace.costUsd = promptTokens * Number(p.prompt ?? 0) + completionTokens * Number(p.completion ?? 0)\n }\n return trace\n}\n\nconst fmtS = (ms: number) => `${(ms / 1000).toFixed(1)}s`\n\n/** ASCII waterfall cascade — the default artifact for explaining a flow. */\nexport function renderWaterfall(trace: FlowTrace, opts?: { width?: number }): string {\n const width = opts?.width ?? 40\n const scale = trace.totalMs > 0 ? width / trace.totalMs : 0\n const lines: string[] = []\n const spans = [...trace.spans].sort((a, b) => a.startMs - b.startMs)\n for (let i = 0; i < spans.length; i++) {\n const s = spans[i]!\n const offset = Math.round(s.startMs * scale)\n const len = Math.max(1, Math.round((s.endMs - s.startMs) * scale))\n const bar = ' '.repeat(offset) + (s.kind === 'tool' ? '▓' : s.kind === 'pipeline' ? '░' : '█').repeat(len)\n const branch = i === spans.length - 1 ? '└─' : '├─'\n const dur = `${fmtS(s.endMs - s.startMs)}${s.approx ? '~' : ''}`\n lines.push(`${fmtS(s.startMs).padStart(7)} ${branch} ${bar.padEnd(width + 2)} ${s.name} (${dur})`)\n }\n const cost = trace.costUsd != null ? ` $${trace.costUsd.toFixed(trace.costUsd < 0.01 ? 6 : 4)}` : ''\n lines.push(\n `${fmtS(trace.totalMs).padStart(7)} ── total · ${trace.promptTokens}p + ${trace.completionTokens}c tok · ${trace.toolCalls} tool calls${cost}`,\n )\n return lines.join('\\n')\n}\n\n/** Summarize key statistics of a numerical distribution including count, min, percentiles, and max */\nexport interface DistributionSummary {\n n: number\n min: number\n p50: number\n p90: number\n max: number\n}\n\n/** Summarize numeric values into a distribution summary including count, min, median, 90th percentile, and max */\nexport function summarize(values: number[]): DistributionSummary {\n const sorted = [...values].sort((a, b) => a - b)\n const q = (p: number) => sorted[Math.min(sorted.length - 1, Math.floor(p * sorted.length))] ?? 0\n return { n: sorted.length, min: sorted[0] ?? 0, p50: q(0.5), p90: q(0.9), max: sorted[sorted.length - 1] ?? 0 }\n}\n\n/** ASCII histogram for multi-run samples (eval latencies, costs, scores). */\nexport function renderHistogram(\n values: number[],\n opts?: { buckets?: number; width?: number; unit?: string; format?: (v: number) => string },\n): string {\n if (!values.length) return '(no samples)'\n const buckets = opts?.buckets ?? 6\n const width = opts?.width ?? 24\n const fmt = opts?.format ?? ((v: number) => `${Math.round(v)}${opts?.unit ?? ''}`)\n const s = summarize(values)\n const lo = s.min\n const hi = s.max === s.min ? s.min + 1 : s.max\n const counts = new Array<number>(buckets).fill(0)\n for (const v of values) {\n counts[Math.min(buckets - 1, Math.floor(((v - lo) / (hi - lo)) * buckets))]!++\n }\n const maxCount = Math.max(...counts)\n const lines = [\n `n=${s.n} min=${fmt(s.min)} p50=${fmt(s.p50)} p90=${fmt(s.p90)} max=${fmt(s.max)}`,\n ]\n for (let i = 0; i < buckets; i++) {\n const a = lo + ((hi - lo) * i) / buckets\n const b = lo + ((hi - lo) * (i + 1)) / buckets\n const bar = '█'.repeat(Math.max(counts[i]! > 0 ? 1 : 0, Math.round((counts[i]! / maxCount) * width)))\n lines.push(`${fmt(a).padStart(8)}-${fmt(b).padEnd(8)} ${bar} ${counts[i]}`)\n }\n return lines.join('\\n')\n}\n"],"mappings":";;;;;;;;AAqCO,SAAS,0BAA0B,WAAyC;AACjF,MAAI,cAAc,UAAa,cAAc,IAAI;AAC/C,WAAO;AAAA,MACL,SAAS,MAAM,QA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;AACnC,QAAM,QAAQ;AAAA,IACZ,KAAK,EAAE,CAAC,SAAS,IAAI,EAAE,GAAG,CAAC,SAAS,IAAI,EAAE,GAAG,CAAC,SAAS,IAAI,EAAE,GAAG,CAAC,SAAS,IAAI,EAAE,GAAG,CAAC;AAAA,EACtF;AACA,WAAS,IAAI,GAAG,IAAI,SAAS,KAAK;AAChC,UAAM,IAAI,MAAO,KAAK,MAAM,IAAK;AACjC,UAAM,IAAI,MAAO,KAAK,OAAO,IAAI,KAAM;AACvC,UAAM,MAAM,SAAI,OAAO,KAAK,IAAI,OAAO,CAAC,IAAK,IAAI,IAAI,GAAG,KAAK,MAAO,OAAO,CAAC,IAAK,WAAY,KAAK,CAAC,CAAC;AACpG,UAAM,KAAK,GAAG,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE;AAAA,EAC5E;AACA,SAAO,MAAM,KAAK,IAAI;AACxB;","names":[]}
|
|
@@ -9,9 +9,8 @@
|
|
|
9
9
|
* available live, from the step's journaled lane.
|
|
10
10
|
* - FINE: `loopTraceEventsToFlowSpans` reconstructs agent-runtime's
|
|
11
11
|
* loop → round → iteration hierarchy from the LoopTraceEvent journal a
|
|
12
|
-
* delegation persists.
|
|
13
|
-
*
|
|
14
|
-
* waterfall reads.
|
|
12
|
+
* delegation persists. Stable ids carry the hierarchy; descriptive names
|
|
13
|
+
* retain context in the ASCII waterfall as well.
|
|
15
14
|
*
|
|
16
15
|
* `composeMissionFlowTrace` lays a whole mission out: one 'pipeline' span per
|
|
17
16
|
* step, each step's delegations beneath it. Pure data transforms — the
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
reconcileStaleTurnLock
|
|
3
3
|
} from "../chunk-CCVWR33L.js";
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_RUNNING_TURN_LEASE_MS
|
|
6
|
+
} from "../chunk-ISP6ZH3G.js";
|
|
4
7
|
import {
|
|
5
8
|
base64UrlEncodeText,
|
|
6
9
|
constantTimeEqual,
|
|
7
10
|
hmacSha256Base64Url
|
|
8
11
|
} from "../chunk-S5SRJJQG.js";
|
|
9
|
-
import {
|
|
10
|
-
DEFAULT_RUNNING_TURN_LEASE_MS
|
|
11
|
-
} from "../chunk-ISP6ZH3G.js";
|
|
12
12
|
|
|
13
13
|
// src/turn-stream/core.ts
|
|
14
14
|
var TURN_STREAM_TOKEN_TTL_MS = 6e4;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FlowSpan, FlowTrace } from '../trace/flow-types';
|
|
2
|
+
export interface WaterfallRow {
|
|
3
|
+
id: string;
|
|
4
|
+
parentId?: string;
|
|
5
|
+
name: string;
|
|
6
|
+
kind: FlowSpan['kind'];
|
|
7
|
+
offsetPct: number;
|
|
8
|
+
widthPct: number;
|
|
9
|
+
durationLabel: string;
|
|
10
|
+
approx: boolean;
|
|
11
|
+
ok: boolean;
|
|
12
|
+
depth: number;
|
|
13
|
+
hasChildren: boolean;
|
|
14
|
+
span: FlowSpan;
|
|
15
|
+
}
|
|
16
|
+
export declare function spanFailed(span: FlowSpan): boolean;
|
|
17
|
+
export declare function spanRunning(span: FlowSpan): boolean;
|
|
18
|
+
/** One geometry owner for the web surface and its established public helper.
|
|
19
|
+
* Orphaned parents become roots; cycles are broken without dropping any span. */
|
|
20
|
+
export declare function waterfallLayout(trace: FlowTrace): WaterfallRow[];
|
|
21
|
+
/** Search keeps ancestor context and deliberately reveals matches inside collapsed branches. */
|
|
22
|
+
export declare function visibleWaterfallRows(rows: WaterfallRow[], query: string, collapsed: Set<string>): WaterfallRow[];
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/* Standalone surface: consumes Brand/Agent App tokens; no Tailwind build required. */
|
|
2
|
+
.fw-root {
|
|
3
|
+
--fw-text: var(--text-primary, hsl(var(--foreground)));
|
|
4
|
+
--fw-muted: var(--text-muted, hsl(var(--muted-foreground)));
|
|
5
|
+
--fw-surface: var(--bg-card, hsl(var(--background)));
|
|
6
|
+
--fw-border: var(--border-default, hsl(var(--border)));
|
|
7
|
+
--fw-well: var(--md3-surface-container, hsl(var(--secondary)));
|
|
8
|
+
--fw-accent: var(--accent-text, hsl(var(--primary)));
|
|
9
|
+
color: var(--fw-text);
|
|
10
|
+
background: var(--fw-surface);
|
|
11
|
+
border: 1px solid var(--fw-border);
|
|
12
|
+
border-radius: var(--radius-lg, .75rem);
|
|
13
|
+
min-width: 0;
|
|
14
|
+
font: inherit;
|
|
15
|
+
font-size: .8125rem;
|
|
16
|
+
line-height: 1.5;
|
|
17
|
+
}
|
|
18
|
+
.fw-root *, .fw-root *::before, .fw-root *::after { box-sizing: border-box; }
|
|
19
|
+
.fw-root :is(p, dl, dd) { margin: 0; }
|
|
20
|
+
.fw-root .fw-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding: .75rem; border-bottom: 1px solid var(--fw-border); }
|
|
21
|
+
.fw-root .fw-title { display: flex; align-items: center; gap: .5rem; font-weight: 600; font-size: .875rem; }
|
|
22
|
+
.fw-root .fw-search { display: flex; min-width: 0; gap: .25rem; align-items: center; }
|
|
23
|
+
.fw-root .fw-control { appearance: auto; font: inherit; font-size: .75rem; line-height: 1.4; min-height: 2rem; padding: .25rem .5rem; border: 1px solid var(--fw-border); border-radius: var(--radius-sm, .375rem); color: var(--fw-text); background: var(--fw-surface); cursor: pointer; }
|
|
24
|
+
.fw-root .fw-control:hover, .fw-root .fw-toggle:hover { background: var(--fw-well); }
|
|
25
|
+
.fw-root :is(button, input, select, [tabindex]):focus-visible { outline: 2px solid var(--fw-accent); outline-offset: 2px; }
|
|
26
|
+
.fw-root :is(button, input):disabled { opacity: .5; cursor: default; }
|
|
27
|
+
.fw-root .fw-search-input { width: 10rem; min-width: 0; cursor: text; }
|
|
28
|
+
.fw-root .fw-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem 1rem; padding: .75rem; border-bottom: 1px solid var(--fw-border); }
|
|
29
|
+
.fw-root .fw-muted { color: var(--fw-muted); font-size: .75rem; }
|
|
30
|
+
.fw-root .fw-value { margin-top: .125rem; font-family: var(--font-mono, monospace); font-size: .875rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
|
|
31
|
+
.fw-root .fw-legend { display: flex; flex-wrap: wrap; gap: .25rem .75rem; padding: .5rem .75rem; border-bottom: 1px solid var(--fw-border); color: var(--fw-muted); font-size: .75rem; }
|
|
32
|
+
.fw-root .fw-legend-item { display: inline-flex; align-items: center; gap: .25rem; }
|
|
33
|
+
.fw-root .fw-dot { width: .375rem; height: .375rem; border-radius: 50%; }
|
|
34
|
+
.fw-root .fw-orchestrator { background: var(--fw-muted); }
|
|
35
|
+
.fw-root .fw-model { background: var(--chart-accent, hsl(var(--primary))); }
|
|
36
|
+
.fw-root .fw-tool { background: var(--status-cold, hsl(var(--accent))); }
|
|
37
|
+
.fw-root .fw-waiting { background: var(--status-stopped, hsl(var(--warning-strong))); }
|
|
38
|
+
.fw-root .fw-handoff { background: var(--status-running, hsl(var(--success))); }
|
|
39
|
+
.fw-root .fw-failed { background: var(--status-error, hsl(var(--destructive))); }
|
|
40
|
+
.fw-root .fw-branches { display: flex; gap: .5rem; padding: .5rem .75rem 0; }
|
|
41
|
+
.fw-root .fw-timeline { overflow-x: auto; padding: .75rem; }
|
|
42
|
+
.fw-root .fw-track { min-width: 480px; }
|
|
43
|
+
.fw-root .fw-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) 70px; align-items: center; gap: .5rem; }
|
|
44
|
+
.fw-root .fw-axis { padding-bottom: .5rem; color: var(--fw-muted); font-size: .75rem; }
|
|
45
|
+
.fw-root .fw-ticks { display: flex; justify-content: space-between; font-family: var(--font-mono, monospace); font-variant-numeric: tabular-nums; }
|
|
46
|
+
.fw-root .fw-align-right { text-align: right; }
|
|
47
|
+
.fw-root .fw-empty { padding: 2rem .5rem; text-align: center; color: var(--fw-muted); font-size: .875rem; }
|
|
48
|
+
.fw-root .fw-row { border-radius: .25rem; padding: .375rem 0; }
|
|
49
|
+
.fw-root .fw-slowest { background: var(--fw-well); outline: 1px solid var(--fw-border); }
|
|
50
|
+
.fw-root .fw-pending { opacity: .4; }
|
|
51
|
+
.fw-root .fw-name { display: flex; align-items: center; min-width: 0; }
|
|
52
|
+
.fw-root .fw-toggle { appearance: none; width: 1.5rem; height: 1.5rem; margin-right: .25rem; flex-shrink: 0; border: 0; border-radius: .25rem; background: transparent; color: var(--fw-text); font: inherit; cursor: pointer; }
|
|
53
|
+
.fw-root .fw-leaf { margin-right: .25rem; width: 1.5rem; flex-shrink: 0; text-align: center; color: var(--fw-muted); }
|
|
54
|
+
.fw-root .fw-span-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .75rem; }
|
|
55
|
+
.fw-root .fw-error-text { color: var(--text-danger, var(--status-error)); }
|
|
56
|
+
.fw-root .fw-bar-track { position: relative; height: 1rem; overflow: hidden; border-radius: .125rem; background: var(--fw-well); }
|
|
57
|
+
.fw-root .fw-bar { position: absolute; top: 0; bottom: 0; border-radius: .125rem; }
|
|
58
|
+
.fw-root .fw-approx { opacity: .7; }
|
|
59
|
+
.fw-root .fw-playhead { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--fw-text); }
|
|
60
|
+
.fw-root .fw-duration { padding-right: .25rem; text-align: right; font-family: var(--font-mono, monospace); font-size: .75rem; font-variant-numeric: tabular-nums; }
|
|
61
|
+
.fw-root .fw-slowest-caption { padding: 0 .75rem .5rem; color: var(--fw-muted); font-size: .75rem; overflow-wrap: anywhere; }
|
|
62
|
+
.fw-root .fw-text { color: var(--fw-text); }
|
|
63
|
+
.fw-root .fw-playback { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; border-top: 1px solid var(--fw-border); padding: .75rem; }
|
|
64
|
+
.fw-root .fw-speed, .fw-root .fw-position { display: flex; align-items: center; gap: .25rem; color: var(--fw-muted); font-size: .75rem; }
|
|
65
|
+
.fw-root .fw-position { flex: 1; min-width: 6rem; gap: .5rem; }
|
|
66
|
+
.fw-root .fw-slider { min-width: 0; flex: 1; accent-color: var(--fw-accent); }
|
|
67
|
+
.fw-root .fw-time { font-family: var(--font-mono, monospace); font-size: .75rem; font-variant-numeric: tabular-nums; color: var(--fw-muted); }
|
|
68
|
+
.fw-root .fw-sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
|
|
69
|
+
@media (max-width: 480px) {
|
|
70
|
+
.fw-root .fw-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
71
|
+
.fw-root .fw-position { flex-basis: 100%; }
|
|
72
|
+
}
|