@blocklet/pages-kit 0.2.340 → 0.2.342

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.
Files changed (97) hide show
  1. package/lib/cjs/builtin/async/ai-runtime/api/agent.js +3 -5
  2. package/lib/cjs/builtin/async/ai-runtime/api/message.js +2 -4
  3. package/lib/cjs/builtin/async/ai-runtime/api/request.js +5 -1
  4. package/lib/cjs/builtin/async/ai-runtime/api/{subscription.js → secret.js} +7 -15
  5. package/lib/cjs/builtin/async/ai-runtime/api/session.js +9 -10
  6. package/lib/cjs/builtin/async/ai-runtime/components/AgentErrorBoundary.js +27 -0
  7. package/lib/cjs/builtin/async/ai-runtime/components/AgentSettings/AgentSettingsDialog.js +80 -0
  8. package/lib/cjs/builtin/async/ai-runtime/components/PopperMenuButton/LoadingMenuItem.js +1 -1
  9. package/lib/cjs/builtin/async/ai-runtime/components/ShareActions/index.js +10 -10
  10. package/lib/cjs/builtin/async/ai-runtime/constants.js +2 -1
  11. package/lib/cjs/builtin/async/ai-runtime/contexts/CurrentAgent.js +2 -2
  12. package/lib/cjs/builtin/async/ai-runtime/contexts/Runtime.js +4 -3
  13. package/lib/cjs/builtin/async/ai-runtime/hooks/use-agent-admin.js +11 -0
  14. package/lib/cjs/builtin/async/ai-runtime/hooks/use-header-menu.js +10 -2
  15. package/lib/cjs/builtin/async/ai-runtime/locales/index.js +4 -0
  16. package/lib/cjs/builtin/async/ai-runtime/runtime/Runtime/index.js +5 -4
  17. package/lib/cjs/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +26 -57
  18. package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageItemView.js +10 -19
  19. package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/index.js +2 -2
  20. package/lib/cjs/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView.js +1 -1
  21. package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +3 -3
  22. package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGalleryItem/index.js +5 -5
  23. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +5 -4
  24. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessagesView.js +1 -1
  25. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/UserMessageView.js +2 -2
  26. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleOutput/index.js +5 -4
  27. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +2 -2
  28. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SuggestedQuestionsView/index.js +2 -2
  29. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Input.js +1 -1
  30. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Output.js +5 -5
  31. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Page.js +7 -7
  32. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.js +8 -8
  33. package/lib/cjs/builtin/async/ai-runtime/state/agent.js +7 -8
  34. package/lib/cjs/builtin/async/ai-runtime/state/runtime.js +5 -5
  35. package/lib/cjs/builtin/async/ai-runtime/state/session.js +15 -17
  36. package/lib/cjs/builtin/page/header.js +3 -3
  37. package/lib/cjs/components/CustomComponentRenderer/index.js +1 -1
  38. package/lib/cjs/tsconfig.tsbuildinfo +1 -1
  39. package/lib/esm/builtin/async/ai-runtime/api/agent.js +4 -6
  40. package/lib/esm/builtin/async/ai-runtime/api/message.js +3 -5
  41. package/lib/esm/builtin/async/ai-runtime/api/request.js +3 -0
  42. package/lib/esm/builtin/async/ai-runtime/api/{subscription.js → secret.js} +7 -14
  43. package/lib/esm/builtin/async/ai-runtime/api/session.js +10 -11
  44. package/lib/esm/builtin/async/ai-runtime/components/AgentErrorBoundary.js +22 -0
  45. package/lib/esm/builtin/async/ai-runtime/components/AgentSettings/AgentSettingsDialog.js +76 -0
  46. package/lib/esm/builtin/async/ai-runtime/components/PopperMenuButton/LoadingMenuItem.js +1 -1
  47. package/lib/esm/builtin/async/ai-runtime/components/ShareActions/index.js +10 -10
  48. package/lib/esm/builtin/async/ai-runtime/constants.js +1 -0
  49. package/lib/esm/builtin/async/ai-runtime/contexts/CurrentAgent.js +2 -2
  50. package/lib/esm/builtin/async/ai-runtime/contexts/Runtime.js +4 -3
  51. package/lib/esm/builtin/async/ai-runtime/hooks/use-agent-admin.js +7 -0
  52. package/lib/esm/builtin/async/ai-runtime/hooks/use-header-menu.js +11 -3
  53. package/lib/esm/builtin/async/ai-runtime/locales/index.js +4 -0
  54. package/lib/esm/builtin/async/ai-runtime/runtime/Runtime/index.js +5 -4
  55. package/lib/esm/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +27 -58
  56. package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageItemView.js +10 -19
  57. package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/index.js +2 -2
  58. package/lib/esm/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView.js +1 -1
  59. package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +3 -3
  60. package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGalleryItem/index.js +5 -5
  61. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +5 -4
  62. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessagesView.js +1 -1
  63. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/UserMessageView.js +2 -2
  64. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleOutput/index.js +5 -4
  65. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +2 -2
  66. package/lib/esm/builtin/async/ai-runtime/runtime-components/SuggestedQuestionsView/index.js +2 -2
  67. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Input.js +1 -1
  68. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Output.js +5 -5
  69. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Page.js +7 -7
  70. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.js +8 -8
  71. package/lib/esm/builtin/async/ai-runtime/state/agent.js +6 -6
  72. package/lib/esm/builtin/async/ai-runtime/state/runtime.js +5 -5
  73. package/lib/esm/builtin/async/ai-runtime/state/session.js +15 -17
  74. package/lib/esm/builtin/page/header.js +3 -3
  75. package/lib/esm/components/CustomComponentRenderer/BlockletReactComponentRenderer.js +1 -1
  76. package/lib/esm/components/CustomComponentRenderer/index.js +1 -1
  77. package/lib/esm/tsconfig.tsbuildinfo +1 -1
  78. package/lib/types/builtin/async/ai-runtime/api/agent.d.ts +10 -1
  79. package/lib/types/builtin/async/ai-runtime/api/message.d.ts +4 -15
  80. package/lib/types/builtin/async/ai-runtime/api/request.d.ts +1 -0
  81. package/lib/types/builtin/async/ai-runtime/api/secret.d.ts +12 -0
  82. package/lib/types/builtin/async/ai-runtime/api/session.d.ts +5 -8
  83. package/lib/types/builtin/async/ai-runtime/components/AgentErrorBoundary.d.ts +4 -0
  84. package/lib/types/builtin/async/ai-runtime/components/AgentSettings/AgentSettingsDialog.d.ts +10 -0
  85. package/lib/types/builtin/async/ai-runtime/constants.d.ts +1 -0
  86. package/lib/types/builtin/async/ai-runtime/contexts/Runtime.d.ts +3 -1
  87. package/lib/types/builtin/async/ai-runtime/hooks/use-agent-admin.d.ts +2 -0
  88. package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +4 -0
  89. package/lib/types/builtin/async/ai-runtime/runtime/Runtime/index.d.ts +2 -1
  90. package/lib/types/builtin/async/ai-runtime/state/agent.d.ts +2 -6
  91. package/lib/types/builtin/async/ai-runtime/state/runtime.d.ts +2 -0
  92. package/lib/types/builtin/async/ai-runtime/state/session.d.ts +1 -0
  93. package/lib/types/builtin/page/header.d.ts +2 -2
  94. package/lib/types/components/CustomComponentRenderer/index.d.ts +3 -0
  95. package/lib/types/tsconfig.tsbuildinfo +1 -1
  96. package/package.json +7 -7
  97. package/lib/types/builtin/async/ai-runtime/api/subscription.d.ts +0 -15
