@burdenoff/microfe-labsofscience 2026.801.3 → 2026.820.1
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/labsofscience/components/MetricsCard.d.ts +1 -2
- package/dist/labsofscience/components/MetricsCard.d.ts.map +1 -1
- package/dist/labsofscience/components/MetricsCard.js.map +1 -1
- package/dist/services/createSandboxAssistantTransport.js +6 -6
- package/dist/services/createSandboxAssistantTransport.js.map +1 -1
- package/dist/utils/pageContext.d.ts +13 -0
- package/dist/utils/pageContext.d.ts.map +1 -1
- package/dist/utils/pageContext.js +89 -26
- package/dist/utils/pageContext.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
2
|
import { TrendDirection } from '../types';
|
|
3
3
|
|
|
4
|
-
interface MetricsCardProps {
|
|
4
|
+
export interface MetricsCardProps {
|
|
5
5
|
icon: ReactNode;
|
|
6
6
|
value: string | number;
|
|
7
7
|
label: string;
|
|
@@ -12,5 +12,4 @@ interface MetricsCardProps {
|
|
|
12
12
|
className?: string;
|
|
13
13
|
}
|
|
14
14
|
export declare const MetricsCard: FC<MetricsCardProps>;
|
|
15
|
-
export {};
|
|
16
15
|
//# sourceMappingURL=MetricsCard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetricsCard.d.ts","sourceRoot":"","sources":["../../../src/labsofscience/components/MetricsCard.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAI3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,
|
|
1
|
+
{"version":3,"file":"MetricsCard.d.ts","sourceRoot":"","sources":["../../../src/labsofscience/components/MetricsCard.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAI3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAQD,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAmC5C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetricsCard.js","names":[],"sources":["../../../src/labsofscience/components/MetricsCard.tsx"],"sourcesContent":["/**\n * Metrics Card Component\n * @module labsofscience/components\n */\n\nimport type { FC, ReactNode } from 'react';\nimport { TrendingUp, TrendingDown, Minus } from 'lucide-react';\nimport { GlassCard } from '@burdenoff/fe-libs/ui';\nimport { cn } from '../utils/cn';\nimport type { TrendDirection } from '../types';\n\
|
|
1
|
+
{"version":3,"file":"MetricsCard.js","names":[],"sources":["../../../src/labsofscience/components/MetricsCard.tsx"],"sourcesContent":["/**\n * Metrics Card Component\n * @module labsofscience/components\n */\n\nimport type { FC, ReactNode } from 'react';\nimport { TrendingUp, TrendingDown, Minus } from 'lucide-react';\nimport { GlassCard } from '@burdenoff/fe-libs/ui';\nimport { cn } from '../utils/cn';\nimport type { TrendDirection } from '../types';\n\nexport interface MetricsCardProps {\n icon: ReactNode;\n value: string | number;\n label: string;\n trend?: TrendDirection;\n trendValue?: string;\n /** Promote the single hero KPI on a page to the glass treatment with glow. */\n featured?: boolean;\n className?: string;\n}\n\nconst trendConfig: Record<TrendDirection, { icon: typeof TrendingUp; color: string }> = {\n up: { icon: TrendingUp, color: 'text-status-success-text' },\n down: { icon: TrendingDown, color: 'text-status-error-text' },\n neutral: { icon: Minus, color: 'text-text-secondary' },\n};\n\nexport const MetricsCard: FC<MetricsCardProps> = ({\n icon,\n value,\n label,\n trend,\n trendValue,\n featured = false,\n className,\n}) => {\n const trendInfo = trend ? trendConfig[trend] : null;\n const TrendIcon = trendInfo?.icon;\n\n return (\n <GlassCard\n treatment={featured ? 'glass' : 'metric'}\n glow={featured}\n className={cn('border-border-seam p-6', className)}\n >\n <div className=\"flex items-center justify-between\">\n <div className=\"flex size-9 items-center justify-center rounded-lg bg-[var(--color-accent-soft)] text-text-primary [&>svg]:h-4 [&>svg]:w-4\">\n {icon}\n </div>\n {trend && trendInfo && TrendIcon && (\n <div className={cn('flex items-center gap-1 text-xs font-medium', trendInfo.color)}>\n <TrendIcon className=\"h-3.5 w-3.5\" />\n {trendValue && <span className=\"tabular-nums\">{trendValue}</span>}\n </div>\n )}\n </div>\n <div className=\"mt-3\">\n <p className=\"text-2xl font-bold tabular-nums text-text-primary\">{value}</p>\n <p className=\"mt-1 text-sm text-text-secondary\">{label}</p>\n </div>\n </GlassCard>\n );\n};\n"],"mappings":";;;;;AAsBA,IAAM,IAAkF;CACtF,IAAI;EAAE,MAAM;EAAY,OAAO;CAA2B;CAC1D,MAAM;EAAE,MAAM;EAAc,OAAO;CAAyB;CAC5D,SAAS;EAAE,MAAM;EAAO,OAAO;CAAsB;AACvD,GAEa,KAAqC,EAChD,SACA,UACA,UACA,UACA,eACA,cAAW,IACX,mBACI;CACJ,IAAM,IAAY,IAAQ,EAAY,KAAS,MACzC,IAAY,GAAW;CAE7B,OACE,kBAAC,GAAD;EACE,WAAW,IAAW,UAAU;EAChC,MAAM;EACN,WAAW,EAAG,0BAA0B,CAAS;YAHnD,CAKE,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,OAAD;IAAK,WAAU;cACZ;GACE,CAAA,GACJ,KAAS,KAAa,KACrB,kBAAC,OAAD;IAAK,WAAW,EAAG,+CAA+C,EAAU,KAAK;cAAjF,CACE,kBAAC,GAAD,EAAW,WAAU,cAAe,CAAA,GACnC,KAAc,kBAAC,QAAD;KAAM,WAAU;eAAgB;IAAiB,CAAA,CAC7D;KAEJ;MACL,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,KAAD;IAAG,WAAU;cAAqD;GAAS,CAAA,GAC3E,kBAAC,KAAD;IAAG,WAAU;cAAoC;GAAS,CAAA,CACvD;IACI;;AAEf"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { gatherPageContext as e } from "../utils/pageContext.js";
|
|
2
|
-
import { useSandboxAssistantTransport as
|
|
1
|
+
import { gatherPageContext as e, toAgentPageContext as t } from "../utils/pageContext.js";
|
|
2
|
+
import { useSandboxAssistantTransport as n } from "@burdenoff/fe-libs/shared/assistant";
|
|
3
3
|
//#region src/services/createSandboxAssistantTransport.ts
|
|
4
|
-
function
|
|
5
|
-
return
|
|
4
|
+
function r() {
|
|
5
|
+
return n({
|
|
6
6
|
product: "labsofscience",
|
|
7
|
-
gatherPageContext: e,
|
|
7
|
+
gatherPageContext: () => t(e()),
|
|
8
8
|
enableCredits: !0
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
|
12
|
-
export {
|
|
12
|
+
export { r as useSandboxAssistantTransport };
|
|
13
13
|
|
|
14
14
|
//# sourceMappingURL=createSandboxAssistantTransport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSandboxAssistantTransport.js","names":[],"sources":["../../src/services/createSandboxAssistantTransport.ts"],"sourcesContent":["/**\n * labsofscience adapter for the shared fe-libs AssistantWidget transport.\n *\n * The sandbox lifecycle + poll/stream loop now lives in\n * `@burdenoff/fe-libs/shared/assistant` (one implementation for all products);\n * this is a thin wrapper. The exported name/shape are unchanged so app-shell\n * imports don't move. The public return type is a LOCALLY-declared structural\n * mirror — never re-export fe-libs types (vite-plugin-dts path rewriting).\n */\n\nimport { useSandboxAssistantTransport as useSharedTransport } from '@burdenoff/fe-libs/shared/assistant';\nimport { gatherPageContext } from '../utils/pageContext';\n\ninterface AssistantSendArgs {\n prompt: string;\n onProgress: (partialText: string) => void;\n signal: AbortSignal;\n}\n\nexport interface AssistantTransport {\n sendPrompt: (args: AssistantSendArgs) => Promise<{ text: string }>;\n prewarm?: (level?: 'probe' | 'full') => void;\n suspend?: () => void;\n}\n\nexport function useSandboxAssistantTransport(): AssistantTransport {\n return useSharedTransport({\n product: 'labsofscience',\n gatherPageContext: gatherPageContext,\n enableCredits: true,\n });\n}\n"],"mappings":";;;AAyBA,SAAgB,IAAmD;CACjE,OAAO,EAAmB;EACxB,SAAS;
|
|
1
|
+
{"version":3,"file":"createSandboxAssistantTransport.js","names":[],"sources":["../../src/services/createSandboxAssistantTransport.ts"],"sourcesContent":["/**\n * labsofscience adapter for the shared fe-libs AssistantWidget transport.\n *\n * The sandbox lifecycle + poll/stream loop now lives in\n * `@burdenoff/fe-libs/shared/assistant` (one implementation for all products);\n * this is a thin wrapper. The exported name/shape are unchanged so app-shell\n * imports don't move. The public return type is a LOCALLY-declared structural\n * mirror — never re-export fe-libs types (vite-plugin-dts path rewriting).\n */\n\nimport { useSandboxAssistantTransport as useSharedTransport } from '@burdenoff/fe-libs/shared/assistant';\nimport { gatherPageContext, toAgentPageContext } from '../utils/pageContext';\n\ninterface AssistantSendArgs {\n prompt: string;\n onProgress: (partialText: string) => void;\n signal: AbortSignal;\n}\n\nexport interface AssistantTransport {\n sendPrompt: (args: AssistantSendArgs) => Promise<{ text: string }>;\n prewarm?: (level?: 'probe' | 'full') => void;\n suspend?: () => void;\n}\n\nexport function useSandboxAssistantTransport(): AssistantTransport {\n return useSharedTransport({\n product: 'labsofscience',\n gatherPageContext: () => toAgentPageContext(gatherPageContext()),\n enableCredits: true,\n });\n}\n"],"mappings":";;;AAyBA,SAAgB,IAAmD;CACjE,OAAO,EAAmB;EACxB,SAAS;EACT,yBAAyB,EAAmB,EAAkB,CAAC;EAC/D,eAAe;CACjB,CAAC;AACH"}
|
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Captures the current browser context so the sandbox agent can answer
|
|
5
5
|
* "this experiment", "current dataset", etc. without asking for IDs.
|
|
6
|
+
*
|
|
7
|
+
* The agent filters payloads to an allow-list (`ALLOWED_CONTEXT_KEYS` in
|
|
8
|
+
* `ai-assistant/src/context-loader.ts`). `gatherPageContext()` returns the full
|
|
9
|
+
* local shape; `toAgentPageContext()` strips it down to exactly the keys the
|
|
10
|
+
* agent accepts, so keys like `userAgent` and `timestamp` stay local and no
|
|
11
|
+
* disallowed PII/notebook bodies are forwarded.
|
|
6
12
|
*/
|
|
7
13
|
interface ConversationContextShape {
|
|
8
14
|
entityType?: string;
|
|
@@ -22,6 +28,13 @@ export interface PageContext {
|
|
|
22
28
|
timestamp: string;
|
|
23
29
|
}
|
|
24
30
|
export declare function gatherPageContext(): PageContext;
|
|
31
|
+
/**
|
|
32
|
+
* Filter a local `PageContext` down to the keys the agent allow-lists.
|
|
33
|
+
*
|
|
34
|
+
* This is what the transport actually sends; `userAgent`/`timestamp`/etc. stay
|
|
35
|
+
* in the browser.
|
|
36
|
+
*/
|
|
37
|
+
export declare function toAgentPageContext(ctx: PageContext): Record<string, unknown>;
|
|
25
38
|
export declare function resolveLabsofscienceConversationContext(pathname: string, search: string): ConversationContextShape;
|
|
26
39
|
export {};
|
|
27
40
|
//# sourceMappingURL=pageContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pageContext.d.ts","sourceRoot":"","sources":["../../src/utils/pageContext.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pageContext.d.ts","sourceRoot":"","sources":["../../src/utils/pageContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,UAAU,wBAAwB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AA0BD,wBAAgB,iBAAiB,IAAI,WAAW,CAoB/C;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQ5E;AA6DD,wBAAgB,uCAAuC,CACrD,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,wBAAwB,CA+B1B"}
|
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
//#region src/utils/pageContext.ts
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
var e = /* @__PURE__ */ new Set([
|
|
3
|
+
"currentUrl",
|
|
4
|
+
"currentPage",
|
|
5
|
+
"entityType",
|
|
6
|
+
"entityId",
|
|
7
|
+
"entityName",
|
|
8
|
+
"pageTitle",
|
|
9
|
+
"pageType",
|
|
10
|
+
"activeTab",
|
|
11
|
+
"activeTool",
|
|
12
|
+
"selectedText",
|
|
13
|
+
"workspaceId",
|
|
14
|
+
"workspaceName",
|
|
15
|
+
"projectId",
|
|
16
|
+
"projectName"
|
|
17
|
+
]);
|
|
18
|
+
function t() {
|
|
19
|
+
let e = window.location.href, t = window.location.pathname.split("/").filter(Boolean).slice(0, 3).join("/") || "home", n = a(window.location.pathname, window.location.search);
|
|
4
20
|
return {
|
|
5
21
|
currentUrl: e,
|
|
6
22
|
currentPage: t,
|
|
7
|
-
entityType:
|
|
8
|
-
entityId:
|
|
23
|
+
entityType: n.entityType,
|
|
24
|
+
entityId: n.entityId,
|
|
9
25
|
platform: "labsofscience",
|
|
10
26
|
version: "0.0.0-dev",
|
|
11
27
|
viewportSize: `${window.innerWidth}x${window.innerHeight}`,
|
|
@@ -13,38 +29,85 @@ function e() {
|
|
|
13
29
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
14
30
|
};
|
|
15
31
|
}
|
|
16
|
-
function
|
|
32
|
+
function n(t) {
|
|
33
|
+
let n = {};
|
|
34
|
+
for (let [r, i] of Object.entries(t)) i == null || i === "" || e.has(r) && (n[r] = i);
|
|
35
|
+
return n;
|
|
36
|
+
}
|
|
37
|
+
var r = [
|
|
38
|
+
{
|
|
39
|
+
pattern: /^\/labsofscience\/experiments\/([^/]+)\/runs\/([^/]+)\/?$/,
|
|
40
|
+
entityType: "LABSOFSCIENCE_EXPERIMENT_RUN",
|
|
41
|
+
entityIdGroup: 2,
|
|
42
|
+
metadataFromMatch: (e) => ({ experimentId: e[1] })
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
pattern: /^\/labsofscience\/pipelines\/([^/]+)\/runs\/([^/]+)\/?$/,
|
|
46
|
+
entityType: "LABSOFSCIENCE_PIPELINE_RUN",
|
|
47
|
+
entityIdGroup: 2,
|
|
48
|
+
metadataFromMatch: (e) => ({ pipelineId: e[1] })
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
pattern: /^\/labsofscience\/projects\/([^/]+)\/?$/,
|
|
52
|
+
entityType: "LABSOFSCIENCE_PROJECT"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
pattern: /^\/labsofscience\/experiments\/([^/]+)\/?$/,
|
|
56
|
+
entityType: "LABSOFSCIENCE_EXPERIMENT"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
pattern: /^\/labsofscience\/datasets\/([^/]+)\/?$/,
|
|
60
|
+
entityType: "LABSOFSCIENCE_DATASET"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
pattern: /^\/labsofscience\/protocols\/([^/]+)\/?$/,
|
|
64
|
+
entityType: "LABSOFSCIENCE_PROTOCOL"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
pattern: /^\/labsofscience\/instruments\/([^/]+)\/?$/,
|
|
68
|
+
entityType: "LABSOFSCIENCE_INSTRUMENT"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
pattern: /^\/labsofscience\/inventory\/([^/]+)\/?$/,
|
|
72
|
+
entityType: "LABSOFSCIENCE_INVENTORY_ITEM"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
pattern: /^\/labsofscience\/notebook\/([^/]+)\/?$/,
|
|
76
|
+
entityType: "LABSOFSCIENCE_NOTEBOOK_ENTRY"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
pattern: /^\/labsofscience\/pipelines\/?$/,
|
|
80
|
+
entityType: "LABSOFSCIENCE_PIPELINE"
|
|
81
|
+
}
|
|
82
|
+
];
|
|
83
|
+
function i(e, t) {
|
|
17
84
|
return t.match(e);
|
|
18
85
|
}
|
|
19
|
-
function
|
|
20
|
-
let
|
|
21
|
-
for (let
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
[
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (i) return {
|
|
33
|
-
entityType: r,
|
|
34
|
-
entityId: i[1],
|
|
35
|
-
metadata: { routePattern: n.source }
|
|
86
|
+
function a(e, t) {
|
|
87
|
+
let n = new URLSearchParams(t);
|
|
88
|
+
for (let t of r) {
|
|
89
|
+
let n = i(t.pattern, e);
|
|
90
|
+
if (!n) continue;
|
|
91
|
+
let r = n[t.entityIdGroup ?? 1], a = t.metadataFromMatch?.(n) ?? {};
|
|
92
|
+
return {
|
|
93
|
+
entityType: t.entityType,
|
|
94
|
+
entityId: r,
|
|
95
|
+
metadata: {
|
|
96
|
+
routePattern: t.pattern.source,
|
|
97
|
+
...a
|
|
98
|
+
}
|
|
36
99
|
};
|
|
37
100
|
}
|
|
38
|
-
let
|
|
101
|
+
let a = n.get("tab") ?? (() => {
|
|
39
102
|
let t = e.split("/").filter(Boolean);
|
|
40
103
|
return t.length > 2 ? t[t.length - 1] : void 0;
|
|
41
104
|
})();
|
|
42
105
|
return {
|
|
43
|
-
activeTab:
|
|
44
|
-
metadata:
|
|
106
|
+
activeTab: a ?? void 0,
|
|
107
|
+
metadata: a ? { activeTab: a } : void 0
|
|
45
108
|
};
|
|
46
109
|
}
|
|
47
110
|
//#endregion
|
|
48
|
-
export {
|
|
111
|
+
export { t as gatherPageContext, a as resolveLabsofscienceConversationContext, n as toAgentPageContext };
|
|
49
112
|
|
|
50
113
|
//# sourceMappingURL=pageContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pageContext.js","names":[],"sources":["../../src/utils/pageContext.ts"],"sourcesContent":["/**\n * Page context gathering for the LabsOfScience assistant.\n *\n * Captures the current browser context so the sandbox agent can answer\n * \"this experiment\", \"current dataset\", etc. without asking for IDs.\n */\n\ninterface ConversationContextShape {\n entityType?: string;\n entityId?: string;\n activeTab?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface PageContext {\n currentUrl: string;\n currentPage: string;\n entityType?: string;\n entityId?: string;\n platform: string;\n version: string;\n viewportSize: string;\n userAgent: string;\n timestamp: string;\n}\n\nexport function gatherPageContext(): PageContext {\n const url = window.location.href;\n const pathSegments = window.location.pathname.split('/').filter(Boolean);\n const currentPage = pathSegments.slice(0, 3).join('/') || 'home';\n const entity = resolveLabsofscienceConversationContext(\n window.location.pathname,\n window.location.search\n );\n\n return {\n currentUrl: url,\n currentPage,\n entityType: entity.entityType,\n entityId: entity.entityId,\n platform: 'labsofscience',\n version: import.meta.env.VITE_APP_VERSION ?? '0.0.0-dev',\n viewportSize: `${window.innerWidth}x${window.innerHeight}`,\n userAgent: navigator.userAgent,\n timestamp: new Date().toISOString(),\n };\n}\n\
|
|
1
|
+
{"version":3,"file":"pageContext.js","names":[],"sources":["../../src/utils/pageContext.ts"],"sourcesContent":["/**\n * Page context gathering for the LabsOfScience assistant.\n *\n * Captures the current browser context so the sandbox agent can answer\n * \"this experiment\", \"current dataset\", etc. without asking for IDs.\n *\n * The agent filters payloads to an allow-list (`ALLOWED_CONTEXT_KEYS` in\n * `ai-assistant/src/context-loader.ts`). `gatherPageContext()` returns the full\n * local shape; `toAgentPageContext()` strips it down to exactly the keys the\n * agent accepts, so keys like `userAgent` and `timestamp` stay local and no\n * disallowed PII/notebook bodies are forwarded.\n */\n\ninterface ConversationContextShape {\n entityType?: string;\n entityId?: string;\n activeTab?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface PageContext {\n currentUrl: string;\n currentPage: string;\n entityType?: string;\n entityId?: string;\n platform: string;\n version: string;\n viewportSize: string;\n userAgent: string;\n timestamp: string;\n}\n\n/**\n * Mirror of the agent-side `ALLOWED_CONTEXT_KEYS` set.\n *\n * Keep this in sync with `~/products/wspace/sandbox/ai-assistant/src/context-loader.ts`.\n * Only these keys are forwarded to the model; everything else is dropped.\n */\nconst AGENT_ALLOWED_CONTEXT_KEYS = new Set([\n // cross-product contract\n 'currentUrl',\n 'currentPage',\n 'entityType',\n 'entityId',\n 'entityName',\n 'pageTitle',\n 'pageType',\n 'activeTab',\n 'activeTool',\n 'selectedText',\n 'workspaceId',\n 'workspaceName',\n 'projectId',\n 'projectName',\n]);\n\nexport function gatherPageContext(): PageContext {\n const url = window.location.href;\n const pathSegments = window.location.pathname.split('/').filter(Boolean);\n const currentPage = pathSegments.slice(0, 3).join('/') || 'home';\n const entity = resolveLabsofscienceConversationContext(\n window.location.pathname,\n window.location.search\n );\n\n return {\n currentUrl: url,\n currentPage,\n entityType: entity.entityType,\n entityId: entity.entityId,\n platform: 'labsofscience',\n version: import.meta.env.VITE_APP_VERSION ?? '0.0.0-dev',\n viewportSize: `${window.innerWidth}x${window.innerHeight}`,\n userAgent: navigator.userAgent,\n timestamp: new Date().toISOString(),\n };\n}\n\n/**\n * Filter a local `PageContext` down to the keys the agent allow-lists.\n *\n * This is what the transport actually sends; `userAgent`/`timestamp`/etc. stay\n * in the browser.\n */\nexport function toAgentPageContext(ctx: PageContext): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(ctx)) {\n if (value === undefined || value === null || value === '') continue;\n if (!AGENT_ALLOWED_CONTEXT_KEYS.has(key)) continue;\n out[key] = value;\n }\n return out;\n}\n\ninterface RouteContextRule {\n pattern: RegExp;\n entityType: string;\n /** Which regex capture group holds the entity id. Defaults to 1. */\n entityIdGroup?: number;\n /** Extra metadata derived from the regex match (parent ids, pattern name, ...). */\n metadataFromMatch?: (match: RegExpMatchArray) => Record<string, unknown>;\n}\n\n/**\n * Route → entity mapping for LabsOfScience.\n *\n * Order matters: more specific patterns must precede the general pattern they\n * would otherwise be swallowed by (e.g. `/experiments/:id/runs/:runId` before\n * `/experiments/:id`).\n */\nconst ROUTE_CONTEXT_RULES: RouteContextRule[] = [\n // Run detail nested under an experiment (most specific first).\n {\n pattern: /^\\/labsofscience\\/experiments\\/([^/]+)\\/runs\\/([^/]+)\\/?$/,\n entityType: 'LABSOFSCIENCE_EXPERIMENT_RUN',\n entityIdGroup: 2,\n metadataFromMatch: (match) => ({ experimentId: match[1] }),\n },\n // Pipeline run detail nested under a pipeline.\n {\n pattern: /^\\/labsofscience\\/pipelines\\/([^/]+)\\/runs\\/([^/]+)\\/?$/,\n entityType: 'LABSOFSCIENCE_PIPELINE_RUN',\n entityIdGroup: 2,\n metadataFromMatch: (match) => ({ pipelineId: match[1] }),\n },\n\n // Detail routes.\n { pattern: /^\\/labsofscience\\/projects\\/([^/]+)\\/?$/, entityType: 'LABSOFSCIENCE_PROJECT' },\n { pattern: /^\\/labsofscience\\/experiments\\/([^/]+)\\/?$/, entityType: 'LABSOFSCIENCE_EXPERIMENT' },\n { pattern: /^\\/labsofscience\\/datasets\\/([^/]+)\\/?$/, entityType: 'LABSOFSCIENCE_DATASET' },\n { pattern: /^\\/labsofscience\\/protocols\\/([^/]+)\\/?$/, entityType: 'LABSOFSCIENCE_PROTOCOL' },\n { pattern: /^\\/labsofscience\\/instruments\\/([^/]+)\\/?$/, entityType: 'LABSOFSCIENCE_INSTRUMENT' },\n {\n pattern: /^\\/labsofscience\\/inventory\\/([^/]+)\\/?$/,\n entityType: 'LABSOFSCIENCE_INVENTORY_ITEM',\n },\n {\n pattern: /^\\/labsofscience\\/notebook\\/([^/]+)\\/?$/,\n entityType: 'LABSOFSCIENCE_NOTEBOOK_ENTRY',\n },\n\n // Pipelines has no detail route (runs open in an in-page dialog, not a URL)\n // but the list page itself is a meaningful context.\n {\n pattern: /^\\/labsofscience\\/pipelines\\/?$/,\n entityType: 'LABSOFSCIENCE_PIPELINE',\n },\n];\n\nfunction matchPath(pattern: RegExp, pathname: string): RegExpMatchArray | null {\n return pathname.match(pattern);\n}\n\nexport function resolveLabsofscienceConversationContext(\n pathname: string,\n search: string\n): ConversationContextShape {\n const params = new URLSearchParams(search);\n\n for (const rule of ROUTE_CONTEXT_RULES) {\n const match = matchPath(rule.pattern, pathname);\n if (!match) continue;\n\n const entityId = match[rule.entityIdGroup ?? 1];\n const extraMetadata = rule.metadataFromMatch?.(match) ?? {};\n\n return {\n entityType: rule.entityType,\n entityId,\n metadata: {\n routePattern: rule.pattern.source,\n ...extraMetadata,\n },\n };\n }\n\n const activeTab =\n params.get('tab') ??\n (() => {\n const segments = pathname.split('/').filter(Boolean);\n return segments.length > 2 ? segments[segments.length - 1] : undefined;\n })();\n\n return {\n activeTab: activeTab ?? undefined,\n metadata: activeTab ? { activeTab } : undefined,\n };\n}\n"],"mappings":";AAsCA,IAAM,oBAA6B,IAAI,IAAI;CAEzC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgB,IAAiC;CAC/C,IAAM,IAAM,OAAO,SAAS,MAEtB,IADe,OAAO,SAAS,SAAS,MAAM,GAAG,CAAC,CAAC,OAAO,OAC5C,CAAA,CAAa,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,KAAK,QACpD,IAAS,EACb,OAAO,SAAS,UAChB,OAAO,SAAS,MAClB;CAEA,OAAO;EACL,YAAY;EACZ;EACA,YAAY,EAAO;EACnB,UAAU,EAAO;EACjB,UAAU;EACV,SAA6C;EAC7C,cAAc,GAAG,OAAO,WAAW,GAAG,OAAO;EAC7C,WAAW,UAAU;EACrB,4BAAW,IAAI,KAAK,EAAA,CAAE,YAAY;CACpC;AACF;AAQA,SAAgB,EAAmB,GAA2C;CAC5E,IAAM,IAA+B,CAAC;CACtC,KAAK,IAAM,CAAC,GAAK,MAAU,OAAO,QAAQ,CAAG,GACvC,KAAiC,QAAQ,MAAU,MAClD,EAA2B,IAAI,CAAG,MACvC,EAAI,KAAO;CAEb,OAAO;AACT;AAkBA,IAAM,IAA0C;CAE9C;EACE,SAAS;EACT,YAAY;EACZ,eAAe;EACf,oBAAoB,OAAW,EAAE,cAAc,EAAM,GAAG;CAC1D;CAEA;EACE,SAAS;EACT,YAAY;EACZ,eAAe;EACf,oBAAoB,OAAW,EAAE,YAAY,EAAM,GAAG;CACxD;CAGA;EAAE,SAAS;EAA2C,YAAY;CAAwB;CAC1F;EAAE,SAAS;EAA8C,YAAY;CAA2B;CAChG;EAAE,SAAS;EAA2C,YAAY;CAAwB;CAC1F;EAAE,SAAS;EAA4C,YAAY;CAAyB;CAC5F;EAAE,SAAS;EAA8C,YAAY;CAA2B;CAChG;EACE,SAAS;EACT,YAAY;CACd;CACA;EACE,SAAS;EACT,YAAY;CACd;CAIA;EACE,SAAS;EACT,YAAY;CACd;AACF;AAEA,SAAS,EAAU,GAAiB,GAA2C;CAC7E,OAAO,EAAS,MAAM,CAAO;AAC/B;AAEA,SAAgB,EACd,GACA,GAC0B;CAC1B,IAAM,IAAS,IAAI,gBAAgB,CAAM;CAEzC,KAAK,IAAM,KAAQ,GAAqB;EACtC,IAAM,IAAQ,EAAU,EAAK,SAAS,CAAQ;EAC9C,IAAI,CAAC,GAAO;EAEZ,IAAM,IAAW,EAAM,EAAK,iBAAiB,IACvC,IAAgB,EAAK,oBAAoB,CAAK,KAAK,CAAC;EAE1D,OAAO;GACL,YAAY,EAAK;GACjB;GACA,UAAU;IACR,cAAc,EAAK,QAAQ;IAC3B,GAAG;GACL;EACF;CACF;CAEA,IAAM,IACJ,EAAO,IAAI,KAAK,YACT;EACL,IAAM,IAAW,EAAS,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO;EACnD,OAAO,EAAS,SAAS,IAAI,EAAS,EAAS,SAAS,KAAK,KAAA;CAC/D,EAAA,CAAG;CAEL,OAAO;EACL,WAAW,KAAa,KAAA;EACxB,UAAU,IAAY,EAAE,aAAU,IAAI,KAAA;CACxC;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@burdenoff/microfe-labsofscience",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.820.1",
|
|
4
4
|
"description": "Burdenoff LabsOfScience Microfrontend",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"zustand": "^5.0.0"
|
|
106
106
|
},
|
|
107
107
|
"publishConfig": {
|
|
108
|
-
"access": "
|
|
108
|
+
"access": "public"
|
|
109
109
|
},
|
|
110
110
|
"overrides": {
|
|
111
111
|
"@burdenoff/fe-libs": "2026.801.1",
|