@ggui-ai/protocol 0.1.0-rc.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/LICENSE +201 -0
- package/README.md +46 -0
- package/dist/bridge/invoke-agent.d.ts +65 -0
- package/dist/bridge/invoke-agent.d.ts.map +1 -0
- package/dist/bridge/invoke-agent.js +113 -0
- package/dist/envelope-adapters.d.ts +24 -0
- package/dist/envelope-adapters.d.ts.map +1 -0
- package/dist/envelope-adapters.js +14 -0
- package/dist/envelopes/builders.d.ts +145 -0
- package/dist/envelopes/builders.d.ts.map +1 -0
- package/dist/envelopes/builders.js +113 -0
- package/dist/errors/unknown-permission-name.d.ts +12 -0
- package/dist/errors/unknown-permission-name.d.ts.map +1 -0
- package/dist/errors/unknown-permission-name.js +29 -0
- package/dist/errors/version-mismatch.d.ts +55 -0
- package/dist/errors/version-mismatch.d.ts.map +1 -0
- package/dist/errors/version-mismatch.js +52 -0
- package/dist/gadgets/resolve-contract-gadgets.d.ts +93 -0
- package/dist/gadgets/resolve-contract-gadgets.d.ts.map +1 -0
- package/dist/gadgets/resolve-contract-gadgets.js +119 -0
- package/dist/gadgets/stdlib-gadgets.d.ts +43 -0
- package/dist/gadgets/stdlib-gadgets.d.ts.map +1 -0
- package/dist/gadgets/stdlib-gadgets.js +161 -0
- package/dist/iframe-bridge.d.ts +63 -0
- package/dist/iframe-bridge.d.ts.map +1 -0
- package/dist/iframe-bridge.js +166 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +79 -0
- package/dist/integrations/mcp-apps.d.ts +1218 -0
- package/dist/integrations/mcp-apps.d.ts.map +1 -0
- package/dist/integrations/mcp-apps.js +427 -0
- package/dist/navigation/index.d.ts +3 -0
- package/dist/navigation/index.d.ts.map +1 -0
- package/dist/navigation/index.js +1 -0
- package/dist/navigation/stack-navigation.d.ts +55 -0
- package/dist/navigation/stack-navigation.d.ts.map +1 -0
- package/dist/navigation/stack-navigation.js +80 -0
- package/dist/recommended-prompts.d.ts +56 -0
- package/dist/recommended-prompts.d.ts.map +1 -0
- package/dist/recommended-prompts.js +55 -0
- package/dist/registry/blueprint-key.d.ts +9 -0
- package/dist/registry/blueprint-key.d.ts.map +1 -0
- package/dist/registry/blueprint-key.js +28 -0
- package/dist/registry/canonicalize-contract.d.ts +35 -0
- package/dist/registry/canonicalize-contract.d.ts.map +1 -0
- package/dist/registry/canonicalize-contract.js +166 -0
- package/dist/registry/summarize-contract.d.ts +46 -0
- package/dist/registry/summarize-contract.d.ts.map +1 -0
- package/dist/registry/summarize-contract.js +63 -0
- package/dist/schema-learning/derive-contract.d.ts +67 -0
- package/dist/schema-learning/derive-contract.d.ts.map +1 -0
- package/dist/schema-learning/derive-contract.js +117 -0
- package/dist/schema-learning/merge.d.ts +32 -0
- package/dist/schema-learning/merge.d.ts.map +1 -0
- package/dist/schema-learning/merge.js +146 -0
- package/dist/schemas/blueprint.d.ts +32 -0
- package/dist/schemas/blueprint.d.ts.map +1 -0
- package/dist/schemas/blueprint.js +92 -0
- package/dist/schemas/data-contract.d.ts +750 -0
- package/dist/schemas/data-contract.d.ts.map +1 -0
- package/dist/schemas/data-contract.js +663 -0
- package/dist/schemas/gadget-name-grammar.d.ts +29 -0
- package/dist/schemas/gadget-name-grammar.d.ts.map +1 -0
- package/dist/schemas/gadget-name-grammar.js +28 -0
- package/dist/schemas/handshake-suggestion.d.ts +46 -0
- package/dist/schemas/handshake-suggestion.d.ts.map +1 -0
- package/dist/schemas/handshake-suggestion.js +107 -0
- package/dist/schemas/invoke.d.ts +337 -0
- package/dist/schemas/invoke.d.ts.map +1 -0
- package/dist/schemas/invoke.js +169 -0
- package/dist/schemas/mcp.d.ts +301 -0
- package/dist/schemas/mcp.d.ts.map +1 -0
- package/dist/schemas/mcp.js +373 -0
- package/dist/schemas/ops-blueprint.d.ts +176 -0
- package/dist/schemas/ops-blueprint.d.ts.map +1 -0
- package/dist/schemas/ops-blueprint.js +259 -0
- package/dist/schemas/sync-check.d.ts +11 -0
- package/dist/schemas/sync-check.d.ts.map +1 -0
- package/dist/schemas/sync-check.js +60 -0
- package/dist/screen-blueprints/define.d.ts +22 -0
- package/dist/screen-blueprints/define.d.ts.map +1 -0
- package/dist/screen-blueprints/define.js +3 -0
- package/dist/screen-blueprints/index.d.ts +4 -0
- package/dist/screen-blueprints/index.d.ts.map +1 -0
- package/dist/screen-blueprints/index.js +3 -0
- package/dist/screen-blueprints/match.d.ts +35 -0
- package/dist/screen-blueprints/match.d.ts.map +1 -0
- package/dist/screen-blueprints/match.js +51 -0
- package/dist/screen-blueprints/types.d.ts +164 -0
- package/dist/screen-blueprints/types.d.ts.map +1 -0
- package/dist/screen-blueprints/types.js +1 -0
- package/dist/stream/stream-parser.d.ts +62 -0
- package/dist/stream/stream-parser.d.ts.map +1 -0
- package/dist/stream/stream-parser.js +199 -0
- package/dist/transport/websocket.d.ts +178 -0
- package/dist/transport/websocket.d.ts.map +1 -0
- package/dist/transport/websocket.js +1 -0
- package/dist/types/app-config.d.ts +61 -0
- package/dist/types/app-config.d.ts.map +1 -0
- package/dist/types/app-config.js +1 -0
- package/dist/types/auth.d.ts +61 -0
- package/dist/types/auth.d.ts.map +1 -0
- package/dist/types/auth.js +1 -0
- package/dist/types/blueprint.d.ts +206 -0
- package/dist/types/blueprint.d.ts.map +1 -0
- package/dist/types/blueprint.js +1 -0
- package/dist/types/canvas-lifecycle.d.ts +105 -0
- package/dist/types/canvas-lifecycle.d.ts.map +1 -0
- package/dist/types/canvas-lifecycle.js +38 -0
- package/dist/types/capabilities.d.ts +40 -0
- package/dist/types/capabilities.d.ts.map +1 -0
- package/dist/types/capabilities.js +19 -0
- package/dist/types/contract-inference.d.ts +401 -0
- package/dist/types/contract-inference.d.ts.map +1 -0
- package/dist/types/contract-inference.js +44 -0
- package/dist/types/credential.d.ts +41 -0
- package/dist/types/credential.d.ts.map +1 -0
- package/dist/types/credential.js +32 -0
- package/dist/types/data-bindings.d.ts +322 -0
- package/dist/types/data-bindings.d.ts.map +1 -0
- package/dist/types/data-bindings.js +29 -0
- package/dist/types/data-contract.d.ts +1296 -0
- package/dist/types/data-contract.d.ts.map +1 -0
- package/dist/types/data-contract.js +111 -0
- package/dist/types/events.d.ts +182 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +8 -0
- package/dist/types/feedback.d.ts +24 -0
- package/dist/types/feedback.d.ts.map +1 -0
- package/dist/types/feedback.js +7 -0
- package/dist/types/gadget.d.ts +121 -0
- package/dist/types/gadget.d.ts.map +1 -0
- package/dist/types/gadget.js +24 -0
- package/dist/types/handshake-suggestion.d.ts +264 -0
- package/dist/types/handshake-suggestion.d.ts.map +1 -0
- package/dist/types/handshake-suggestion.js +70 -0
- package/dist/types/host-context.d.ts +163 -0
- package/dist/types/host-context.d.ts.map +1 -0
- package/dist/types/host-context.js +142 -0
- package/dist/types/interface-context.d.ts +105 -0
- package/dist/types/interface-context.d.ts.map +1 -0
- package/dist/types/interface-context.js +115 -0
- package/dist/types/invoke.d.ts +28 -0
- package/dist/types/invoke.d.ts.map +1 -0
- package/dist/types/invoke.js +7 -0
- package/dist/types/live-channel.d.ts +613 -0
- package/dist/types/live-channel.d.ts.map +1 -0
- package/dist/types/live-channel.js +1 -0
- package/dist/types/llm.d.ts +61 -0
- package/dist/types/llm.d.ts.map +1 -0
- package/dist/types/llm.js +186 -0
- package/dist/types/mcp-proxy.d.ts +67 -0
- package/dist/types/mcp-proxy.d.ts.map +1 -0
- package/dist/types/mcp-proxy.js +46 -0
- package/dist/types/mcp.d.ts +637 -0
- package/dist/types/mcp.d.ts.map +1 -0
- package/dist/types/mcp.js +30 -0
- package/dist/types/openrouter-models.d.ts +22 -0
- package/dist/types/openrouter-models.d.ts.map +1 -0
- package/dist/types/openrouter-models.js +4843 -0
- package/dist/types/region.d.ts +26 -0
- package/dist/types/region.d.ts.map +1 -0
- package/dist/types/region.js +36 -0
- package/dist/types/session.d.ts +419 -0
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/session.js +1 -0
- package/dist/types/thread.d.ts +207 -0
- package/dist/types/thread.d.ts.map +1 -0
- package/dist/types/thread.js +57 -0
- package/dist/types/ui-generator.d.ts +100 -0
- package/dist/types/ui-generator.d.ts.map +1 -0
- package/dist/types/ui-generator.js +53 -0
- package/dist/validation/ajv-runtime.d.ts +140 -0
- package/dist/validation/ajv-runtime.d.ts.map +1 -0
- package/dist/validation/ajv-runtime.js +452 -0
- package/dist/validation/content-hash.d.ts +3 -0
- package/dist/validation/content-hash.d.ts.map +1 -0
- package/dist/validation/content-hash.js +21 -0
- package/dist/validation/contract-validator.d.ts +244 -0
- package/dist/validation/contract-validator.d.ts.map +1 -0
- package/dist/validation/contract-validator.js +711 -0
- package/dist/validation/cross-references.d.ts +105 -0
- package/dist/validation/cross-references.d.ts.map +1 -0
- package/dist/validation/cross-references.js +164 -0
- package/dist/validation/hygiene-rules.d.ts +250 -0
- package/dist/validation/hygiene-rules.d.ts.map +1 -0
- package/dist/validation/hygiene-rules.js +564 -0
- package/dist/validation/lint-contract.d.ts +130 -0
- package/dist/validation/lint-contract.d.ts.map +1 -0
- package/dist/validation/lint-contract.js +225 -0
- package/dist/validation/name-invariants.d.ts +117 -0
- package/dist/validation/name-invariants.d.ts.map +1 -0
- package/dist/validation/name-invariants.js +172 -0
- package/dist/validation/reserved-channels.d.ts +156 -0
- package/dist/validation/reserved-channels.d.ts.map +1 -0
- package/dist/validation/reserved-channels.js +356 -0
- package/dist/validation/resolve-stream-channel.d.ts +78 -0
- package/dist/validation/resolve-stream-channel.d.ts.map +1 -0
- package/dist/validation/resolve-stream-channel.js +64 -0
- package/dist/validation/sanitize-error.d.ts +46 -0
- package/dist/validation/sanitize-error.d.ts.map +1 -0
- package/dist/validation/sanitize-error.js +88 -0
- package/dist/validation/schema-compat-invariants.d.ts +140 -0
- package/dist/validation/schema-compat-invariants.d.ts.map +1 -0
- package/dist/validation/schema-compat-invariants.js +220 -0
- package/dist/validation/schema-meta-validation.d.ts +60 -0
- package/dist/validation/schema-meta-validation.d.ts.map +1 -0
- package/dist/validation/schema-meta-validation.js +131 -0
- package/dist/validation/schema-subset.d.ts +165 -0
- package/dist/validation/schema-subset.d.ts.map +1 -0
- package/dist/validation/schema-subset.js +295 -0
- package/dist/validation/ui-security.d.ts +54 -0
- package/dist/validation/ui-security.d.ts.map +1 -0
- package/dist/validation/ui-security.js +138 -0
- package/dist/validation/zod-to-json-schema.d.ts +63 -0
- package/dist/validation/zod-to-json-schema.d.ts.map +1 -0
- package/dist/validation/zod-to-json-schema.js +126 -0
- package/dist/version.d.ts +1458 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +1459 -0
- package/package.json +113 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface Context — device and viewport information for responsive UI generation.
|
|
3
|
+
*
|
|
4
|
+
* Threaded through the full pipeline:
|
|
5
|
+
* Client → WebSocket/MCP → SQS → Queue Consumer → Generator → Prompts
|
|
6
|
+
*
|
|
7
|
+
* Allows Claude to generate UIs adapted to the user's device/viewport.
|
|
8
|
+
*/
|
|
9
|
+
import type { JsonObject } from './data-contract';
|
|
10
|
+
export type PlatformType = 'web' | 'mobile' | 'desktop';
|
|
11
|
+
export type DeviceType = 'phone' | 'tablet' | 'desktop';
|
|
12
|
+
export type Orientation = 'portrait' | 'landscape';
|
|
13
|
+
/**
|
|
14
|
+
* Device category for blueprint variant selection.
|
|
15
|
+
* Each blueprint can have optimized variants per device category.
|
|
16
|
+
*
|
|
17
|
+
* - mobile: viewport width < 768px
|
|
18
|
+
* - tablet: viewport width 768-1023px
|
|
19
|
+
* - desktop: viewport width >= 1024px
|
|
20
|
+
* - spatial: 3D spatial shell (overrides width-based detection)
|
|
21
|
+
*/
|
|
22
|
+
export type DeviceCategory = 'mobile' | 'tablet' | 'desktop' | 'spatial';
|
|
23
|
+
/**
|
|
24
|
+
* Shell type — describes the rendering container for generated UI.
|
|
25
|
+
* The generator uses this to adapt layout, sizing, and interaction patterns.
|
|
26
|
+
*
|
|
27
|
+
* - chat: Inline card in a scrolling chat conversation. Compact, card-sized.
|
|
28
|
+
* - fullscreen: Full-viewport swipeable card. Fill entire screen, immersive.
|
|
29
|
+
* - agent: Character-based shell (R2D2-style). Screen panel + character + thinking bubble.
|
|
30
|
+
* - spatial: 3D spatial panel (future: Meta Glass, Apple Vision Pro). Fixed-size floating panel.
|
|
31
|
+
*/
|
|
32
|
+
export type ShellType = 'chat' | 'fullscreen' | 'agent' | 'spatial';
|
|
33
|
+
/**
|
|
34
|
+
* Viewport dimensions in CSS pixels.
|
|
35
|
+
* Used for responsive breakpoint calculations and layout decisions.
|
|
36
|
+
*
|
|
37
|
+
* Extends {@link JsonObject} for direct JSON serialization over WebSocket.
|
|
38
|
+
*/
|
|
39
|
+
export interface ViewportInfo extends JsonObject {
|
|
40
|
+
/** Width in CSS pixels */
|
|
41
|
+
width: number;
|
|
42
|
+
/** Height in CSS pixels */
|
|
43
|
+
height: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Complete interface context describing the rendering environment.
|
|
47
|
+
* All fields except viewport are optional for graceful degradation.
|
|
48
|
+
*
|
|
49
|
+
* Extends {@link JsonObject} for direct JSON serialization over WebSocket.
|
|
50
|
+
*/
|
|
51
|
+
export interface InterfaceContext extends JsonObject {
|
|
52
|
+
/** Viewport dimensions in CSS pixels */
|
|
53
|
+
viewport: ViewportInfo;
|
|
54
|
+
/** Platform type */
|
|
55
|
+
platform: PlatformType;
|
|
56
|
+
/** Device form factor */
|
|
57
|
+
deviceType: DeviceType;
|
|
58
|
+
/** Screen orientation */
|
|
59
|
+
orientation: Orientation;
|
|
60
|
+
/** Device pixel ratio (for high-DPI rendering decisions) */
|
|
61
|
+
devicePixelRatio?: number;
|
|
62
|
+
/** Whether touch is the primary input method */
|
|
63
|
+
touchPrimary?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Shell type — the rendering container for this UI.
|
|
66
|
+
* Tells the generator how the component will be displayed so it can
|
|
67
|
+
* adapt layout, sizing, spacing, and interaction patterns accordingly.
|
|
68
|
+
*/
|
|
69
|
+
shellType?: ShellType;
|
|
70
|
+
/** User's preferred color scheme */
|
|
71
|
+
colorScheme?: 'light' | 'dark';
|
|
72
|
+
/** Whether the user prefers reduced motion (prefers-reduced-motion) */
|
|
73
|
+
reducedMotion?: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Detect interface context from the browser `window` object.
|
|
77
|
+
*
|
|
78
|
+
* Reads viewport size, device pixel ratio, touch capability, color scheme,
|
|
79
|
+
* and reduced-motion preference. Falls back to {@link defaultInterfaceContext}
|
|
80
|
+
* when called in a non-browser environment (e.g., SSR).
|
|
81
|
+
*
|
|
82
|
+
* @returns Fully populated interface context derived from the browser
|
|
83
|
+
*/
|
|
84
|
+
export declare function detectInterfaceContext(): InterfaceContext;
|
|
85
|
+
/**
|
|
86
|
+
* Default interface context for SSR or when browser detection is unavailable.
|
|
87
|
+
*
|
|
88
|
+
* Returns a standard desktop viewport (1280x800), landscape orientation,
|
|
89
|
+
* non-touch, 1x pixel ratio. Suitable as a safe fallback for server-side
|
|
90
|
+
* rendering where no `window` object exists.
|
|
91
|
+
*
|
|
92
|
+
* @returns A desktop-oriented default context
|
|
93
|
+
*/
|
|
94
|
+
export declare function defaultInterfaceContext(): InterfaceContext;
|
|
95
|
+
/**
|
|
96
|
+
* Derive the device category from an InterfaceContext.
|
|
97
|
+
* Used for blueprint variant selection — determines which optimized
|
|
98
|
+
* version of a blueprint to serve.
|
|
99
|
+
*
|
|
100
|
+
* Priority:
|
|
101
|
+
* 1. If shellType is 'spatial', returns 'spatial' (overrides width)
|
|
102
|
+
* 2. Otherwise, derives from viewport width using standard breakpoints
|
|
103
|
+
*/
|
|
104
|
+
export declare function getDeviceCategory(context: InterfaceContext): DeviceCategory;
|
|
105
|
+
//# sourceMappingURL=interface-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|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,wBAAgB,sBAAsB,IAAI,gBAAgB,CAuBzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,IAAI,gBAAgB,CAS1D;AAMD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,GAAG,cAAc,CAU3E"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface Context — device and viewport information for responsive UI generation.
|
|
3
|
+
*
|
|
4
|
+
* Threaded through the full pipeline:
|
|
5
|
+
* Client → WebSocket/MCP → SQS → Queue Consumer → Generator → Prompts
|
|
6
|
+
*
|
|
7
|
+
* Allows Claude to generate UIs adapted to the user's device/viewport.
|
|
8
|
+
*/
|
|
9
|
+
// =============================================================================
|
|
10
|
+
// Detection & Defaults
|
|
11
|
+
// =============================================================================
|
|
12
|
+
/**
|
|
13
|
+
* Detect interface context from the browser `window` object.
|
|
14
|
+
*
|
|
15
|
+
* Reads viewport size, device pixel ratio, touch capability, color scheme,
|
|
16
|
+
* and reduced-motion preference. Falls back to {@link defaultInterfaceContext}
|
|
17
|
+
* when called in a non-browser environment (e.g., SSR).
|
|
18
|
+
*
|
|
19
|
+
* @returns Fully populated interface context derived from the browser
|
|
20
|
+
*/
|
|
21
|
+
export function detectInterfaceContext() {
|
|
22
|
+
if (typeof window === 'undefined') {
|
|
23
|
+
return defaultInterfaceContext();
|
|
24
|
+
}
|
|
25
|
+
const width = window.innerWidth;
|
|
26
|
+
const height = window.innerHeight;
|
|
27
|
+
const devicePixelRatio = window.devicePixelRatio || 1;
|
|
28
|
+
const touchPrimary = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
|
|
29
|
+
const colorScheme = window.matchMedia?.('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
30
|
+
const reducedMotion = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false;
|
|
31
|
+
return {
|
|
32
|
+
viewport: { width, height },
|
|
33
|
+
platform: detectPlatform(touchPrimary),
|
|
34
|
+
deviceType: detectDeviceType(width),
|
|
35
|
+
orientation: width >= height ? 'landscape' : 'portrait',
|
|
36
|
+
devicePixelRatio,
|
|
37
|
+
touchPrimary,
|
|
38
|
+
colorScheme,
|
|
39
|
+
reducedMotion,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Default interface context for SSR or when browser detection is unavailable.
|
|
44
|
+
*
|
|
45
|
+
* Returns a standard desktop viewport (1280x800), landscape orientation,
|
|
46
|
+
* non-touch, 1x pixel ratio. Suitable as a safe fallback for server-side
|
|
47
|
+
* rendering where no `window` object exists.
|
|
48
|
+
*
|
|
49
|
+
* @returns A desktop-oriented default context
|
|
50
|
+
*/
|
|
51
|
+
export function defaultInterfaceContext() {
|
|
52
|
+
return {
|
|
53
|
+
viewport: { width: 1280, height: 800 },
|
|
54
|
+
platform: 'web',
|
|
55
|
+
deviceType: 'desktop',
|
|
56
|
+
orientation: 'landscape',
|
|
57
|
+
devicePixelRatio: 1,
|
|
58
|
+
touchPrimary: false,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// =============================================================================
|
|
62
|
+
// Device Category
|
|
63
|
+
// =============================================================================
|
|
64
|
+
/**
|
|
65
|
+
* Derive the device category from an InterfaceContext.
|
|
66
|
+
* Used for blueprint variant selection — determines which optimized
|
|
67
|
+
* version of a blueprint to serve.
|
|
68
|
+
*
|
|
69
|
+
* Priority:
|
|
70
|
+
* 1. If shellType is 'spatial', returns 'spatial' (overrides width)
|
|
71
|
+
* 2. Otherwise, derives from viewport width using standard breakpoints
|
|
72
|
+
*/
|
|
73
|
+
export function getDeviceCategory(context) {
|
|
74
|
+
if (context.shellType === 'spatial') {
|
|
75
|
+
return 'spatial';
|
|
76
|
+
}
|
|
77
|
+
const width = context.viewport.width;
|
|
78
|
+
if (width < 768)
|
|
79
|
+
return 'mobile';
|
|
80
|
+
if (width < 1024)
|
|
81
|
+
return 'tablet';
|
|
82
|
+
return 'desktop';
|
|
83
|
+
}
|
|
84
|
+
// =============================================================================
|
|
85
|
+
// Internal Helpers
|
|
86
|
+
// =============================================================================
|
|
87
|
+
/**
|
|
88
|
+
* Infer the platform type from the user agent string and touch capability.
|
|
89
|
+
*
|
|
90
|
+
* @param touchPrimary - Whether touch is the primary input method
|
|
91
|
+
* @returns Detected platform: `'mobile'` for phones/tablets, `'web'` otherwise
|
|
92
|
+
*/
|
|
93
|
+
function detectPlatform(touchPrimary) {
|
|
94
|
+
if (typeof navigator === 'undefined')
|
|
95
|
+
return 'web';
|
|
96
|
+
const ua = navigator.userAgent.toLowerCase();
|
|
97
|
+
if (ua.includes('android') || ua.includes('iphone') || ua.includes('ipad'))
|
|
98
|
+
return 'mobile';
|
|
99
|
+
if (touchPrimary && ua.includes('mobile'))
|
|
100
|
+
return 'mobile';
|
|
101
|
+
return 'web';
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Classify device form factor from viewport width using standard breakpoints.
|
|
105
|
+
*
|
|
106
|
+
* @param width - Viewport width in CSS pixels
|
|
107
|
+
* @returns `'phone'` (<768px), `'tablet'` (768-1023px), or `'desktop'` (>=1024px)
|
|
108
|
+
*/
|
|
109
|
+
function detectDeviceType(width) {
|
|
110
|
+
if (width < 768)
|
|
111
|
+
return 'phone';
|
|
112
|
+
if (width < 1024)
|
|
113
|
+
return 'tablet';
|
|
114
|
+
return 'desktop';
|
|
115
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streamable Invoke Protocol v1 — TypeScript types.
|
|
3
|
+
*
|
|
4
|
+
* Derived from Zod schemas in schemas/invoke.ts via z.infer — single source
|
|
5
|
+
* of truth. Do not hand-author parallel types here.
|
|
6
|
+
*/
|
|
7
|
+
import type { z } from 'zod';
|
|
8
|
+
import type { textBlockSchema, toolUseBlockSchema, toolResultBlockSchema, contentBlockSchema, textDeltaSchema, inputJsonDeltaSchema, contentBlockDeltaPayloadSchema, messageStartEventSchema, contentBlockStartEventSchema, contentBlockDeltaEventSchema, contentBlockStopEventSchema, messageDeltaEventSchema, messageStopEventSchema, pingEventSchema, errorEventSchema, invokeEventSchema, invokeErrorCodeSchema, invokeTurnSchema, invokeRequestSchema } from '../schemas/invoke';
|
|
9
|
+
export type TextBlock = z.infer<typeof textBlockSchema>;
|
|
10
|
+
export type ToolUseBlock = z.infer<typeof toolUseBlockSchema>;
|
|
11
|
+
export type ToolResultBlock = z.infer<typeof toolResultBlockSchema>;
|
|
12
|
+
export type ContentBlock = z.infer<typeof contentBlockSchema>;
|
|
13
|
+
export type TextDelta = z.infer<typeof textDeltaSchema>;
|
|
14
|
+
export type InputJsonDelta = z.infer<typeof inputJsonDeltaSchema>;
|
|
15
|
+
export type ContentBlockDeltaPayload = z.infer<typeof contentBlockDeltaPayloadSchema>;
|
|
16
|
+
export type MessageStartEvent = z.infer<typeof messageStartEventSchema>;
|
|
17
|
+
export type ContentBlockStartEvent = z.infer<typeof contentBlockStartEventSchema>;
|
|
18
|
+
export type ContentBlockDeltaEvent = z.infer<typeof contentBlockDeltaEventSchema>;
|
|
19
|
+
export type ContentBlockStopEvent = z.infer<typeof contentBlockStopEventSchema>;
|
|
20
|
+
export type MessageDeltaEvent = z.infer<typeof messageDeltaEventSchema>;
|
|
21
|
+
export type MessageStopEvent = z.infer<typeof messageStopEventSchema>;
|
|
22
|
+
export type PingEvent = z.infer<typeof pingEventSchema>;
|
|
23
|
+
export type ErrorEvent = z.infer<typeof errorEventSchema>;
|
|
24
|
+
export type InvokeEvent = z.infer<typeof invokeEventSchema>;
|
|
25
|
+
export type InvokeErrorCode = z.infer<typeof invokeErrorCodeSchema>;
|
|
26
|
+
export type InvokeTurn = z.infer<typeof invokeTurnSchema>;
|
|
27
|
+
export type InvokeRequest = z.infer<typeof invokeRequestSchema>;
|
|
28
|
+
//# sourceMappingURL=invoke.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../../src/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