@@ -31,8 +31,17 @@ export interface Agent {
31
31
  };
32
32
  };
33
33
  };
34
+ config: {
35
+ secrets: {
36
+ targetProjectId: string;
37
+ targetAgentId: string;
38
+ targetInput: Parameter;
39
+ hasValue: boolean;
40
+ }[];
41
+ };
34
42
  }
35
- export declare function getAgent({ aid, working }: {
43
+ export declare function getAgent({ aid, blockletDid, working, }: {
36
44
  aid: string;
45
+ blockletDid?: string;
37
46
  working?: boolean;
38
47
  }): Promise<Agent>;
@@ -1,27 +1,16 @@
1
- import { ExecuteBlock, RuntimeOutputVariablesSchema } from '@blocklet/ai-runtime/types';
2
1
  export interface Message {
3
2
  id: string;
4
- taskId: string;
5
- assistantId: string;
3
+ agentId: string;
6
4
  sessionId: string;
7
5
  createdAt: string;
8
6
  updatedAt: string;
9
- parameters?: {
7
+ inputs?: {
10
8
  [key: string]: any;
11
9
  };
12
- result?: {
10
+ outputs?: {
13
11
  content?: string;
14
- images?: {
15
- url: string;
16
- }[];
17
- messages?: {
18
- taskId: string;
19
- respondAs?: ExecuteBlock['respondAs'];
20
- result?: Pick<NonNullable<Message['result']>, 'content' | 'images'>;
21
- }[];
22
12
  objects?: {
23
- taskId: string;
24
- data: RuntimeOutputVariablesSchema;
13
+ [key: string]: any;
25
14
  }[];
26
15
  } | null;
27
16
  error?: {
@@ -1,3 +1,4 @@
1
+ export declare const getAIRuntimeApiPrefix: () => any;
1
2
  export declare const fetch: (input: string | URL | Request, options?: RequestInit | undefined) => Promise<Response>;
2
3
  export declare function request<T>({ url, query, body, ...init }: {
3
4
  url: string;
@@ -0,0 +1,12 @@
1
+ export interface CreateOrUpdateSecretsInput {
2
+ secrets: {
3
+ projectId: string;
4
+ targetProjectId: string;
5
+ targetAgentId: string;
6
+ targetInputKey: string;
7
+ secret: string;
8
+ }[];
9
+ }
10
+ export declare function createSecrets({ input }: {
11
+ input: CreateOrUpdateSecretsInput;
12
+ }): Promise<{}>;
@@ -1,16 +1,12 @@
1
1
  import { RunAssistantResponse } from '@blocklet/ai-runtime/types';
2
2
  export interface Session {
3
3
  id: string;
4
+ createdAt: string;
5
+ updatedAt: string;
4
6
  name?: string;
5
7
  userId: string;
6
8
  projectId: string;
7
- projectRef: string;
8
- assistantId: string;
9
- createdAt: string;
10
- parameters?: any;
11
- entry?: {
12
- title?: string;
13
- };
9
+ agentId: string;
14
10
  }
15
11
  export declare function getSessions({ aid }: {
16
12
  aid: string;
@@ -45,9 +41,10 @@ export declare function deleteSession({ sessionId, }: {
45
41
  deleted: Session;
46
42
  sessions: Session[];
47
43
  }>;
48
- export declare function runAgent({ aid, sessionId, working, parameters, }: {
44
+ export declare function runAgent({ aid, sessionId, blockletDid, working, parameters, }: {
49
45
  aid: string;
50
46
  sessionId: string;
47
+ blockletDid?: string;
51
48
  working?: boolean;
52
49
  parameters: any;
53
50
  }): AsyncGenerator<RunAssistantResponse, void, unknown>;
@@ -0,0 +1,4 @@
1
+ export default function AgentErrorBoundary(): import("react/jsx-runtime").JSX.Element;
2
+ export declare function AgentErrorView({ error }: {
3
+ error: any;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { DialogProps } from '@mui/material';
2
+ export interface SettingsDialogState {
3
+ isOpen: boolean;
4
+ open: () => void;
5
+ onClose: () => void;
6
+ }
7
+ export declare const settingsDialogState: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<SettingsDialogState>, "setState"> & {
8
+ setState(nextStateOrUpdater: SettingsDialogState | Partial<SettingsDialogState> | ((state: import("immer").WritableDraft<SettingsDialogState>) => void), shouldReplace?: boolean | undefined): void;
9
+ }>;
10
+ export default function AgentSettingsDialog({ ...props }: Omit<DialogProps, 'open'>): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import { OutputVariable } from '@blocklet/ai-runtime/types';
2
2
  export declare const AI_STUDIO_DID = "z8iZpog7mcgcgBZzTiXJCWESvmnRrQmnd3XBB";
3
+ export declare const AI_RUNTIME_DID = "z2qa5vnwATPJyAnBYm7SbLMMjfeXJgeBKkfMG";
3
4
  export declare const PAYMENT_KIT_DID = "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk";
4
5
  export declare const DEFAULT_PAGE_COMPONENT_ID = "ctnxha29uu8cx4xv";
5
6
  export declare const DEFAULT_INPUT_COMPONENT_ID = "1wwtemqcdio6nqf0";
@@ -2,9 +2,11 @@ import { ReactNode } from 'react';
2
2
  export interface RuntimeContext {
3
3
  aid: string;
4
4
  working?: boolean;
5
+ blockletDid?: string;
5
6
  }
6
7
  export declare function useRuntimeContext(): RuntimeContext;
7
- export default function RuntimeProvider({ aid, working, children, }: {
8
+ export default function RuntimeProvider({ blockletDid, aid, working, children, }: {
9
+ blockletDid?: string;
8
10
  aid: string;
9
11
  working?: boolean;
10
12
  children?: ReactNode;
@@ -0,0 +1,2 @@
1
+ import { Agent } from '../api/agent';
2
+ export declare function useIsAgentAdmin(agent: Agent): boolean;
@@ -98,6 +98,8 @@ export declare const translations: {
98
98
  retry: string;
99
99
  errorCodeTip: string;
100
100
  };
101
+ settings: string;
102
+ setup: string;
101
103
  };
102
104
  zh: {
103
105
  by: string;
@@ -198,5 +200,7 @@ export declare const translations: {
198
200
  retry: string;
199
201
  errorCodeTip: string;
200
202
  };
203
+ settings: string;
204
+ setup: string;
201
205
  };
202
206
  };
@@ -1,4 +1,5 @@
1
- export default function Runtime({ aid, working }: {
1
+ export default function Runtime({ blockletDid, aid, working, }: {
2
+ blockletDid?: string;
2
3
  aid?: string;
3
4
  working?: boolean;
4
5
  }): import("react/jsx-runtime").JSX.Element;
@@ -5,12 +5,8 @@ export interface AgentState {
5
5
  error?: Error;
6
6
  load: () => Promise<void>;
7
7
  }
8
- export declare const createAgentState: ({ aid, working, agent }: {
9
- aid: string;
10
- working?: boolean;
11
- agent?: Agent;
12
- }) => import("zustand").UseBoundStore<import("zustand").StoreApi<import("immer").WritableDraft<AgentState>>>;
13
- export declare function useAgentState({ aid, working }: {
8
+ export declare function useAgentState({ blockletDid, aid, working, }: {
9
+ blockletDid?: string;
14
10
  aid: string;
15
11
  working?: boolean;
16
12
  }): [Agent, AgentState];
@@ -1,8 +1,10 @@
1
1
  export declare function useRuntimeState(): {
2
+ blockletDid: string | undefined;
2
3
  aid: string;
3
4
  working: boolean | undefined;
4
5
  agent: import("../api/agent").Agent;
5
6
  execute: (options: {
7
+ blockletDid?: string | undefined;
6
8
  sessionId?: string | undefined;
7
9
  aid: string;
8
10
  working?: boolean | undefined;
@@ -45,6 +45,7 @@ export interface SessionState {
45
45
  }) => Promise<void>;
46
46
  loadLatestMessagesForAllSessions: () => Promise<void>;
47
47
  execute: (options: {
48
+ blockletDid?: string;
48
49
  sessionId?: string;
49
50
  aid: string;
50
51
  working?: boolean;
@@ -3,14 +3,14 @@ export interface HeaderWidgets {
3
3
  logo?: any;
4
4
  brand?: any;
5
5
  description?: any;
6
- addons?: (...exists: any[]) => any[];
6
+ addons?: (exists: any[]) => any[];
7
7
  }
8
8
  export type HeaderWidgetCreator = () => HeaderWidgets;
9
9
  export interface HeaderState {
10
10
  logo?: any;
11
11
  brand?: any;
12
12
  description?: any;
13
- addons?: (...exists: any[]) => any[];
13
+ addons?: (exists: any[]) => any[];
14
14
  stack: Set<HeaderWidgetCreator>;
15
15
  add: (creator: HeaderWidgetCreator) => void;
16
16
  delete: (creator: HeaderWidgetCreator) => void;
@@ -1,3 +1,5 @@
1
+ import { ComponentProps } from 'react';
2
+ import { ErrorBoundary } from 'react-error-boundary';
1
3
  import { StateMode } from '../../types';
2
4
  import { CustomComponent } from '../../types/core';
3
5
  export * from './state';
@@ -24,5 +26,6 @@ export interface CustomComponentRendererProps {
24
26
  };
25
27
  dev?: CustomComponentRendererDevProps;
26
28
  fallbackRender?: any;
29
+ ErrorBoundaryProps?: ComponentProps<typeof ErrorBoundary>;
27
30
  }
28
31
  export default function CustomComponentRenderer({ dev, ...props }: CustomComponentRendererProps): import("react/jsx-runtime").JSX.Element;