nitrostack 1.0.72 ā 1.0.73
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/auth/api-key.js.map +1 -1
- package/dist/auth/client.js.map +1 -1
- package/dist/auth/index.d.ts +2 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +3 -0
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/middleware.d.ts +1 -1
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js.map +1 -1
- package/dist/auth/secure-secret.d.ts +136 -0
- package/dist/auth/secure-secret.d.ts.map +1 -0
- package/dist/auth/secure-secret.js +182 -0
- package/dist/auth/secure-secret.js.map +1 -0
- package/dist/auth/server-metadata.d.ts.map +1 -1
- package/dist/auth/server-metadata.js.map +1 -1
- package/dist/auth/simple-jwt.d.ts +100 -14
- package/dist/auth/simple-jwt.d.ts.map +1 -1
- package/dist/auth/simple-jwt.js +19 -9
- package/dist/auth/simple-jwt.js.map +1 -1
- package/dist/auth/token-store.js +1 -1
- package/dist/auth/token-store.js.map +1 -1
- package/dist/auth/token-validation.js +1 -1
- package/dist/auth/token-validation.js.map +1 -1
- package/dist/cli/commands/build.js +1 -1
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/generate-types.js +12 -12
- package/dist/cli/commands/generate-types.js.map +1 -1
- package/dist/cli/commands/generate.d.ts +8 -1
- package/dist/cli/commands/generate.d.ts.map +1 -1
- package/dist/cli/commands/generate.js +13 -12
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/commands/init.js +1 -1
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/upgrade.d.ts +10 -0
- package/dist/cli/commands/upgrade.d.ts.map +1 -0
- package/dist/cli/commands/upgrade.js +221 -0
- package/dist/cli/commands/upgrade.js.map +1 -0
- package/dist/cli/index.js +7 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/core/app-decorator.d.ts +4 -3
- package/dist/core/app-decorator.d.ts.map +1 -1
- package/dist/core/app-decorator.js +67 -28
- package/dist/core/app-decorator.js.map +1 -1
- package/dist/core/builders.d.ts +19 -7
- package/dist/core/builders.d.ts.map +1 -1
- package/dist/core/builders.js +15 -8
- package/dist/core/builders.js.map +1 -1
- package/dist/core/component.d.ts +8 -8
- package/dist/core/component.d.ts.map +1 -1
- package/dist/core/component.js +3 -2
- package/dist/core/component.js.map +1 -1
- package/dist/core/config-module.d.ts +11 -4
- package/dist/core/config-module.d.ts.map +1 -1
- package/dist/core/config-module.js +1 -1
- package/dist/core/config-module.js.map +1 -1
- package/dist/core/decorators/cache.decorator.d.ts +9 -9
- package/dist/core/decorators/cache.decorator.d.ts.map +1 -1
- package/dist/core/decorators/cache.decorator.js +3 -3
- package/dist/core/decorators/cache.decorator.js.map +1 -1
- package/dist/core/decorators/health-check.decorator.d.ts +3 -3
- package/dist/core/decorators/health-check.decorator.d.ts.map +1 -1
- package/dist/core/decorators/health-check.decorator.js +2 -2
- package/dist/core/decorators/health-check.decorator.js.map +1 -1
- package/dist/core/decorators/rate-limit.decorator.d.ts +5 -4
- package/dist/core/decorators/rate-limit.decorator.d.ts.map +1 -1
- package/dist/core/decorators/rate-limit.decorator.js +3 -3
- package/dist/core/decorators/rate-limit.decorator.js.map +1 -1
- package/dist/core/decorators.d.ts +47 -29
- package/dist/core/decorators.d.ts.map +1 -1
- package/dist/core/decorators.js +9 -9
- package/dist/core/decorators.js.map +1 -1
- package/dist/core/di/container.d.ts +21 -4
- package/dist/core/di/container.d.ts.map +1 -1
- package/dist/core/di/container.js +11 -7
- package/dist/core/di/container.js.map +1 -1
- package/dist/core/di/injectable.decorator.d.ts +5 -3
- package/dist/core/di/injectable.decorator.d.ts.map +1 -1
- package/dist/core/di/injectable.decorator.js.map +1 -1
- package/dist/core/errors.d.ts +4 -4
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js.map +1 -1
- package/dist/core/events/event-emitter.d.ts +3 -3
- package/dist/core/events/event-emitter.d.ts.map +1 -1
- package/dist/core/events/event-emitter.js.map +1 -1
- package/dist/core/events/event.decorator.d.ts +5 -5
- package/dist/core/events/event.decorator.d.ts.map +1 -1
- package/dist/core/events/event.decorator.js +10 -6
- package/dist/core/events/event.decorator.js.map +1 -1
- package/dist/core/events/log-emitter.d.ts +7 -1
- package/dist/core/events/log-emitter.d.ts.map +1 -1
- package/dist/core/events/log-emitter.js.map +1 -1
- package/dist/core/filters/exception-filter.decorator.d.ts +5 -5
- package/dist/core/filters/exception-filter.decorator.d.ts.map +1 -1
- package/dist/core/filters/exception-filter.decorator.js +3 -3
- package/dist/core/filters/exception-filter.decorator.js.map +1 -1
- package/dist/core/filters/exception-filter.interface.d.ts +14 -5
- package/dist/core/filters/exception-filter.interface.d.ts.map +1 -1
- package/dist/core/guards/apikey.guard.d.ts +1 -1
- package/dist/core/guards/apikey.guard.d.ts.map +1 -1
- package/dist/core/guards/guard.interface.d.ts +1 -1
- package/dist/core/guards/guard.interface.d.ts.map +1 -1
- package/dist/core/guards/jwt.guard.d.ts +1 -1
- package/dist/core/guards/jwt.guard.d.ts.map +1 -1
- package/dist/core/guards/oauth.guard.d.ts +1 -1
- package/dist/core/guards/oauth.guard.d.ts.map +1 -1
- package/dist/core/guards/use-guards.decorator.d.ts +3 -3
- package/dist/core/guards/use-guards.decorator.d.ts.map +1 -1
- package/dist/core/guards/use-guards.decorator.js +1 -1
- package/dist/core/guards/use-guards.decorator.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/interceptors/interceptor.decorator.d.ts +4 -4
- package/dist/core/interceptors/interceptor.decorator.d.ts.map +1 -1
- package/dist/core/interceptors/interceptor.decorator.js +2 -2
- package/dist/core/interceptors/interceptor.decorator.js.map +1 -1
- package/dist/core/interceptors/interceptor.interface.d.ts +3 -3
- package/dist/core/interceptors/interceptor.interface.d.ts.map +1 -1
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js.map +1 -1
- package/dist/core/middleware/middleware.decorator.d.ts +4 -4
- package/dist/core/middleware/middleware.decorator.d.ts.map +1 -1
- package/dist/core/middleware/middleware.decorator.js +2 -2
- package/dist/core/middleware/middleware.decorator.js.map +1 -1
- package/dist/core/middleware/middleware.interface.d.ts +3 -3
- package/dist/core/middleware/middleware.interface.d.ts.map +1 -1
- package/dist/core/module.d.ts +33 -14
- package/dist/core/module.d.ts.map +1 -1
- package/dist/core/module.js +11 -6
- package/dist/core/module.js.map +1 -1
- package/dist/core/oauth-module.d.ts +9 -3
- package/dist/core/oauth-module.d.ts.map +1 -1
- package/dist/core/oauth-module.js +4 -3
- package/dist/core/oauth-module.js.map +1 -1
- package/dist/core/pipes/pipe.decorator.d.ts +14 -5
- package/dist/core/pipes/pipe.decorator.d.ts.map +1 -1
- package/dist/core/pipes/pipe.decorator.js +2 -2
- package/dist/core/pipes/pipe.decorator.js.map +1 -1
- package/dist/core/pipes/pipe.interface.d.ts +9 -4
- package/dist/core/pipes/pipe.interface.d.ts.map +1 -1
- package/dist/core/prompt.d.ts +13 -4
- package/dist/core/prompt.d.ts.map +1 -1
- package/dist/core/prompt.js +2 -2
- package/dist/core/prompt.js.map +1 -1
- package/dist/core/resource.d.ts +7 -2
- package/dist/core/resource.d.ts.map +1 -1
- package/dist/core/resource.js +2 -2
- package/dist/core/resource.js.map +1 -1
- package/dist/core/server.d.ts +49 -3
- package/dist/core/server.d.ts.map +1 -1
- package/dist/core/server.js +61 -34
- package/dist/core/server.js.map +1 -1
- package/dist/core/tool.d.ts +44 -16
- package/dist/core/tool.d.ts.map +1 -1
- package/dist/core/tool.js +19 -6
- package/dist/core/tool.js.map +1 -1
- package/dist/core/transports/discovery-http-server.d.ts +7 -1
- package/dist/core/transports/discovery-http-server.d.ts.map +1 -1
- package/dist/core/transports/discovery-http-server.js.map +1 -1
- package/dist/core/transports/http-server.d.ts +2 -2
- package/dist/core/transports/http-server.d.ts.map +1 -1
- package/dist/core/transports/http-server.js +1 -1
- package/dist/core/transports/http-server.js.map +1 -1
- package/dist/core/transports/streamable-http.d.ts +4 -4
- package/dist/core/transports/streamable-http.d.ts.map +1 -1
- package/dist/core/transports/streamable-http.js +1 -1
- package/dist/core/transports/streamable-http.js.map +1 -1
- package/dist/core/types.d.ts +87 -15
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/widgets/widget-registry.d.ts +2 -2
- package/dist/core/widgets/widget-registry.d.ts.map +1 -1
- package/dist/core/widgets/widget-registry.js +1 -1
- package/dist/core/widgets/widget-registry.js.map +1 -1
- package/dist/testing/index.d.ts +44 -17
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +5 -8
- package/dist/testing/index.js.map +1 -1
- package/dist/ui-next/index.d.ts +1 -1
- package/dist/ui-next/index.d.ts.map +1 -1
- package/dist/ui-next/index.js.map +1 -1
- package/dist/widgets/hooks/useWidgetSDK.d.ts +5 -5
- package/dist/widgets/runtime/WidgetLayout.js.map +1 -1
- package/dist/widgets/sdk.d.ts +5 -5
- package/dist/widgets/sdk.d.ts.map +1 -1
- package/dist/widgets/sdk.js.map +1 -1
- package/package.json +1 -1
- package/src/studio/app/api/auth/fetch-metadata/route.ts +3 -2
- package/src/studio/app/api/auth/register-client/route.ts +3 -2
- package/src/studio/app/api/chat/route.ts +31 -17
- package/src/studio/app/api/health/checks/route.ts +5 -4
- package/src/studio/app/api/init/route.ts +3 -2
- package/src/studio/app/api/ping/route.ts +3 -2
- package/src/studio/app/api/prompts/[name]/route.ts +4 -3
- package/src/studio/app/api/prompts/route.ts +3 -2
- package/src/studio/app/api/resources/[...uri]/route.ts +3 -2
- package/src/studio/app/api/resources/route.ts +3 -2
- package/src/studio/app/api/roots/route.ts +3 -2
- package/src/studio/app/api/sampling/route.ts +3 -2
- package/src/studio/app/api/tools/[name]/call/route.ts +3 -2
- package/src/studio/app/api/tools/route.ts +4 -3
- package/src/studio/app/api/widget-examples/route.ts +5 -4
- package/src/studio/app/auth/callback/page.tsx +3 -2
- package/src/studio/app/chat/page.tsx +481 -105
- package/src/studio/app/health/page.tsx +1 -1
- package/src/studio/app/logs/page.tsx +2 -2
- package/src/studio/app/page.tsx +5 -5
- package/src/studio/app/prompts/page.tsx +2 -2
- package/src/studio/app/settings/page.tsx +3 -2
- package/src/studio/app/tools/page.tsx +3 -3
- package/src/studio/components/LogMessage.tsx +1 -1
- package/src/studio/components/MarkdownRenderer.tsx +245 -348
- package/src/studio/components/Sidebar.tsx +18 -3
- package/src/studio/components/VoiceOrbOverlay.tsx +12 -6
- package/src/studio/components/WidgetErrorBoundary.tsx +48 -0
- package/src/studio/components/WidgetRenderer.tsx +168 -215
- package/src/studio/components/ops/OpsCanvas.tsx +748 -0
- package/src/studio/components/ops/OpsNodeDetailPanel.tsx +150 -0
- package/src/studio/components/ops/OpsSummaryBar.tsx +90 -0
- package/src/studio/components/ops/index.ts +5 -0
- package/src/studio/components/ops/nodes/BaseNode.tsx +65 -0
- package/src/studio/components/ops/nodes/LLMCallNode.tsx +34 -0
- package/src/studio/components/ops/nodes/LLMResponseNode.tsx +33 -0
- package/src/studio/components/ops/nodes/ToolCallNode.tsx +30 -0
- package/src/studio/components/ops/nodes/ToolResultNode.tsx +43 -0
- package/src/studio/components/ops/nodes/UserPromptNode.tsx +34 -0
- package/src/studio/components/ops/nodes/WidgetRenderNode.tsx +23 -0
- package/src/studio/components/ops/nodes/index.ts +8 -0
- package/src/studio/components/tools/ToolsCanvas.tsx +2 -2
- package/src/studio/lib/api.ts +61 -42
- package/src/studio/lib/http-client-transport.ts +2 -2
- package/src/studio/lib/llm-service.ts +126 -47
- package/src/studio/lib/mcp-client.ts +9 -6
- package/src/studio/lib/ops-store.ts +427 -0
- package/src/studio/lib/ops-tracker.ts +416 -0
- package/src/studio/lib/ops-types.ts +164 -0
- package/src/studio/lib/store.ts +8 -11
- package/src/studio/lib/types.ts +228 -38
- package/src/studio/lib/widget-loader.ts +2 -2
- package/templates/typescript-oauth/src/modules/flights/flights.prompts.ts +19 -22
- package/dist/cli/build-widgets.mjs +0 -165
package/src/studio/lib/types.ts
CHANGED
|
@@ -1,26 +1,108 @@
|
|
|
1
1
|
// NitroStack Studio Type Definitions
|
|
2
2
|
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// JSON Types - For safe handling of arbitrary JSON data
|
|
5
|
+
// ============================================================================
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Primitive JSON values
|
|
9
|
+
*/
|
|
10
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* JSON array type
|
|
14
|
+
*/
|
|
15
|
+
export type JsonArray = JsonValue[];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* JSON object type
|
|
19
|
+
*/
|
|
20
|
+
export type JsonObject = { [key: string]: JsonValue };
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Any valid JSON value
|
|
24
|
+
*/
|
|
25
|
+
export type JsonValue = JsonPrimitive | JsonArray | JsonObject;
|
|
26
|
+
|
|
27
|
+
// ============================================================================
|
|
28
|
+
// Schema Types
|
|
29
|
+
// ============================================================================
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* JSON Schema property definition
|
|
33
|
+
*/
|
|
34
|
+
export interface JsonSchemaProperty {
|
|
35
|
+
type?: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
enum?: JsonValue[];
|
|
38
|
+
default?: JsonValue;
|
|
39
|
+
items?: JsonSchemaProperty;
|
|
40
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
41
|
+
required?: string[];
|
|
42
|
+
additionalProperties?: boolean | JsonSchemaProperty;
|
|
43
|
+
format?: string;
|
|
44
|
+
minimum?: number;
|
|
45
|
+
maximum?: number;
|
|
46
|
+
minLength?: number;
|
|
47
|
+
maxLength?: number;
|
|
48
|
+
pattern?: string;
|
|
49
|
+
[key: string]: JsonValue | undefined;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Tool input schema (JSON Schema format)
|
|
54
|
+
*/
|
|
55
|
+
export interface ToolInputSchema {
|
|
56
|
+
type: string;
|
|
57
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
58
|
+
required?: string[];
|
|
59
|
+
additionalProperties?: boolean;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ============================================================================
|
|
63
|
+
// Tool Types
|
|
64
|
+
// ============================================================================
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Tool metadata
|
|
68
|
+
*/
|
|
69
|
+
export interface ToolMeta {
|
|
70
|
+
'openai/outputTemplate'?: string;
|
|
71
|
+
'ui/template'?: string;
|
|
72
|
+
'tool/initial'?: boolean;
|
|
73
|
+
'tool/examples'?: JsonValue;
|
|
74
|
+
[key: string]: JsonValue | undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Tool examples
|
|
79
|
+
*/
|
|
80
|
+
export interface ToolExamples {
|
|
81
|
+
request?: JsonValue;
|
|
82
|
+
response?: JsonValue;
|
|
83
|
+
}
|
|
84
|
+
|
|
3
85
|
export interface Tool {
|
|
4
86
|
name: string;
|
|
5
87
|
description?: string;
|
|
6
|
-
inputSchema?:
|
|
7
|
-
|
|
8
|
-
properties?: Record<string, any>;
|
|
9
|
-
required?: string[];
|
|
10
|
-
};
|
|
11
|
-
examples?: {
|
|
12
|
-
request?: any;
|
|
13
|
-
response?: any;
|
|
14
|
-
};
|
|
88
|
+
inputSchema?: ToolInputSchema;
|
|
89
|
+
examples?: ToolExamples;
|
|
15
90
|
widget?: {
|
|
16
91
|
route: string;
|
|
17
92
|
};
|
|
18
93
|
outputTemplate?: string;
|
|
19
|
-
_meta?:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
94
|
+
_meta?: ToolMeta;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// ============================================================================
|
|
98
|
+
// Resource Types
|
|
99
|
+
// ============================================================================
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Resource examples
|
|
103
|
+
*/
|
|
104
|
+
export interface ResourceExamples {
|
|
105
|
+
response?: JsonValue;
|
|
24
106
|
}
|
|
25
107
|
|
|
26
108
|
export interface Resource {
|
|
@@ -28,45 +110,69 @@ export interface Resource {
|
|
|
28
110
|
uri: string;
|
|
29
111
|
description?: string;
|
|
30
112
|
mimeType?: string;
|
|
31
|
-
examples?:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
113
|
+
examples?: ResourceExamples;
|
|
114
|
+
_meta?: Record<string, JsonValue>;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// ============================================================================
|
|
118
|
+
// Prompt Types
|
|
119
|
+
// ============================================================================
|
|
120
|
+
|
|
121
|
+
export interface PromptArgument {
|
|
122
|
+
name: string;
|
|
123
|
+
description?: string;
|
|
124
|
+
required?: boolean;
|
|
35
125
|
}
|
|
36
126
|
|
|
37
127
|
export interface Prompt {
|
|
38
128
|
name: string;
|
|
39
129
|
description?: string;
|
|
40
|
-
arguments?:
|
|
41
|
-
name: string;
|
|
42
|
-
description?: string;
|
|
43
|
-
required?: boolean;
|
|
44
|
-
}>;
|
|
130
|
+
arguments?: PromptArgument[];
|
|
45
131
|
}
|
|
46
132
|
|
|
133
|
+
// ============================================================================
|
|
134
|
+
// Root Types
|
|
135
|
+
// ============================================================================
|
|
136
|
+
|
|
47
137
|
export interface Root {
|
|
48
138
|
uri: string;
|
|
49
139
|
name?: string;
|
|
50
140
|
}
|
|
51
141
|
|
|
142
|
+
// ============================================================================
|
|
143
|
+
// Chat Types
|
|
144
|
+
// ============================================================================
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Tool call in a chat message
|
|
148
|
+
*/
|
|
149
|
+
export interface ToolCall {
|
|
150
|
+
id: string;
|
|
151
|
+
name: string;
|
|
152
|
+
arguments: JsonValue;
|
|
153
|
+
result?: JsonValue;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* File attachment in a chat message
|
|
158
|
+
*/
|
|
159
|
+
export interface ChatFile {
|
|
160
|
+
data: string;
|
|
161
|
+
type: string;
|
|
162
|
+
name: string;
|
|
163
|
+
}
|
|
164
|
+
|
|
52
165
|
export interface ChatMessage {
|
|
53
166
|
role: 'user' | 'assistant' | 'tool' | 'system';
|
|
54
167
|
content: string;
|
|
55
168
|
toolCalls?: ToolCall[];
|
|
56
169
|
toolCallId?: string;
|
|
57
|
-
file?:
|
|
58
|
-
data: string;
|
|
59
|
-
type: string;
|
|
60
|
-
name: string;
|
|
61
|
-
};
|
|
170
|
+
file?: ChatFile;
|
|
62
171
|
}
|
|
63
172
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
arguments: any;
|
|
68
|
-
result?: any;
|
|
69
|
-
}
|
|
173
|
+
// ============================================================================
|
|
174
|
+
// Connection & Health Types
|
|
175
|
+
// ============================================================================
|
|
70
176
|
|
|
71
177
|
export interface PingResult {
|
|
72
178
|
time: Date;
|
|
@@ -83,17 +189,92 @@ export interface HealthCheck {
|
|
|
83
189
|
status: 'up' | 'down' | 'degraded';
|
|
84
190
|
lastCheck: Date;
|
|
85
191
|
message?: string;
|
|
192
|
+
details?: JsonObject;
|
|
86
193
|
}
|
|
87
194
|
|
|
195
|
+
// ============================================================================
|
|
196
|
+
// OAuth Types
|
|
197
|
+
// ============================================================================
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* OAuth Resource Metadata (RFC 9728)
|
|
201
|
+
*/
|
|
202
|
+
export interface ResourceMetadata {
|
|
203
|
+
resource: string;
|
|
204
|
+
authorization_servers: string[];
|
|
205
|
+
scopes_supported?: string[];
|
|
206
|
+
bearer_methods_supported?: string[];
|
|
207
|
+
[key: string]: JsonValue | undefined;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* OAuth Authorization Server Metadata (RFC 8414)
|
|
212
|
+
*/
|
|
213
|
+
export interface AuthServerMetadata {
|
|
214
|
+
issuer: string;
|
|
215
|
+
authorization_endpoint: string;
|
|
216
|
+
token_endpoint: string;
|
|
217
|
+
registration_endpoint?: string;
|
|
218
|
+
revocation_endpoint?: string;
|
|
219
|
+
introspection_endpoint?: string;
|
|
220
|
+
scopes_supported?: string[];
|
|
221
|
+
response_types_supported?: string[];
|
|
222
|
+
grant_types_supported?: string[];
|
|
223
|
+
code_challenge_methods_supported?: string[];
|
|
224
|
+
[key: string]: JsonValue | undefined;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* OAuth Client Registration
|
|
229
|
+
*/
|
|
230
|
+
export interface ClientRegistration {
|
|
231
|
+
client_id: string;
|
|
232
|
+
client_secret?: string;
|
|
233
|
+
redirect_uris: string[];
|
|
234
|
+
token_endpoint_auth_method?: string;
|
|
235
|
+
grant_types?: string[];
|
|
236
|
+
response_types?: string[];
|
|
237
|
+
[key: string]: JsonValue | undefined;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* OAuth Token
|
|
242
|
+
*/
|
|
243
|
+
export interface OAuthToken {
|
|
244
|
+
access_token: string;
|
|
245
|
+
token_type: string;
|
|
246
|
+
expires_in?: number;
|
|
247
|
+
refresh_token?: string;
|
|
248
|
+
scope?: string;
|
|
249
|
+
[key: string]: JsonValue | undefined;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* OAuth state for the studio
|
|
254
|
+
*/
|
|
88
255
|
export interface OAuthState {
|
|
89
256
|
authServerUrl: string | null;
|
|
90
|
-
resourceMetadata:
|
|
91
|
-
authServerMetadata:
|
|
92
|
-
clientRegistration:
|
|
257
|
+
resourceMetadata: ResourceMetadata | null;
|
|
258
|
+
authServerMetadata: AuthServerMetadata | null;
|
|
259
|
+
clientRegistration: ClientRegistration | null;
|
|
93
260
|
selectedScopes: string[];
|
|
94
|
-
currentToken:
|
|
261
|
+
currentToken: OAuthToken | null;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// ============================================================================
|
|
265
|
+
// PKCE Types
|
|
266
|
+
// ============================================================================
|
|
267
|
+
|
|
268
|
+
export interface PKCEParams {
|
|
269
|
+
code_verifier: string;
|
|
270
|
+
code_challenge: string;
|
|
271
|
+
code_challenge_method: 'S256' | 'plain';
|
|
95
272
|
}
|
|
96
273
|
|
|
274
|
+
// ============================================================================
|
|
275
|
+
// UI Types
|
|
276
|
+
// ============================================================================
|
|
277
|
+
|
|
97
278
|
export type TabType =
|
|
98
279
|
| 'tools'
|
|
99
280
|
| 'chat'
|
|
@@ -105,3 +286,12 @@ export type TabType =
|
|
|
105
286
|
| 'sampling'
|
|
106
287
|
| 'roots';
|
|
107
288
|
|
|
289
|
+
/**
|
|
290
|
+
* Enlarge modal state
|
|
291
|
+
*/
|
|
292
|
+
export interface EnlargeModalState {
|
|
293
|
+
open: boolean;
|
|
294
|
+
type: 'tool' | 'resource' | null;
|
|
295
|
+
item: Tool | Resource | null;
|
|
296
|
+
}
|
|
297
|
+
|
|
@@ -46,7 +46,7 @@ export async function loadWidget(uri: string): Promise<{ html: string; isDevMode
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export function createWidgetHTML(html: string, data:
|
|
49
|
+
export function createWidgetHTML(html: string, data: unknown): string {
|
|
50
50
|
const htmlParts = [
|
|
51
51
|
'<!DOCTYPE html>',
|
|
52
52
|
'<html>',
|
|
@@ -70,7 +70,7 @@ export function createWidgetHTML(html: string, data: any): string {
|
|
|
70
70
|
return htmlParts.join('\n');
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
export function postMessageToWidget(iframe: HTMLIFrameElement, data:
|
|
73
|
+
export function postMessageToWidget(iframe: HTMLIFrameElement, data: unknown, delay: number = 500): void {
|
|
74
74
|
iframe.onload = () => {
|
|
75
75
|
setTimeout(() => {
|
|
76
76
|
try {
|
|
@@ -22,33 +22,30 @@ export class FlightPrompts {
|
|
|
22
22
|
]
|
|
23
23
|
})
|
|
24
24
|
async flightSearchAssistant(input: any, ctx: ExecutionContext) {
|
|
25
|
-
const systemPrompt = `You are a professional flight booking assistant with expertise in helping travelers find
|
|
25
|
+
const systemPrompt = `You are a professional flight booking assistant with expertise in helping travelers find flight information.
|
|
26
|
+
|
|
27
|
+
ā ļø CRITICAL: Only do what the user specifically asks. Do NOT assume additional steps.
|
|
26
28
|
|
|
27
29
|
Your capabilities:
|
|
30
|
+
- Search for airports using search_airports tool
|
|
28
31
|
- Search for flights using the search_flights tool
|
|
29
32
|
- Get detailed flight information using get_flight_details tool
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
BOOKING WORKFLOW:
|
|
46
|
-
When a user wants to book a flight:
|
|
33
|
+
- Help book flights when explicitly requested
|
|
34
|
+
|
|
35
|
+
**IMPORTANT RULES:**
|
|
36
|
+
1. If user asks about airports, ONLY search airports - do NOT search for flights
|
|
37
|
+
2. If user asks about flights, ONLY search flights - do NOT automatically book
|
|
38
|
+
3. If user asks to book, ONLY then proceed with booking workflow
|
|
39
|
+
4. NEVER chain operations unless user explicitly requests it
|
|
40
|
+
|
|
41
|
+
**EXAMPLES:**
|
|
42
|
+
- "show me airports in London" ā search_airports("London") ā show results ā STOP
|
|
43
|
+
- "find flights from NYC to LAX" ā search_flights ā show results ā STOP
|
|
44
|
+
- "book this flight" ā THEN start booking workflow
|
|
45
|
+
|
|
46
|
+
BOOKING WORKFLOW (only when user explicitly wants to book):
|
|
47
47
|
1. FIRST, collect ALL passenger information (name, title, gender, date of birth, email, phone)
|
|
48
48
|
2. THEN, call create_order tool with complete passenger details
|
|
49
|
-
- The system will automatically create a HOLD order (no payment required)
|
|
50
|
-
- The system will automatically handle passenger ID creation with Duffel
|
|
51
|
-
- You just need to provide the passenger details in the correct format
|
|
52
49
|
ā ļø NEVER call create_order without collecting passenger information first!
|
|
53
50
|
ā ļø All bookings are automatically held - no payment is required at booking time
|
|
54
51
|
|
|
@@ -56,7 +53,7 @@ Current user query: ${input.userQuery}
|
|
|
56
53
|
|
|
57
54
|
${input.context?.previousSearches?.length ? `Previous searches in this conversation:\n${JSON.stringify(input.context.previousSearches, null, 2)}` : ''}
|
|
58
55
|
|
|
59
|
-
Respond
|
|
56
|
+
Respond to EXACTLY what the user asked - nothing more.`;
|
|
60
57
|
|
|
61
58
|
return {
|
|
62
59
|
role: 'assistant',
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Custom widget bundler for NitroStack
|
|
5
|
-
*
|
|
6
|
-
* This script bundles Next.js widget pages into single-file HTML documents
|
|
7
|
-
* with all JavaScript and CSS inlined, following OpenAI's widget spec.
|
|
8
|
-
*
|
|
9
|
-
* Unlike Next.js static export which creates multiple chunk files,
|
|
10
|
-
* this creates truly self-contained single-file widgets.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import * as esbuild from 'esbuild';
|
|
14
|
-
import * as fs from 'fs';
|
|
15
|
-
import * as path from 'path';
|
|
16
|
-
|
|
17
|
-
const WIDGETS_DIR = path.resolve(process.cwd(), 'src/widgets');
|
|
18
|
-
const APP_DIR = path.join(WIDGETS_DIR, 'app');
|
|
19
|
-
const OUT_DIR = path.join(WIDGETS_DIR, 'out');
|
|
20
|
-
|
|
21
|
-
console.log('šØ Building widgets with esbuild...\n');
|
|
22
|
-
|
|
23
|
-
// Clean output directory
|
|
24
|
-
if (fs.existsSync(OUT_DIR)) {
|
|
25
|
-
fs.rmSync(OUT_DIR, { recursive: true });
|
|
26
|
-
}
|
|
27
|
-
fs.mkdirSync(OUT_DIR, { recursive: true });
|
|
28
|
-
|
|
29
|
-
// Find all widget pages
|
|
30
|
-
const widgetPages = [];
|
|
31
|
-
|
|
32
|
-
function findWidgetPages(dir, basePath = '') {
|
|
33
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
34
|
-
|
|
35
|
-
for (const entry of entries) {
|
|
36
|
-
const fullPath = path.join(dir, entry.name);
|
|
37
|
-
const relativePath = path.join(basePath, entry.name);
|
|
38
|
-
|
|
39
|
-
if (entry.isDirectory()) {
|
|
40
|
-
findWidgetPages(fullPath, relativePath);
|
|
41
|
-
} else if (entry.name === 'page.tsx' || entry.name === 'page.jsx') {
|
|
42
|
-
const widgetName = basePath || 'index';
|
|
43
|
-
widgetPages.push({
|
|
44
|
-
name: widgetName,
|
|
45
|
-
entryPoint: fullPath,
|
|
46
|
-
outputName: widgetName.replace(/\//g, '-')
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (fs.existsSync(APP_DIR)) {
|
|
53
|
-
findWidgetPages(APP_DIR);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
console.log(`Found ${widgetPages.length} widget(s):`);
|
|
57
|
-
widgetPages.forEach(w => console.log(` - ${w.name}`));
|
|
58
|
-
console.log('');
|
|
59
|
-
|
|
60
|
-
// Bundle each widget
|
|
61
|
-
for (const widget of widgetPages) {
|
|
62
|
-
console.log(`š¦ Bundling ${widget.name}...`);
|
|
63
|
-
|
|
64
|
-
const tempEntry = path.join(OUT_DIR, `_temp_${widget.outputName}.jsx`);
|
|
65
|
-
const jsOutput = path.join(OUT_DIR, `${widget.outputName}.js`);
|
|
66
|
-
const htmlOutput = path.join(OUT_DIR, `${widget.outputName}.html`);
|
|
67
|
-
|
|
68
|
-
// Create a temporary entry file that renders the widget
|
|
69
|
-
const entryCode = `
|
|
70
|
-
import React from 'react';
|
|
71
|
-
import { createRoot } from 'react-dom/client';
|
|
72
|
-
import WidgetPage from '${widget.entryPoint.replace(/\\/g, '/')}';
|
|
73
|
-
|
|
74
|
-
// Wait for DOM to be ready
|
|
75
|
-
if (document.readyState === 'loading') {
|
|
76
|
-
document.addEventListener('DOMContentLoaded', init);
|
|
77
|
-
} else {
|
|
78
|
-
init();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function init() {
|
|
82
|
-
// Get data from window.openai if available
|
|
83
|
-
const data = window.openai?.toolOutput || {};
|
|
84
|
-
|
|
85
|
-
// Find or create root element
|
|
86
|
-
let root = document.getElementById('widget-root');
|
|
87
|
-
if (!root) {
|
|
88
|
-
root = document.createElement('div');
|
|
89
|
-
root.id = 'widget-root';
|
|
90
|
-
document.body.appendChild(root);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Render the widget
|
|
94
|
-
const reactRoot = createRoot(root);
|
|
95
|
-
reactRoot.render(React.createElement(WidgetPage, { data }));
|
|
96
|
-
}
|
|
97
|
-
`;
|
|
98
|
-
|
|
99
|
-
fs.writeFileSync(tempEntry, entryCode);
|
|
100
|
-
|
|
101
|
-
try {
|
|
102
|
-
// Bundle with esbuild
|
|
103
|
-
await esbuild.build({
|
|
104
|
-
entryPoints: [tempEntry],
|
|
105
|
-
bundle: true,
|
|
106
|
-
format: 'iife',
|
|
107
|
-
outfile: jsOutput,
|
|
108
|
-
platform: 'browser',
|
|
109
|
-
target: ['es2020'],
|
|
110
|
-
minify: true,
|
|
111
|
-
jsx: 'automatic',
|
|
112
|
-
jsxImportSource: 'react',
|
|
113
|
-
// Don't bundle React - it should come from widgets/node_modules
|
|
114
|
-
external: [],
|
|
115
|
-
// Resolve modules from the widgets directory
|
|
116
|
-
nodePaths: [path.join(WIDGETS_DIR, 'node_modules')],
|
|
117
|
-
define: {
|
|
118
|
-
'process.env.NODE_ENV': '"production"'
|
|
119
|
-
},
|
|
120
|
-
logLevel: 'warning'
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
// Read the bundled JavaScript
|
|
124
|
-
const bundledJs = fs.readFileSync(jsOutput, 'utf-8');
|
|
125
|
-
|
|
126
|
-
// Create the HTML file with inlined JavaScript
|
|
127
|
-
const html = `<!DOCTYPE html>
|
|
128
|
-
<html lang="en">
|
|
129
|
-
<head>
|
|
130
|
-
<meta charset="utf-8">
|
|
131
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
132
|
-
<style>
|
|
133
|
-
* { box-sizing: border-box; }
|
|
134
|
-
body {
|
|
135
|
-
margin: 0;
|
|
136
|
-
padding: 0;
|
|
137
|
-
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
138
|
-
}
|
|
139
|
-
#widget-root {
|
|
140
|
-
width: 100%;
|
|
141
|
-
min-height: 100vh;
|
|
142
|
-
}
|
|
143
|
-
</style>
|
|
144
|
-
</head>
|
|
145
|
-
<body>
|
|
146
|
-
<div id="widget-root"></div>
|
|
147
|
-
<script>${bundledJs}</script>
|
|
148
|
-
</body>
|
|
149
|
-
</html>`;
|
|
150
|
-
|
|
151
|
-
fs.writeFileSync(htmlOutput, html);
|
|
152
|
-
|
|
153
|
-
// Clean up temporary files
|
|
154
|
-
fs.unlinkSync(tempEntry);
|
|
155
|
-
fs.unlinkSync(jsOutput);
|
|
156
|
-
|
|
157
|
-
console.log(` ā ${widget.outputName}.html`);
|
|
158
|
-
|
|
159
|
-
} catch (error) {
|
|
160
|
-
console.error(` ā Failed to bundle ${widget.name}:`, error.message);
|
|
161
|
-
process.exit(1);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
console.log(`\n⨠Successfully built ${widgetPages.length} widget(s) to ${OUT_DIR}\n`);
|