@tangle-network/agent-app 0.63.60 → 0.63.62
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/{DesignCanvas-Q65UV4D5.js → DesignCanvas-566V5KVC.js} +3 -2
- package/dist/{DesignCanvasEditor-THEFESEX.js → DesignCanvasEditor-6XNHSREG.js} +5 -4
- package/dist/agent-profiles/d1.js +3 -3
- package/dist/agent-profiles/index.js +3 -3
- package/dist/app-auth/index.js +2 -1
- package/dist/app-auth/index.js.map +1 -1
- package/dist/assistant/index.js +6 -5
- package/dist/assistant/index.js.map +1 -1
- package/dist/chat-react/index.js +3 -3
- package/dist/chat-routes/agent-producers.d.ts +39 -0
- package/dist/chat-routes/dispatch-parts.d.ts +24 -2
- package/dist/chat-routes/hybrid-producer.d.ts +6 -2
- package/dist/chat-routes/index.d.ts +1 -0
- package/dist/chat-routes/index.js +31 -12
- package/dist/chat-routes/index.js.map +1 -1
- package/dist/chat-routes/turn-admission.d.ts +3 -3
- package/dist/chat-routes/turn-route-contracts.d.ts +39 -1
- package/dist/chat-routes/wire.d.ts +35 -4
- package/dist/chat-store/index.js +4 -2
- package/dist/chat-store/index.js.map +1 -1
- package/dist/chat-store/parts.d.ts +19 -3
- package/dist/{chunk-6XSQCP6W.js → chunk-43CV4JIT.js} +2 -2
- package/dist/{chunk-SFZELD6V.js → chunk-4JTEPK2G.js} +2 -2
- package/dist/{chunk-RILVJYXJ.js → chunk-5ERXADSW.js} +2 -2
- package/dist/{chunk-LAZCUQFZ.js → chunk-73AVOSH6.js} +179 -86
- package/dist/chunk-73AVOSH6.js.map +1 -0
- package/dist/{chunk-HHPQMFKP.js → chunk-7O62NYGT.js} +2 -2
- package/dist/{chunk-GGJYAV7R.js → chunk-AHBVQRJA.js} +2 -2
- package/dist/{chunk-GGJYAV7R.js.map → chunk-AHBVQRJA.js.map} +1 -1
- package/dist/{chunk-UTF7H6BK.js → chunk-EUQ46YWK.js} +15 -15
- package/dist/chunk-EUQ46YWK.js.map +1 -0
- package/dist/{chunk-PIGW5LRM.js → chunk-FJRQCF43.js} +3 -3
- package/dist/{chunk-AICYKYYF.js → chunk-GAYWV565.js} +17 -4
- package/dist/chunk-GAYWV565.js.map +1 -0
- package/dist/{chunk-5C3RXQQ7.js → chunk-H3DAXUKV.js} +2 -2
- package/dist/{chunk-SRA7VAVK.js → chunk-HJYEK4SU.js} +2 -2
- package/dist/{chunk-P7UB7ZVP.js → chunk-IAK227OO.js} +2 -2
- package/dist/{chunk-QGJOT6R6.js → chunk-K2JPSXKI.js} +54 -9
- package/dist/{chunk-QGJOT6R6.js.map → chunk-K2JPSXKI.js.map} +1 -1
- package/dist/{chunk-QFIVY6WA.js → chunk-NJW4JCSF.js} +2 -2
- package/dist/{chunk-IDQ7N36R.js → chunk-Q55WW6DO.js} +15 -15
- package/dist/{chunk-H6BRJU5M.js → chunk-RKNNMC6T.js} +1 -1
- package/dist/{chunk-KFO5R4SN.js → chunk-RYKANV3P.js} +945 -801
- package/dist/chunk-RYKANV3P.js.map +1 -0
- package/dist/{chunk-4E2MUVGL.js → chunk-VQIH5NAB.js} +3 -3
- package/dist/chunk-XBBXPZJI.js +47 -0
- package/dist/chunk-XBBXPZJI.js.map +1 -0
- package/dist/{chunk-DCGATWZ5.js → chunk-XPB2UYHU.js} +5 -5
- package/dist/{chunk-DCGATWZ5.js.map → chunk-XPB2UYHU.js.map} +1 -1
- package/dist/design-canvas/index.js +2 -1
- package/dist/design-canvas/index.js.map +1 -1
- package/dist/design-canvas-react/engine.js +2 -1
- package/dist/design-canvas-react/index.js +5 -4
- package/dist/design-canvas-react/index.js.map +1 -1
- package/dist/design-canvas-react/lazy.js +1 -1
- package/dist/operator/index.js +2 -2
- package/dist/platform/index.js +2 -1
- package/dist/platform/index.js.map +1 -1
- package/dist/preset-cloudflare/index.js +6 -6
- package/dist/public-consultation/index.d.ts +2 -2
- package/dist/public-consultation/index.js +11 -10
- package/dist/public-consultation/index.js.map +1 -1
- package/dist/sandbox/index.js +6 -6
- package/dist/sequences/index.js +2 -1
- package/dist/sequences/index.js.map +1 -1
- package/dist/stories/chat/fixtures.d.ts +4 -0
- package/dist/theme/brand.generated.d.ts +15 -15
- package/dist/theme/dom.js +2 -2
- package/dist/theme/index.js +1 -1
- package/dist/theme/tokens.css +210 -356
- package/dist/tools/index.js +4 -4
- package/dist/web/index.d.ts +1 -0
- package/dist/web/index.js +7 -1
- package/dist/web/speakers.d.ts +30 -0
- package/dist/web-react/chat-messages.d.ts +1 -1
- package/dist/web-react/chat-stream.d.ts +7 -0
- package/dist/web-react/document.js +2 -2
- package/dist/web-react/entry-composer.d.ts +2 -2
- package/dist/web-react/index.d.ts +3 -0
- package/dist/web-react/index.js +18 -5
- package/dist/web-react/message-projection.d.ts +19 -0
- package/dist/web-react/use-file-mentions.d.ts +23 -4
- package/dist/work-product/index.js +2 -2
- package/dist/workspace-react/index.d.ts +29 -1
- package/dist/workspace-react/index.js +34 -0
- package/dist/workspace-react/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-AICYKYYF.js.map +0 -1
- package/dist/chunk-KFO5R4SN.js.map +0 -1
- package/dist/chunk-LAZCUQFZ.js.map +0 -1
- package/dist/chunk-UTF7H6BK.js.map +0 -1
- /package/dist/{DesignCanvas-Q65UV4D5.js.map → DesignCanvas-566V5KVC.js.map} +0 -0
- /package/dist/{DesignCanvasEditor-THEFESEX.js.map → DesignCanvasEditor-6XNHSREG.js.map} +0 -0
- /package/dist/{chunk-6XSQCP6W.js.map → chunk-43CV4JIT.js.map} +0 -0
- /package/dist/{chunk-SFZELD6V.js.map → chunk-4JTEPK2G.js.map} +0 -0
- /package/dist/{chunk-RILVJYXJ.js.map → chunk-5ERXADSW.js.map} +0 -0
- /package/dist/{chunk-HHPQMFKP.js.map → chunk-7O62NYGT.js.map} +0 -0
- /package/dist/{chunk-PIGW5LRM.js.map → chunk-FJRQCF43.js.map} +0 -0
- /package/dist/{chunk-5C3RXQQ7.js.map → chunk-H3DAXUKV.js.map} +0 -0
- /package/dist/{chunk-SRA7VAVK.js.map → chunk-HJYEK4SU.js.map} +0 -0
- /package/dist/{chunk-P7UB7ZVP.js.map → chunk-IAK227OO.js.map} +0 -0
- /package/dist/{chunk-QFIVY6WA.js.map → chunk-NJW4JCSF.js.map} +0 -0
- /package/dist/{chunk-IDQ7N36R.js.map → chunk-Q55WW6DO.js.map} +0 -0
- /package/dist/{chunk-H6BRJU5M.js.map → chunk-RKNNMC6T.js.map} +0 -0
- /package/dist/{chunk-4E2MUVGL.js.map → chunk-VQIH5NAB.js.map} +0 -0
|
@@ -15,31 +15,31 @@ var brandThemes = {
|
|
|
15
15
|
"mutedForeground": "0 0% 29.8039%",
|
|
16
16
|
"accent": "230 27% 96%",
|
|
17
17
|
"accentForeground": "0 0% 17.6471%",
|
|
18
|
-
"destructive": "0 73.
|
|
18
|
+
"destructive": "0 73.7% 41.8%",
|
|
19
19
|
"destructiveForeground": "0 0% 100%",
|
|
20
20
|
"border": "244 16% 81%",
|
|
21
21
|
"input": "0 0% 29.8039%",
|
|
22
22
|
"ring": "246 54% 51%",
|
|
23
|
-
"success": "162.
|
|
24
|
-
"warning": "
|
|
23
|
+
"success": "162.9 93.5% 24.3%",
|
|
24
|
+
"warning": "25.9 90% 35.3%",
|
|
25
25
|
"successForeground": "0 0% 100%",
|
|
26
|
-
"warningForeground": "0 0%
|
|
27
|
-
"warningStrong": "25.
|
|
26
|
+
"warningForeground": "0 0% 100%",
|
|
27
|
+
"warningStrong": "25.9 90% 35.3%",
|
|
28
28
|
"inputFill": "hsl(225 29% 97%)",
|
|
29
29
|
"canvasBackdrop": "#dcdee6",
|
|
30
30
|
"borderSoft": "rgba(0, 0, 0, 0.10)",
|
|
31
31
|
"cardEdge": "rgba(0, 0, 0, 0.14)",
|
|
32
32
|
"canvasRender": {
|
|
33
|
-
"grid": "#
|
|
33
|
+
"grid": "#c8c7d6",
|
|
34
34
|
"snapGrid": "#787878",
|
|
35
35
|
"snapGuide": "#0369a1",
|
|
36
36
|
"snapPage": "#ab4f09",
|
|
37
37
|
"snapElement": "#b91c1c",
|
|
38
38
|
"selectionStroke": "#3c32e9",
|
|
39
39
|
"selectionAnchorFill": "#ffffff",
|
|
40
|
-
"placeholderFill": "#
|
|
41
|
-
"placeholderStroke": "#
|
|
42
|
-
"brokenFill": "#
|
|
40
|
+
"placeholderFill": "#f5f6fa",
|
|
41
|
+
"placeholderStroke": "#c8c7d6",
|
|
42
|
+
"brokenFill": "#f2f3f8",
|
|
43
43
|
"brokenStroke": "#787878"
|
|
44
44
|
}
|
|
45
45
|
},
|
|
@@ -58,16 +58,16 @@ var brandThemes = {
|
|
|
58
58
|
"mutedForeground": "240 5% 68%",
|
|
59
59
|
"accent": "249 24% 16%",
|
|
60
60
|
"accentForeground": "0 0% 90.1961%",
|
|
61
|
-
"destructive": "2.
|
|
61
|
+
"destructive": "2.8 100% 83.1%",
|
|
62
62
|
"destructiveForeground": "0 0% 0%",
|
|
63
63
|
"border": "243 20% 20%",
|
|
64
64
|
"input": "240 5% 68%",
|
|
65
65
|
"ring": "233 100% 87%",
|
|
66
|
-
"success": "154.
|
|
67
|
-
"warning": "
|
|
66
|
+
"success": "154.7 60.2% 60.6%",
|
|
67
|
+
"warning": "41.5 88.2% 63.3%",
|
|
68
68
|
"successForeground": "0 0% 0%",
|
|
69
69
|
"warningForeground": "0 0% 0%",
|
|
70
|
-
"warningStrong": "41.
|
|
70
|
+
"warningStrong": "41.5 88.2% 63.3%",
|
|
71
71
|
"inputFill": "hsl(244 29% 9%)",
|
|
72
72
|
"canvasBackdrop": "#040408",
|
|
73
73
|
"borderSoft": "rgba(255, 255, 255, 0.10)",
|
|
@@ -80,7 +80,7 @@ var brandThemes = {
|
|
|
80
80
|
"snapElement": "#ffada9",
|
|
81
81
|
"selectionStroke": "#a5b4fc",
|
|
82
82
|
"selectionAnchorFill": "#232238",
|
|
83
|
-
"placeholderFill": "#
|
|
83
|
+
"placeholderFill": "#11101e",
|
|
84
84
|
"placeholderStroke": "#2a293d",
|
|
85
85
|
"brokenFill": "#221f33",
|
|
86
86
|
"brokenStroke": "#8e8e8e"
|
|
@@ -147,4 +147,4 @@ export {
|
|
|
147
147
|
themeColor,
|
|
148
148
|
themeToCssVars
|
|
149
149
|
};
|
|
150
|
-
//# sourceMappingURL=chunk-
|
|
150
|
+
//# sourceMappingURL=chunk-EUQ46YWK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/theme/brand.generated.ts","../src/theme/theme.ts"],"sourcesContent":["/** GENERATED from @tangle-network/brand/styles/legacy-light.css\n * SHA-256: 0724fdafc42190beb3b6fae05f536de07d65b10554c08d97eaa1ceef475a0602\n * Run node src/theme/build.mjs --write; do not edit colors or ratios here. */\nexport const brandThemes = {\n \"light\": {\n \"background\": \"223 23% 94%\",\n \"foreground\": \"0 0% 17.6471%\",\n \"card\": \"0 0% 100%\",\n \"cardForeground\": \"0 0% 17.6471%\",\n \"popover\": \"0 0% 100%\",\n \"popoverForeground\": \"0 0% 17.6471%\",\n \"primary\": \"243.2787 80.6167% 55.4902%\",\n \"primaryForeground\": \"0 0% 100%\",\n \"secondary\": \"230 27% 96%\",\n \"secondaryForeground\": \"0 0% 17.6471%\",\n \"muted\": \"230 27% 96%\",\n \"mutedForeground\": \"0 0% 29.8039%\",\n \"accent\": \"230 27% 96%\",\n \"accentForeground\": \"0 0% 17.6471%\",\n \"destructive\": \"0 73.7% 41.8%\",\n \"destructiveForeground\": \"0 0% 100%\",\n \"border\": \"244 16% 81%\",\n \"input\": \"0 0% 29.8039%\",\n \"ring\": \"246 54% 51%\",\n \"success\": \"162.9 93.5% 24.3%\",\n \"warning\": \"25.9 90% 35.3%\",\n \"successForeground\": \"0 0% 100%\",\n \"warningForeground\": \"0 0% 100%\",\n \"warningStrong\": \"25.9 90% 35.3%\",\n \"inputFill\": \"hsl(225 29% 97%)\",\n \"canvasBackdrop\": \"#dcdee6\",\n \"borderSoft\": \"rgba(0, 0, 0, 0.10)\",\n \"cardEdge\": \"rgba(0, 0, 0, 0.14)\",\n \"canvasRender\": {\n \"grid\": \"#c8c7d6\",\n \"snapGrid\": \"#787878\",\n \"snapGuide\": \"#0369a1\",\n \"snapPage\": \"#ab4f09\",\n \"snapElement\": \"#b91c1c\",\n \"selectionStroke\": \"#3c32e9\",\n \"selectionAnchorFill\": \"#ffffff\",\n \"placeholderFill\": \"#f5f6fa\",\n \"placeholderStroke\": \"#c8c7d6\",\n \"brokenFill\": \"#f2f3f8\",\n \"brokenStroke\": \"#787878\"\n }\n },\n \"dark\": {\n \"background\": \"240 33% 6%\",\n \"foreground\": \"0 0% 90.1961%\",\n \"card\": \"244 23% 12%\",\n \"cardForeground\": \"0 0% 90.1961%\",\n \"popover\": \"247 23% 21%\",\n \"popoverForeground\": \"0 0% 90.1961%\",\n \"primary\": \"229.6552 93.5484% 81.7647%\",\n \"primaryForeground\": \"0 0% 0%\",\n \"secondary\": \"249 24% 16%\",\n \"secondaryForeground\": \"0 0% 90.1961%\",\n \"muted\": \"249 24% 16%\",\n \"mutedForeground\": \"240 5% 68%\",\n \"accent\": \"249 24% 16%\",\n \"accentForeground\": \"0 0% 90.1961%\",\n \"destructive\": \"2.8 100% 83.1%\",\n \"destructiveForeground\": \"0 0% 0%\",\n \"border\": \"243 20% 20%\",\n \"input\": \"240 5% 68%\",\n \"ring\": \"233 100% 87%\",\n \"success\": \"154.7 60.2% 60.6%\",\n \"warning\": \"41.5 88.2% 63.3%\",\n \"successForeground\": \"0 0% 0%\",\n \"warningForeground\": \"0 0% 0%\",\n \"warningStrong\": \"41.5 88.2% 63.3%\",\n \"inputFill\": \"hsl(244 29% 9%)\",\n \"canvasBackdrop\": \"#040408\",\n \"borderSoft\": \"rgba(255, 255, 255, 0.10)\",\n \"cardEdge\": \"rgba(255, 255, 255, 0.16)\",\n \"canvasRender\": {\n \"grid\": \"#2a293d\",\n \"snapGrid\": \"#8e8e8e\",\n \"snapGuide\": \"#67cdff\",\n \"snapPage\": \"#f4c14f\",\n \"snapElement\": \"#ffada9\",\n \"selectionStroke\": \"#a5b4fc\",\n \"selectionAnchorFill\": \"#232238\",\n \"placeholderFill\": \"#11101e\",\n \"placeholderStroke\": \"#2a293d\",\n \"brokenFill\": \"#221f33\",\n \"brokenStroke\": \"#8e8e8e\"\n }\n }\n} as const\n","/** Brand-derived HSL compatibility and bitmap snapshots. Regenerate with src/theme/build.mjs; never author a second palette here. */\nimport { brandThemes } from './brand.generated'\n\nexport interface AgentAppTheme {\n background: string\n foreground: string\n card: string\n cardForeground: string\n popover: string\n popoverForeground: string\n primary: string\n primaryForeground: string\n secondary: string\n secondaryForeground: string\n muted: string\n mutedForeground: string\n accent: string\n accentForeground: string\n destructive: string\n destructiveForeground: string\n border: string\n input: string\n /** Full field fill, distinct from the input border. Optional for existing custom themes. */\n inputFill?: string\n ring: string\n success: string\n successForeground: string\n warning: string\n warningForeground: string\n /**\n * Warning as TEXT on a warning-TINTED surface, as a channel triple. Optional\n * so a consumer's existing `AgentAppTheme` literal still type-checks;\n * {@link themeToCssVars} falls back to `warningForeground`, which is what the\n * surface used before this token existed.\n */\n warningStrong?: string\n /** Full CSS color (not a triple) — the canvas/scene backdrop. */\n canvasBackdrop: string\n /**\n * Border tiers as FULL CSS colors (they are `color-mix()` results, not\n * triples). Optional so a consumer's existing `AgentAppTheme` literal still\n * type-checks; {@link themeToCssVars} falls back to full-strength\n * `hsl(var(--border))`, which can never erase an edge.\n */\n borderSoft?: string\n /** @see borderSoft */\n cardEdge?: string\n /** Konva render palette — full hex colors the bitmap canvas paints with\n * (it cannot resolve `var(--…)`). NOT emitted by themeToCssVars. */\n canvasRender: CanvasRenderPalette\n}\n\n/**\n * Colors the Konva design-canvas paints directly. Konva renders to a bitmap\n * and cannot read CSS custom properties, so these are full hex strings sourced\n * from the active theme and threaded through the canvas components.\n */\nexport interface CanvasRenderPalette {\n /** Grid line color (GridLayer). */\n grid: string\n /** Grid-snap guide line (SnapGuidesOverlay, kind 'grid'). */\n snapGrid: string\n /** Saved ruler-guide snap line (kind 'guide'). */\n snapGuide: string\n /** Page edge/center snap line (kinds 'page-edge'/'page-center'). */\n snapPage: string\n /** Element edge/center snap line (kinds 'element-edge'/'element-center'). */\n snapElement: string\n /** Transformer border + anchor stroke (SelectionLayer). */\n selectionStroke: string\n /** Transformer anchor fill (SelectionLayer). */\n selectionAnchorFill: string\n /** Video placeholder fill (ElementNode VideoNode). */\n placeholderFill: string\n /** Video placeholder stroke (ElementNode VideoNode). */\n placeholderStroke: string\n /** Broken/loading image placeholder fill (ElementNode ImageNode). */\n brokenFill: string\n /** Broken/loading image placeholder stroke (ElementNode ImageNode). */\n brokenStroke: string\n}\n\n/** Define a light color theme with specific background, foreground, and accent color values */\nexport const lightTheme: AgentAppTheme = brandThemes.light\n\n/** Canonical Brand dark values projected for legacy JS and bitmap callers. */\nexport const darkTheme: AgentAppTheme = brandThemes.dark\n\n/**\n * Wrap a channel triple in `hsl()`; pass through values already in a color form.\n * `oklch(…)` / `oklab(…)` / `color-mix(…)` are recognised because the ramp is\n * authored in oklch and the border tiers are colour mixes — wrapping either in\n * `hsl()` yields an invalid colour that paints as nothing.\n */\nexport function themeColor(value: string): string {\n return /^(hsl|rgb|oklch|oklab|lch|lab|color|color-mix|#)/.test(value) ? value : `hsl(${value})`\n}\n\n/**\n * Map a theme to the full CSS-variable set (shadcn triples + canvas/sequences\n * aliases + canvas surface). Apply at runtime to scope a theme without loading\n * tokens.css: `Object.assign(el.style, themeToCssVars(darkTheme))`.\n */\nexport function themeToCssVars(theme: AgentAppTheme): Record<string, string> {\n return {\n '--background': theme.background,\n '--foreground': theme.foreground,\n '--card': theme.card,\n '--card-foreground': theme.cardForeground,\n '--popover': theme.popover,\n '--popover-foreground': theme.popoverForeground,\n '--primary': theme.primary,\n '--primary-foreground': theme.primaryForeground,\n '--secondary': theme.secondary,\n '--secondary-foreground': theme.secondaryForeground,\n '--muted': theme.muted,\n '--muted-foreground': theme.mutedForeground,\n '--accent': theme.accent,\n '--accent-foreground': theme.accentForeground,\n '--destructive': theme.destructive,\n '--destructive-foreground': theme.destructiveForeground,\n '--border': theme.border,\n '--input': theme.input,\n '--ring': theme.ring,\n '--success': theme.success,\n '--success-foreground': theme.successForeground,\n '--warning': theme.warning,\n '--warning-foreground': theme.warningForeground,\n // Falls back to the pairing the tinted surfaces used before this token\n // existed, so an unset value restores the previous look rather than an\n // unthemed one.\n '--warning-strong': theme.warningStrong ?? theme.warningForeground,\n '--bg-input': theme.inputFill ?? `hsl(${theme.card})`,\n '--text-primary': `hsl(${theme.foreground})`,\n '--text-secondary': `hsl(${theme.secondaryForeground})`,\n '--text-muted': `hsl(${theme.mutedForeground})`,\n '--text-danger': `hsl(${theme.destructive})`,\n '--text-warning': `hsl(${theme.warningStrong ?? theme.warningForeground})`,\n '--border-default': `hsl(${theme.border})`,\n '--brand-primary': `hsl(${theme.primary})`,\n '--editor-selection-background': `hsl(${theme.primary})`,\n '--editor-selection-foreground': `hsl(${theme.primaryForeground})`,\n '--canvas-backdrop': theme.canvasBackdrop,\n // Full strength is the safe default: an unset tier can under-draw an edge,\n // never erase one.\n '--border-soft': theme.borderSoft ?? `hsl(${theme.border})`,\n '--card-edge': theme.cardEdge ?? `hsl(${theme.border})`,\n }\n}\n"],"mappings":";AAGO,IAAM,cAAc;AAAA,EACzB,SAAS;AAAA,IACP,cAAc;AAAA,IACd,cAAc;AAAA,IACd,QAAQ;AAAA,IACR,kBAAkB;AAAA,IAClB,WAAW;AAAA,IACX,qBAAqB;AAAA,IACrB,WAAW;AAAA,IACX,qBAAqB;AAAA,IACrB,aAAa;AAAA,IACb,uBAAuB;AAAA,IACvB,SAAS;AAAA,IACT,mBAAmB;AAAA,IACnB,UAAU;AAAA,IACV,oBAAoB;AAAA,IACpB,eAAe;AAAA,IACf,yBAAyB;AAAA,IACzB,UAAU;AAAA,IACV,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,WAAW;AAAA,I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iBAAiB,MAAM,cAAc,OAAO,MAAM,MAAM;AAAA,IACxD,eAAe,MAAM,YAAY,OAAO,MAAM,MAAM;AAAA,EACtD;AACF;","names":[]}
|
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
} from "./chunk-OY7A6M7S.js";
|
|
5
5
|
import {
|
|
6
6
|
parseRenderUiSchema
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-43CV4JIT.js";
|
|
8
8
|
import {
|
|
9
9
|
buildAppToolOpenAITools,
|
|
10
10
|
findCustomTool,
|
|
11
11
|
isAppToolName
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-HJYEK4SU.js";
|
|
13
13
|
import {
|
|
14
14
|
ToolInputError
|
|
15
15
|
} from "./chunk-F4XBNR5L.js";
|
|
@@ -212,4 +212,4 @@ export {
|
|
|
212
212
|
createAppToolRuntimeExecutor,
|
|
213
213
|
handleAppToolRequest
|
|
214
214
|
};
|
|
215
|
-
//# sourceMappingURL=chunk-
|
|
215
|
+
//# sourceMappingURL=chunk-FJRQCF43.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-TB6KNPFI.js";
|
|
7
7
|
import {
|
|
8
8
|
mentionKindForPath
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-K2JPSXKI.js";
|
|
10
10
|
import {
|
|
11
11
|
persistedPartToPlan,
|
|
12
12
|
planToPersistedPart
|
|
@@ -52,6 +52,8 @@ function toChatMessagePart(part) {
|
|
|
52
52
|
return persistedPartToWorkProduct(part) ? part : null;
|
|
53
53
|
case "mention":
|
|
54
54
|
return isChatMentionPart(part) ? part : null;
|
|
55
|
+
case "speaker":
|
|
56
|
+
return isChatSpeakerPart(part) ? part : null;
|
|
55
57
|
case void 0:
|
|
56
58
|
return null;
|
|
57
59
|
default: {
|
|
@@ -70,13 +72,23 @@ function isChatMentionPart(part) {
|
|
|
70
72
|
if (record.size !== void 0 && (typeof record.size !== "number" || !Number.isFinite(record.size))) {
|
|
71
73
|
return false;
|
|
72
74
|
}
|
|
73
|
-
|
|
75
|
+
if (record.mentionKind === "agent" && (typeof record.agentId !== "string" || record.agentId.length === 0)) return false;
|
|
76
|
+
return record.type === "mention" && typeof record.path === "string" && record.path.length > 0 && typeof record.name === "string" && record.name.trim().length > 0 && (record.mentionKind === "image" || record.mentionKind === "file" || record.mentionKind === "agent");
|
|
77
|
+
}
|
|
78
|
+
function isChatSpeakerPart(part) {
|
|
79
|
+
if (!part || typeof part !== "object") return false;
|
|
80
|
+
const record = part;
|
|
81
|
+
return record.type === "speaker" && typeof record.id === "string" && record.id.length > 0 && typeof record.name === "string" && record.name.trim().length > 0 && (record.handle === void 0 || typeof record.handle === "string");
|
|
74
82
|
}
|
|
75
83
|
function mentionPartsFromMessageParts(parts) {
|
|
76
84
|
if (!parts) return [];
|
|
77
85
|
return parts.filter(isChatMentionPart);
|
|
78
86
|
}
|
|
79
|
-
function mentionInputToPart(
|
|
87
|
+
function mentionInputToPart(mention) {
|
|
88
|
+
if ("kind" in mention && mention.kind === "agent") {
|
|
89
|
+
return { type: "mention", mentionKind: "agent", path: mention.handle, name: mention.name, agentId: mention.agentId };
|
|
90
|
+
}
|
|
91
|
+
const input = mention;
|
|
80
92
|
const part = {
|
|
81
93
|
type: "mention",
|
|
82
94
|
mentionKind: mentionKindForPath(input.path),
|
|
@@ -135,6 +147,7 @@ export {
|
|
|
135
147
|
toChatMessageParts,
|
|
136
148
|
isChatInteractionPart,
|
|
137
149
|
isChatMentionPart,
|
|
150
|
+
isChatSpeakerPart,
|
|
138
151
|
mentionPartsFromMessageParts,
|
|
139
152
|
mentionInputToPart,
|
|
140
153
|
attachmentKindForMime,
|
|
@@ -146,4 +159,4 @@ export {
|
|
|
146
159
|
buildAttachmentPromptBlock,
|
|
147
160
|
historyContentWithAttachments
|
|
148
161
|
};
|
|
149
|
-
//# sourceMappingURL=chunk-
|
|
162
|
+
//# sourceMappingURL=chunk-GAYWV565.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/chat-store/parts.ts"],"sourcesContent":["/**\n * The stored shape of `message.parts` — one typed vocabulary for every part a\n * product persists into a chat transcript. NOT an ad-hoc union reverse-\n * engineered from product schemas; each member is matched field-for-field to\n * its canonical source:\n *\n * - `text` / `reasoning` / `tool`: the persisted projection `/stream`'s\n * `normalizePersistedPart` produces from the harness lane's\n * `message.part.updated` events (ADC sidecar\n * `apps/sidecar/src/events/session-events.ts:56` wraps the canonical part in\n * an `{id, sessionID, messageID}` envelope; the projection strips the\n * session/message ids and keeps the per-segment part id).\n * - `file` / `image` / `step-start` / `step-finish`: the sidecar's canonical\n * `MessagePartSchema` members (ADC\n * `apps/sidecar/src/schemas/agent-schemas.ts:50-154`); `step-finish` carries\n * the harness's per-step usage receipt — tokens\n * `{total, input, output, reasoning, cache{write, read}}` + `cost` — which is\n * also the shape the message-level token/cost columns mirror.\n * - `subtask`: `@tangle-network/agent-interface`'s `SubtaskPart` (a spawned\n * sub-agent task).\n * - `interaction` / `notice`: the persisted-part codecs in\n * `/web-react`'s chat-interactions contract (`interactionToPersistedPart`,\n * `noticePart`) — type-only imports, one source of truth for their statuses\n * and field shapes.\n * - `plan`: the durable-plan projection in `/plans`, derived from the sandbox\n * SDK's authoritative plan lifecycle.\n * - `work_product`: the persisted work-product anchor card in\n * `/work-product`'s contract (`workProductToPersistedPart` /\n * `persistedPartToWorkProduct`) — SYSTEM-authored on the ready transition\n * and updated on a reviewer verdict; no prompt teaches an agent to author\n * one.\n * - `mention`: an `@`-picked reference to a file that already lives in the\n * workspace sandbox (`FileMention` in `/chat-routes`'s wire contract, plus\n * the image/file discriminant). Neither transport lane produces it — the\n * turn route persists it from the request's `mentions` field — but it is a\n * part a product persists into a transcript, so it belongs in this\n * vocabulary rather than in a parallel one.\n *\n * `@tangle-network/agent-interface` exports the canonical wire `Part` union,\n * but its `PartBase` requires the `sessionID`/`messageID` stream envelope that\n * is deliberately NOT persisted, so the stored union is defined here as the\n * envelope-free projection (a type-level coverage check against the peer's\n * `Part['type']` lives in the tests). Contribute-down candidate: if\n * agent-interface grows envelope-free persisted-part types, re-export them\n * here and delete these definitions.\n *\n * Two transport lanes serialize into this SAME stored shape:\n * - harness lane: canonical `message.part.updated` parts, merged/normalized by\n * `/stream` (`mergePersistedPart`, `finalizeAssistantParts`);\n * - router/openai-compat lane: `text_delta`/`tool_call` stream events are\n * mapped INTO canonical part events first (`/runtime`'s `toLoopEvents` +\n * `/stream`'s `normalizeToolEvent`) and then persisted identically — the\n * store never sees a router-specific shape.\n */\n\nimport type { Part as HarnessWirePart } from '@tangle-network/agent-interface'\nimport type {\n ChatInteractionField,\n ChatInteractionStatus,\n InteractionAnswers,\n NoticeKind,\n} from '../web-react/chat-interactions'\nimport { persistedPartToInteraction } from '../interactions/contract'\nimport {\n persistedPartToWorkProduct,\n type WorkProductPersistedPart,\n} from '../work-product/types'\nimport {\n persistedPartToPlan,\n planToPersistedPart,\n type ChatPlanPersistedPart,\n} from '../plans/index'\n// `./wire` is import-free by construction, so this edge costs the store\n// nothing and keeps ONE image-extension table for the whole mention layer.\nimport {\n mentionKindForPath,\n type ChatAttachmentInput,\n type ChatAttachmentKind,\n type ChatMention,\n type ChatMentionKind,\n type FileMention,\n} from '../chat-routes/wire'\n\nexport type { ChatMentionKind, ChatAttachmentKind }\n\n/** Start/end wall-clock millis, as normalized by `/stream`'s `normalizeTime`. */\nexport interface ChatPartTime {\n start?: number\n end?: number\n}\n\n/** `id` is the harness's per-segment identity; absent on legacy/router parts,\n * which collapse to a single logical text stream. Never invented client-side. */\nexport interface ChatTextPart {\n type: 'text'\n text: string\n id?: string\n}\n\n/** Define a reasoning part of a chat with text content and optional metadata fields */\nexport interface ChatReasoningPart {\n type: 'reasoning'\n text: string\n id?: string\n time?: ChatPartTime\n}\n\n/** Superset of the sidecar's status enum (`pending|running|completed|failed`)\n * and agent-interface's `ToolState` statuses; `error` is the persisted\n * terminal form `/stream`'s `normalizePersistedPart` settles on. */\nexport type ChatToolStatus = 'pending' | 'running' | 'completed' | 'error' | 'failed'\n\n/** Describe the current state and data of a chat tool including status, input, output, and metadata */\nexport interface ChatToolState {\n status: ChatToolStatus\n input?: unknown\n output?: unknown\n error?: string\n title?: string\n metadata?: Record<string, unknown>\n time?: ChatPartTime\n}\n\n/** Define a chat component representing a tool with its state and optional call identifier */\nexport interface ChatToolPart {\n type: 'tool'\n id: string\n tool: string\n callID?: string\n state: ChatToolState\n}\n\n/** Union of the sidecar's legacy (path-based) and AI-SDK (url-based) file\n * shapes; response-side every field besides `type` is optional. `name` is the\n * attachment-flavored display label an uploaded/promoted file carries (see\n * {@link ChatAttachmentPart}) — absent on a harness-emitted file part, which\n * uses `filename`. */\nexport interface ChatFilePart {\n type: 'file'\n id?: string\n filename?: string\n name?: string\n mediaType?: string\n url?: string\n path?: string\n content?: string\n}\n\n/** Define properties for an image part within a chat message including optional metadata fields */\nexport interface ChatImagePart {\n type: 'image'\n filename?: string\n name?: string\n mediaType?: string\n url?: string\n path?: string\n}\n\n/** Define a subtask part of a chat with prompt, description, agent, and optional identifier */\nexport interface ChatSubtaskPart {\n type: 'subtask'\n prompt: string\n description: string\n agent: string\n id?: string\n}\n\n/** OpenCode step-boundary marker — no renderable text; preserved so mappers\n * never coerce it into a \"[object Object]\" text part. */\nexport interface ChatStepStartPart {\n type: 'step-start'\n}\n\n/** Per-step usage receipt as the harness reports it (sidecar\n * `StepFinishPartSchema`). The message-level token/cost columns are this\n * shape flattened. */\nexport interface ChatUsageTokens {\n total?: number\n input?: number\n output?: number\n reasoning?: number\n cache?: {\n write?: number\n read?: number\n }\n}\n\n/** Define a chat step finish part indicating completion with optional reason, tokens, and cost */\nexport interface ChatStepFinishPart {\n type: 'step-finish'\n reason?: string\n tokens?: ChatUsageTokens\n cost?: number\n}\n\n/** Persisted human-in-the-loop ask — byte-matches\n * `interactionToPersistedPart` in `/web-react`'s chat-interactions contract. */\nexport interface ChatInteractionPart {\n type: 'interaction'\n id: string\n kind: string\n title: string\n body?: string\n answerSpec: { fields: ChatInteractionField[] }\n status: ChatInteractionStatus\n answers?: InteractionAnswers\n cancelReason?: string\n}\n\n/** Resolve a chat plan part by aliasing it to the persisted chat plan part type */\nexport type ChatPlanPart = ChatPlanPersistedPart\n\n/** Persisted work-product anchor card — byte-matches\n * `workProductToPersistedPart` in `/work-product`'s contract. Written by the\n * PLATFORM on the ready transition (and updated on a verdict); never\n * authored by a prompt. */\nexport type ChatWorkProductPart = WorkProductPersistedPart\n\n/** Persisted one-line transcript notice — byte-matches `noticePart` in\n * `/web-react`'s chat-interactions contract. */\nexport interface ChatNoticePart {\n type: 'notice'\n id: string\n noticeKind: NoticeKind\n text: string\n /** Typed reason for an `error` notice, e.g. the sandbox or upstream error code. */\n code?: string\n /** The failure's redacted cause chain, for operators and support. Kept with the transcript; not rendered. */\n detail?: string\n}\n\n/**\n * A file the user `@`-mentioned on this turn: a workspace-relative path into\n * the sandbox, never bytes. `type: 'mention'` is its own discriminant\n * precisely so it does NOT collide with the `file`/`image` attachment parts —\n * an attachment carries content the product uploaded, a mention points at\n * something the box already has, and a transcript renders them differently\n * (an inline pill, not an attachment card).\n *\n * `path` is the identity: mentioning one file twice in a turn folds to one\n * part. `turnId` is optional and set by products that rebuild a turn's\n * mentions on retry.\n */\nexport interface ChatMentionPart {\n type: 'mention'\n mentionKind: ChatMentionKind\n /** The `@`-token identity the message text carries: a workspace-relative\n * path for a file, the handle for an agent. */\n path: string\n name: string\n size?: number\n turnId?: string\n /** The stable profile id behind an `agent` mention, so a rename never\n * breaks an old message. Absent on file mentions. */\n agentId?: string\n}\n\n/** Who wrote the parts that follow, when one assistant row holds more than one\n * responder: a turn addressed to `@a @b` is one row whose parts read\n * speaker a, a's text, speaker b, b's text. A renderer splits the row at\n * these (`expandSpeakerRows` in `/web`); a row with none is one speaker. */\nexport interface ChatSpeakerPart {\n type: 'speaker'\n id: string\n name: string\n handle?: string\n}\n\n/** Represent parts of a chat message including text, reasoning, tools, files, images, subtasks, steps, interactions, notices, plans, and mentions */\nexport type ChatMessagePart =\n | ChatTextPart\n | ChatReasoningPart\n | ChatToolPart\n | ChatFilePart\n | ChatImagePart\n | ChatSubtaskPart\n | ChatStepStartPart\n | ChatStepFinishPart\n | ChatInteractionPart\n | ChatNoticePart\n | ChatPlanPart\n | ChatWorkProductPart\n | ChatMentionPart\n | ChatSpeakerPart\n\n/** Every canonical harness wire-part kind must be storable — compile-time\n * guarantee that a new agent-interface part kind cannot silently fall out of\n * the persisted vocabulary. */\nexport type StorableHarnessPartKind = HarnessWirePart['type'] & ChatMessagePart['type']\n\n/**\n * The typed projection at the `/stream` → `/chat-store` boundary. The stream\n * normalizers (`normalizePersistedPart`/`mergePersistedPart`/\n * `finalizeAssistantParts`) deliberately produce untyped `JsonRecord`s — they\n * normalize wire shapes and do not own the stored vocabulary. THIS module\n * owns it, so this is where rows gain the `ChatMessagePart` type: each entry\n * is validated against its kind's required fields and narrowed, junk is\n * dropped, and — enforced by the exhaustiveness check below — no storable\n * kind can silently fall out (the step-finish/interaction trap).\n */\nexport function toChatMessageParts(parts: Array<Record<string, unknown>>): ChatMessagePart[] {\n const out: ChatMessagePart[] = []\n for (const part of parts) {\n const typed = toChatMessagePart(part)\n if (typed) out.push(typed)\n }\n return out\n}\n\nconst str = (value: unknown): value is string => typeof value === 'string'\n\nfunction toChatMessagePart(part: Record<string, unknown>): ChatMessagePart | null {\n if (!part || typeof part !== 'object') return null\n const type = part.type as ChatMessagePart['type'] | undefined\n switch (type) {\n case 'text':\n case 'reasoning':\n return str(part.text) ? (part as unknown as ChatTextPart | ChatReasoningPart) : null\n case 'tool':\n return str(part.id) && str(part.tool) && part.state && typeof part.state === 'object'\n ? (part as unknown as ChatToolPart)\n : null\n case 'file':\n case 'image':\n return part as unknown as ChatFilePart | ChatImagePart\n case 'subtask':\n return str(part.prompt) && str(part.description) && str(part.agent)\n ? (part as unknown as ChatSubtaskPart)\n : null\n case 'step-start':\n return { type: 'step-start' }\n case 'step-finish':\n return part as unknown as ChatStepFinishPart\n case 'interaction':\n return persistedPartToInteraction(part) ? (part as unknown as ChatInteractionPart) : null\n case 'notice':\n return str(part.id) && str(part.noticeKind) && str(part.text)\n ? (part as unknown as ChatNoticePart)\n : null\n case 'plan': {\n const plan = persistedPartToPlan(part)\n return plan ? ({ ...part, ...planToPersistedPart(plan) } as ChatPlanPart) : null\n }\n case 'work_product':\n // Validate via the codec but keep the original row (extra fields the\n // product persisted round-trip, matching the interaction case).\n return persistedPartToWorkProduct(part) ? (part as unknown as ChatWorkProductPart) : null\n case 'mention':\n return isChatMentionPart(part) ? part : null\n case 'speaker':\n return isChatSpeakerPart(part) ? part : null\n case undefined:\n return null\n default: {\n // Compile-time exhaustiveness: a new ChatMessagePart kind that is not\n // handled above makes `type` non-never here and this line fails.\n const _exhaustive: never = type\n void _exhaustive\n return null\n }\n }\n}\n/** Resolve whether a ChatMessagePart is a ChatInteractionPart based on its type property */\nexport function isChatInteractionPart(part: ChatMessagePart): part is ChatInteractionPart {\n return part.type === 'interaction'\n}\n/** Widened to `unknown` — unlike its siblings this guard also runs over raw\n * untyped stored rows (a transcript renderer reads `message.parts` before the\n * typed projection), which is exactly what {@link mentionPartsFromMessageParts}\n * needs. `path` and `name` carry the pill; a row missing either is unrenderable.\n *\n * Mirrors the write contract exactly (`parseFileMention` in `/chat-routes`,\n * then {@link mentionInputToPart}): a blank `name` is rejected there and so is\n * rejected here, and `size` — optional, but typed `number` once present — is\n * type-checked so `'12'` or `null` cannot ride through the guard wearing a\n * type it does not have. Negative sizes are NOT re-rejected: the wire screens\n * them, `mentionInputToPart` trusts its input, and a read guard stricter than\n * what the writer can emit would drop rows it produced itself. */\nexport function isChatMentionPart(part: unknown): part is ChatMentionPart {\n if (!part || typeof part !== 'object') return false\n const record = part as Record<string, unknown>\n if (record.size !== undefined && (typeof record.size !== 'number' || !Number.isFinite(record.size))) {\n return false\n }\n if (record.mentionKind === 'agent' && (typeof record.agentId !== 'string' || record.agentId.length === 0)) return false\n return (\n record.type === 'mention' &&\n typeof record.path === 'string' &&\n record.path.length > 0 &&\n typeof record.name === 'string' &&\n record.name.trim().length > 0 &&\n (record.mentionKind === 'image' || record.mentionKind === 'file' || record.mentionKind === 'agent')\n )\n}\n\nexport function isChatSpeakerPart(part: unknown): part is ChatSpeakerPart {\n if (!part || typeof part !== 'object') return false\n const record = part as Record<string, unknown>\n return record.type === 'speaker' && typeof record.id === 'string' && record.id.length > 0 &&\n typeof record.name === 'string' && record.name.trim().length > 0 &&\n (record.handle === undefined || typeof record.handle === 'string')\n}\n\n/** Every mention part on one message, in stored order. The projection a\n * transcript renderer runs before deciding which mentions the message text\n * already shows inline (see `segmentMentionContent` in `/web-react`). */\nexport function mentionPartsFromMessageParts(\n parts: ReadonlyArray<Record<string, unknown>> | ReadonlyArray<ChatMessagePart> | null | undefined,\n): ChatMentionPart[] {\n if (!parts) return []\n return (parts as ReadonlyArray<unknown>).filter(isChatMentionPart)\n}\n\n/** A validated wire mention (`parseFileMentions` in `/chat-routes`) as the\n * part the turn route persists. An absent/non-finite `size` is DROPPED rather\n * than stored as `undefined`, so a stored row never carries a key that means\n * nothing. */\nexport function mentionInputToPart(mention: ChatMention): ChatMentionPart {\n if ('kind' in mention && mention.kind === 'agent') {\n return { type: 'mention', mentionKind: 'agent', path: mention.handle, name: mention.name, agentId: mention.agentId }\n }\n const input = mention as FileMention\n const part: ChatMentionPart = {\n type: 'mention',\n mentionKind: mentionKindForPath(input.path),\n path: input.path,\n name: input.name,\n }\n if (typeof input.size === 'number' && Number.isFinite(input.size)) part.size = input.size\n return part\n}\n\n// ── attachments ──────────────────────────────────────────────────────────\n//\n// An attachment is a file the product uploaded into its own store (vault /\n// object-store) ahead of the turn — content the box did not already have,\n// unlike a `@`-mention. It persists NOT as a new `ChatMessagePart` union\n// member but as an attachment-flavored `file`/`image` part: `type` is the\n// existing `image`/`file` discriminant, with `path` + `name` load-bearing.\n// That reuse is deliberate — a transcript already renders `file`/`image`\n// parts, and `toChatMessagePart` passes them through by cast (fields survive),\n// so an attachment slots into the same stored `parts` array without a parallel\n// vocabulary. These helpers own the input→part projection, the path-keyed\n// stream key, and the agent-facing prompt block, all byte-identical to the gtm\n// source they were lifted from (gtm-agent#618 adoption reproduces its rows and\n// dispatched prompt bytes through them).\n\n/** `image` for any `image/*` mime, `file` for everything else (including an\n * absent/empty mime) — the same split the composer and the persisted-part\n * discriminant both key on. */\nexport function attachmentKindForMime(mime?: string): ChatAttachmentKind {\n return mime?.startsWith('image/') ? 'image' : 'file'\n}\n\n/** Stream/transcript part key for an attachment — ONE declaration, owned by\n * `/stream`'s normalizer (whose `getPartKey` routes path-bearing file/image\n * parts through it). Re-exported here (not redefined) so the root barrel's\n * star-exports of both modules resolve to the same symbol instead of\n * colliding (TS2308 in the dts build). */\nexport { attachmentPartKey } from '../stream/stream-normalizer'\n\n/**\n * Persisted attachment part: structurally an attachment-flavored `ChatFilePart`\n * / `ChatImagePart` (`path` + `name` promoted to required) rather than a\n * separate union member — see the section note above. The index signature keeps\n * it a `Record<string, unknown>` so it drops into the same untyped `parts`\n * arrays every other stored part rides in, and lets the `type`-driven\n * constructors below build it without union-discriminant gymnastics.\n */\nexport interface ChatAttachmentPart {\n type: ChatAttachmentKind\n path: string\n name: string\n size?: number\n mediaType?: string\n turnId?: string\n [key: string]: unknown\n}\n\n/** True for any `image`/`file` part carrying a non-empty string `path`.\n * DELIBERATELY also matches a sidecar path-bearing file part (a mention-style\n * `file` part with only `path`) — the guard is a structural attachment shape,\n * not proof of provenance; a caller that needs to exclude those filters\n * upstream. The `path.length > 0` check diverges from gtm's original guard\n * (which only checked `typeof`), mirroring sibling {@link isChatMentionPart}:\n * read-side robustness against a stored `{type:'file', path:''}` row — which\n * would otherwise render a malformed `(vault: )` pointer line — justifies the\n * small divergence from byte-for-byte gtm parity here; no legitimate write\n * path ever produces an empty `path`. */\nexport function isChatAttachmentPart(part: unknown): part is ChatAttachmentPart {\n if (!part || typeof part !== 'object') return false\n const record = part as Record<string, unknown>\n return (\n (record.type === 'image' || record.type === 'file') &&\n typeof record.path === 'string' &&\n record.path.length > 0\n )\n}\n\n/** Drop absent/empty optional fields rather than persisting `undefined`/`''`\n * — keeps stored parts minimal. */\nexport function attachmentInputToPart(input: ChatAttachmentInput): ChatAttachmentPart {\n const part: ChatAttachmentPart = { type: input.kind, path: input.path, name: input.name }\n if (typeof input.size === 'number' && Number.isFinite(input.size)) part.size = input.size\n if (input.mediaType) part.mediaType = input.mediaType\n return part\n}\n\n/** Every attachment part on one message's stored `parts`, in stored order. */\nexport function attachmentPartsFromMessageParts(\n parts: ReadonlyArray<Record<string, unknown>> | null | undefined,\n): ChatAttachmentPart[] {\n if (!parts) return []\n return parts.filter(isChatAttachmentPart)\n}\n\n/** Attachment carry-forward in first-seen path order. Current-turn paths\n * are excluded; a later history row replaces a path's value without moving\n * the Map entry, matching the existing product dispatches. */\nexport function historyAttachmentsFromMessages(\n currentAttachments: ReadonlyArray<Pick<ChatAttachmentPart, 'path'>>,\n priorMessages: ReadonlyArray<{ parts?: ReadonlyArray<Record<string, unknown>> | null }>,\n): ChatAttachmentPart[] {\n const currentPaths = new Set(currentAttachments.map((part) => part.path))\n const historyByPath = new Map<string, ChatAttachmentPart>()\n for (const message of priorMessages) {\n for (const part of attachmentPartsFromMessageParts(message.parts)) {\n if (!currentPaths.has(part.path)) historyByPath.set(part.path, part)\n }\n }\n return [...historyByPath.values()]\n}\n\n/** gtm's exact default header for {@link buildAttachmentPromptBlock} — kept\n * byte-identical because it feeds dispatched prompts (gtm-agent#618\n * reproduces the prompt bytes through this module). Override only with intent. */\nexport const DEFAULT_ATTACHMENT_PROMPT_HEADER =\n 'Attached files (already saved to the workspace vault — read them from these paths):'\n\n/** Same C0-control/DEL sweep as `/chat-routes`'s `resolve-attachments.ts`\n * (kept as a separate literal rather than a shared import — this module is\n * the read side and must stay usable over PERSISTED rows the wire validator\n * never saw). Replaced with a single space, not stripped or collapsed: this\n * is defense-in-depth for legacy/corrupt stored rows that bypassed wire\n * validation, not the primary control — a name/path a `resolveChatAttachments`\n * call validated today never contains one, so this is a no-op on legitimate\n * input and gtm byte-compat holds. */\nconst PROMPT_BLOCK_CONTROL_CHARS = /[\\x00-\\x1F\\x7F]/g\n\n/**\n * The agent-facing pointer block appended to the dispatched prompt — never\n * persisted in `message.content`. Empty array → `''` so callers can append\n * unconditionally. The sole producer of this text: both the current turn's\n * dispatch and history projection ({@link historyContentWithAttachments}) build\n * it from here, so the two can never drift. `header` overrides the first line\n * ({@link DEFAULT_ATTACHMENT_PROMPT_HEADER}); the per-file line format is fixed.\n *\n * Every interpolated `name`/`path` is swept for control characters first\n * (newline/carriage-return/tab included) and each one replaced with a single\n * space — a single-line-per-file guarantee. Without it, a control character\n * riding through on a PERSISTED row (`historyContentWithAttachments` reads\n * whatever is already stored; a legacy or hand-edited row was never re-checked\n * against `resolveChatAttachments`) could inject extra lines — fabricated\n * pointer entries or instructions — into a prompt the agent trusts verbatim.\n * The wire-side validator is the primary control; this is the backstop for\n * rows it never saw.\n */\nexport function buildAttachmentPromptBlock(\n atts: ReadonlyArray<Pick<ChatAttachmentPart, 'name' | 'path'>>,\n header: string = DEFAULT_ATTACHMENT_PROMPT_HEADER,\n): string {\n if (atts.length === 0) return ''\n const clean = (value: string) => value.replace(PROMPT_BLOCK_CONTROL_CHARS, ' ')\n const lines = atts.map((a) => `- ${clean(a.name)} (vault: ${clean(a.path)})`)\n return `\\n\\n${header}\\n${lines.join('\\n')}`\n}\n\n/**\n * History projection for a persisted message: `content` unchanged when it\n * carries no attachment parts, else the block is appended once. The\n * no-double-annotation guarantee holds under the invariant that the block is\n * never persisted INTO `message.content` — it is appended only at read time,\n * by this function and the current turn's dispatch, both sourcing from\n * `attachmentPartsFromMessageParts` — never by content inspection. This\n * function does not (and cannot) detect an already-embedded block by scanning\n * `content` for its text: a message whose stored `content` happens to already\n * contain the block's bytes, alongside attachment parts, still gets the block\n * appended a second time. See the pinned test for that boundary.\n */\nexport function historyContentWithAttachments(\n message: {\n content: string\n parts?: ReadonlyArray<Record<string, unknown>> | null\n },\n header?: string,\n): string {\n const attachmentParts = attachmentPartsFromMessageParts(message.parts)\n if (attachmentParts.length === 0) return message.content\n return `${message.content}${buildAttachmentPromptBlock(attachmentParts, header)}`\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4SO,SAAS,mBAAmB,OAA0D;AAC3F,QAAM,MAAyB,CAAC;AAChC,aAAW,QAAQ,OAAO;AACxB,UAAM,QAAQ,kBAAkB,IAAI;AACpC,QAAI,MAAO,KAAI,KAAK,KAAK;AAAA,EAC3B;AACA,SAAO;AACT;AAEA,IAAM,MAAM,CAAC,UAAoC,OAAO,UAAU;AAElE,SAAS,kBAAkB,MAAuD;AAChF,MAAI,CAAC,QAAQ,OAAO,SAAS,SAAU,QAAO;AAC9C,QAAM,OAAO,KAAK;AAClB,UAAQ,MAAM;AAAA,IACZ,KAAK;AAAA,IACL,KAAK;AACH,aAAO,IAAI,KAAK,IAAI,IAAK,OAAuD;AAAA,IAClF,KAAK;AACH,aAAO,IAAI,KAAK,EAAE,KAAK,IAAI,KAAK,IAAI,KAAK,KAAK,SAAS,OAAO,KAAK,UAAU,WACxE,OACD;AAAA,IACN,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO,IAAI,KAAK,MAAM,KAAK,IAAI,KAAK,WAAW,KAAK,IAAI,KAAK,KAAK,IAC7D,OACD;AAAA,IACN,KAAK;AACH,aAAO,EAAE,MAAM,aAAa;AAAA,IAC9B,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO,2BAA2B,IAAI,IAAK,OAA0C;AAAA,IACvF,KAAK;AACH,aAAO,IAAI,KAAK,EAAE,KAAK,IAAI,KAAK,UAAU,KAAK,IAAI,KAAK,IAAI,IACvD,OACD;AAAA,IACN,KAAK,QAAQ;AACX,YAAM,OAAO,oBAAoB,IAAI;AACrC,aAAO,OAAQ,EAAE,GAAG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I,IAAgC;AAC1D,aAAW,WAAW,eAAe;AACnC,eAAW,QAAQ,gCAAgC,QAAQ,KAAK,GAAG;AACjE,UAAI,CAAC,aAAa,IAAI,KAAK,IAAI,EAAG,eAAc,IAAI,KAAK,MAAM,IAAI;AAAA,IACrE;AAAA,EACF;AACA,SAAO,CAAC,GAAG,cAAc,OAAO,CAAC;AACnC;AAKO,IAAM,mCACX;AAUF,IAAM,6BAA6B;AAoB5B,SAAS,2BACd,MACA,SAAiB,kCACT;AACR,MAAI,KAAK,WAAW,EAAG,QAAO;AAC9B,QAAM,QAAQ,CAAC,UAAkB,MAAM,QAAQ,4BAA4B,GAAG;AAC9E,QAAM,QAAQ,KAAK,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE,IAAI,CAAC,YAAY,MAAM,EAAE,IAAI,CAAC,GAAG;AAC5E,SAAO;AAAA;AAAA,EAAO,MAAM;AAAA,EAAK,MAAM,KAAK,IAAI,CAAC;AAC3C;AAcO,SAAS,8BACd,SAIA,QACQ;AACR,QAAM,kBAAkB,gCAAgC,QAAQ,KAAK;AACrE,MAAI,gBAAgB,WAAW,EAAG,QAAO,QAAQ;AACjD,SAAO,GAAG,QAAQ,OAAO,GAAG,2BAA2B,iBAAiB,MAAM,CAAC;AACjF;","names":[]}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-3CI35I4X.js";
|
|
5
5
|
import {
|
|
6
6
|
defineAppTool
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-HJYEK4SU.js";
|
|
8
8
|
import {
|
|
9
9
|
ToolInputError
|
|
10
10
|
} from "./chunk-F4XBNR5L.js";
|
|
@@ -672,4 +672,4 @@ export {
|
|
|
672
672
|
PROFILE_MEMORY_PREFIX,
|
|
673
673
|
profileTools
|
|
674
674
|
};
|
|
675
|
-
//# sourceMappingURL=chunk-
|
|
675
|
+
//# sourceMappingURL=chunk-H3DAXUKV.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
OPENUI_NODE_JSON_SCHEMA,
|
|
6
6
|
OPENUI_NODE_TYPES
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-XPB2UYHU.js";
|
|
8
8
|
|
|
9
9
|
// src/tools/openai.ts
|
|
10
10
|
var APP_TOOL_NAMES = ["submit_proposal", "schedule_followup", "render_ui", "add_citation"];
|
|
@@ -117,4 +117,4 @@ export {
|
|
|
117
117
|
customToolToOpenAI,
|
|
118
118
|
findCustomTool
|
|
119
119
|
};
|
|
120
|
-
//# sourceMappingURL=chunk-
|
|
120
|
+
//# sourceMappingURL=chunk-HJYEK4SU.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
formatBytes
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-K2JPSXKI.js";
|
|
4
4
|
|
|
5
5
|
// src/chat-routes/binary-sniff.ts
|
|
6
6
|
var OOXML_WORD_MIME = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
@@ -570,4 +570,4 @@ export {
|
|
|
570
570
|
defaultValidateAttachmentPath,
|
|
571
571
|
parseChatAttachmentInputs
|
|
572
572
|
};
|
|
573
|
-
//# sourceMappingURL=chunk-
|
|
573
|
+
//# sourceMappingURL=chunk-IAK227OO.js.map
|
|
@@ -182,6 +182,21 @@ function assertPromptPartsWithinCap(parts, maxBytes = INLINE_PARTS_MAX_BYTES) {
|
|
|
182
182
|
"PROMPT_PARTS_TOO_LARGE"
|
|
183
183
|
);
|
|
184
184
|
}
|
|
185
|
+
function isAgentMention(mention) {
|
|
186
|
+
return mention.kind === "agent";
|
|
187
|
+
}
|
|
188
|
+
function fileMentionsOf(mentions) {
|
|
189
|
+
return mentions.filter((mention) => !isAgentMention(mention));
|
|
190
|
+
}
|
|
191
|
+
function agentMentionsOf(mentions) {
|
|
192
|
+
return mentions.filter(isAgentMention);
|
|
193
|
+
}
|
|
194
|
+
var AGENT_HANDLE_PATTERN = /^[a-z0-9][a-z0-9-]{0,62}$/;
|
|
195
|
+
function agentHandle(name) {
|
|
196
|
+
const handle = name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 63).replace(/-+$/, "");
|
|
197
|
+
return handle || "agent";
|
|
198
|
+
}
|
|
199
|
+
var AGENT_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
|
|
185
200
|
var MENTION_IMAGE_MEDIA_TYPES = /* @__PURE__ */ new Map([
|
|
186
201
|
[".png", "image/png"],
|
|
187
202
|
[".jpg", "image/jpeg"],
|
|
@@ -207,7 +222,7 @@ function mentionKindForPath(path) {
|
|
|
207
222
|
}
|
|
208
223
|
function fileMentionsToParts(mentions, opts = {}) {
|
|
209
224
|
const resolvePath = opts.resolvePath ?? ((path) => path);
|
|
210
|
-
return mentions.map((mention) => {
|
|
225
|
+
return fileMentionsOf(mentions).map((mention) => {
|
|
211
226
|
const mediaType = mediaTypeForMentionPath(mention.path);
|
|
212
227
|
const part = {
|
|
213
228
|
type: mediaType ? "image" : "file",
|
|
@@ -219,8 +234,9 @@ function fileMentionsToParts(mentions, opts = {}) {
|
|
|
219
234
|
});
|
|
220
235
|
}
|
|
221
236
|
function buildMentionPromptBlock(mentions) {
|
|
222
|
-
|
|
223
|
-
|
|
237
|
+
const files = mentions.filter((m) => m.kind !== "agent");
|
|
238
|
+
if (files.length === 0) return "";
|
|
239
|
+
const lines = files.map((m) => `- ${m.name} (${m.path})`);
|
|
224
240
|
return `
|
|
225
241
|
|
|
226
242
|
Mentioned files \u2014 read them from these paths:
|
|
@@ -278,22 +294,45 @@ function parseFileMention(value, index) {
|
|
|
278
294
|
}
|
|
279
295
|
return { path: record.path, name, ...typeof size === "number" ? { size } : {} };
|
|
280
296
|
}
|
|
281
|
-
function
|
|
297
|
+
function parseMentions(raw) {
|
|
282
298
|
if (raw === void 0 || raw === null) return [];
|
|
283
299
|
if (!Array.isArray(raw)) throw new ChatTurnInputError("mentions must be an array");
|
|
284
300
|
if (raw.length > MENTION_MAX_COUNT) {
|
|
285
301
|
throw new ChatTurnInputError(`mentions must not exceed ${MENTION_MAX_COUNT} entries`);
|
|
286
302
|
}
|
|
287
303
|
const mentions = [];
|
|
288
|
-
const
|
|
304
|
+
const seen = /* @__PURE__ */ new Set();
|
|
289
305
|
for (let index = 0; index < raw.length; index += 1) {
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
306
|
+
const entry = raw[index];
|
|
307
|
+
const mention = entry && typeof entry === "object" && entry.kind === "agent" ? parseAgentMention(entry, index) : parseFileMention(raw[index], index);
|
|
308
|
+
const key = isAgentMention(mention) ? `agent:${mention.agentId}` : `file:${mention.path}`;
|
|
309
|
+
if (seen.has(key)) continue;
|
|
310
|
+
seen.add(key);
|
|
293
311
|
mentions.push(mention);
|
|
294
312
|
}
|
|
295
313
|
return mentions;
|
|
296
314
|
}
|
|
315
|
+
function parseFileMentions(raw) {
|
|
316
|
+
return fileMentionsOf(parseMentions(raw));
|
|
317
|
+
}
|
|
318
|
+
function parseAgentMention(record, index) {
|
|
319
|
+
const agentId = record.agentId;
|
|
320
|
+
if (typeof agentId !== "string" || !AGENT_ID_PATTERN.test(agentId)) {
|
|
321
|
+
throw new ChatTurnInputError(`mentions[${index}].agentId must be 1\u2013128 letters, digits, dots, colons, underscores or hyphens`);
|
|
322
|
+
}
|
|
323
|
+
const handle = record.handle;
|
|
324
|
+
if (typeof handle !== "string" || !AGENT_HANDLE_PATTERN.test(handle)) {
|
|
325
|
+
throw new ChatTurnInputError(`mentions[${index}].handle must be lowercase letters, digits and hyphens`);
|
|
326
|
+
}
|
|
327
|
+
const name = record.name;
|
|
328
|
+
if (typeof name !== "string" || !name.trim()) {
|
|
329
|
+
throw new ChatTurnInputError(`mentions[${index}].name must be a non-empty string`);
|
|
330
|
+
}
|
|
331
|
+
if (name.length > MAX_MENTION_NAME_LENGTH) {
|
|
332
|
+
throw new ChatTurnInputError(`mentions[${index}].name must not exceed ${MAX_MENTION_NAME_LENGTH} characters`);
|
|
333
|
+
}
|
|
334
|
+
return { kind: "agent", agentId, handle, name: name.trim() };
|
|
335
|
+
}
|
|
297
336
|
function parseChatTurnParts(raw) {
|
|
298
337
|
if (raw === void 0 || raw === null) return [];
|
|
299
338
|
if (!Array.isArray(raw)) throw new ChatTurnInputError("parts must be an array");
|
|
@@ -358,13 +397,19 @@ export {
|
|
|
358
397
|
ChatTurnInputError,
|
|
359
398
|
promptPartsByteSize,
|
|
360
399
|
assertPromptPartsWithinCap,
|
|
400
|
+
isAgentMention,
|
|
401
|
+
fileMentionsOf,
|
|
402
|
+
agentMentionsOf,
|
|
403
|
+
AGENT_HANDLE_PATTERN,
|
|
404
|
+
agentHandle,
|
|
361
405
|
mediaTypeForMentionPath,
|
|
362
406
|
mentionKindForPath,
|
|
363
407
|
fileMentionsToParts,
|
|
364
408
|
buildMentionPromptBlock,
|
|
365
409
|
MENTION_MAX_COUNT,
|
|
366
410
|
validateSandboxMentionPath,
|
|
411
|
+
parseMentions,
|
|
367
412
|
parseFileMentions,
|
|
368
413
|
parseChatTurnParts
|
|
369
414
|
};
|
|
370
|
-
//# sourceMappingURL=chunk-
|
|
415
|
+
//# sourceMappingURL=chunk-K2JPSXKI.js.map
|