@metad/contracts 3.8.4 → 3.9.0-beta.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metad/contracts",
3
- "version": "3.8.4",
3
+ "version": "3.9.0-beta.0",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,12 +10,12 @@
10
10
  "url": "https://github.com/xpert-ai/xpert/issues"
11
11
  },
12
12
  "scripts": {
13
- "docs": "yarn typedoc --out ./.docs"
13
+ "docs": "pnpm typedoc --out ./.docs"
14
14
  },
15
15
  "module": "./index.esm.js",
16
16
  "main": "./index.cjs.js",
17
17
  "dependencies": {
18
- "@a2ui/lit": "^0.8.1",
19
- "@xpert-ai/chatkit-types": "^0.0.12"
20
- }
21
- }
18
+ "@xpert-ai/chatkit-types": "^0.0.17"
19
+ },
20
+ "types": "./index.d.ts"
21
+ }
@@ -1,10 +1,10 @@
1
1
  import { BaseMessage } from '@langchain/core/messages';
2
2
  import { RunnableConfig } from '@langchain/core/runnables';
3
- import { TMessageContentComplex } from '@xpert-ai/chatkit-types';
3
+ import type { TMessageContentComplex } from '@xpert-ai/chatkit-types';
4
4
  import { Subscriber } from 'rxjs';
5
5
  import { ICopilotModel } from '../ai/copilot-model.model';
6
6
  import { TWorkflowVarGroup } from '../ai/xpert-workflow.model';
7
- import { TXpertGraph } from '../ai/xpert.model';
7
+ import { TXpertGraph, TXpertTeamNode } from '../ai/xpert.model';
8
8
  import { IXpertAgent } from '../ai/xpert-agent.model';
9
9
  /**
10
10
  * @deprecated can use getCurrentTaskInput instead?
@@ -31,6 +31,9 @@ export type TMessageChannel = {
31
31
  summary?: string;
32
32
  error?: string | null;
33
33
  };
34
+ export interface IBackendProtocol {
35
+ workingDirectory: string;
36
+ }
34
37
  export type TSandboxConfigurable = {
35
38
  /**
36
39
  * Resolved sandbox provider type used for this backend acquisition.
@@ -78,6 +81,12 @@ export type TAgentRunnableConfigurable = {
78
81
  agentKey: string;
79
82
  xpertName?: string;
80
83
  toolName?: string;
84
+ /**
85
+ * Additional runtime context for middleware/tool execution.
86
+ */
87
+ context?: Record<string, unknown> & {
88
+ env?: Record<string, unknown>;
89
+ };
81
90
  copilotModel?: ICopilotModel;
82
91
  subscriber: Subscriber<any>;
83
92
  /**
@@ -148,14 +157,6 @@ export declare function getAgentVarGroup(key: string, graph: TXpertGraph): TWork
148
157
  */
149
158
  export declare function getSwarmPartners(graph: TXpertGraph, agentKey: string, partners: string[], leaderKey?: string): string[];
150
159
  export declare function getWorkflowTriggers(graph: TXpertGraph, from: string): ((import("../ai/xpert.model").TXpertTeamNodeBase & {
151
- type: "agent";
152
- } & {
153
- entity: IXpertAgent;
154
- }) | (import("../ai/xpert.model").TXpertTeamNodeBase & {
155
- type: "knowledge";
156
- } & {
157
- entity: import("..").IKnowledgebase;
158
- }) | (import("../ai/xpert.model").TXpertTeamNodeBase & {
159
160
  type: "toolset";
160
161
  } & {
161
162
  entity: import("..").IXpertToolset;
@@ -163,29 +164,19 @@ export declare function getWorkflowTriggers(graph: TXpertGraph, from: string): (
163
164
  type: "xpert";
164
165
  } & {
165
166
  entity: import("../ai/xpert.model").IXpert;
166
- nodes?: ((import("../ai/xpert.model").TXpertTeamNodeBase & {
167
- type: "agent";
168
- } & {
169
- entity: IXpertAgent;
170
- }) | (import("../ai/xpert.model").TXpertTeamNodeBase & {
171
- type: "knowledge";
172
- } & {
173
- entity: import("..").IKnowledgebase;
174
- }) | (import("../ai/xpert.model").TXpertTeamNodeBase & {
175
- type: "toolset";
176
- } & {
177
- entity: import("..").IXpertToolset;
178
- }) | (import("../ai/xpert.model").TXpertTeamNodeBase & {
179
- type: "xpert";
180
- } & any) | (import("../ai/xpert.model").TXpertTeamNodeBase & {
181
- type: "workflow";
182
- } & {
183
- entity: import("../ai/xpert-workflow.model").IWorkflowNode;
184
- }))[];
167
+ nodes?: TXpertTeamNode[];
185
168
  connections?: import("../ai/xpert.model").TXpertTeamConnection[];
186
169
  expanded?: boolean;
187
170
  }) | (import("../ai/xpert.model").TXpertTeamNodeBase & {
188
171
  type: "workflow";
189
172
  } & {
190
173
  entity: import("../ai/xpert-workflow.model").IWorkflowNode;
174
+ }) | (import("../ai/xpert.model").TXpertTeamNodeBase & {
175
+ type: "agent";
176
+ } & {
177
+ entity: IXpertAgent;
178
+ }) | (import("../ai/xpert.model").TXpertTeamNodeBase & {
179
+ type: "knowledge";
180
+ } & {
181
+ entity: import("..").IKnowledgebase;
191
182
  }))[];
@@ -3,23 +3,6 @@ export type TTokenUsage = {
3
3
  completionTokens: number;
4
4
  totalTokens: number;
5
5
  };
6
- export type TThreadContextUsageMetrics = {
7
- contextTokens: number;
8
- inputTokens: number;
9
- outputTokens: number;
10
- totalTokens: number;
11
- embedTokens: number;
12
- totalPrice: number;
13
- currency: string | null;
14
- };
15
- export type TThreadContextUsageEvent = {
16
- type: 'thread_context_usage';
17
- threadId: string;
18
- runId: string | null;
19
- agentKey: string;
20
- updatedAt: string;
21
- usage: TThreadContextUsageMetrics;
22
- };
23
6
  export interface IModelUsage {
24
7
  totalTokens: number;
25
8
  totalPrice: number;
@@ -0,0 +1,74 @@
1
+ import { IBasePerTenantAndOrganizationEntityModel } from '../base-entity.model';
2
+ import { IUser } from '../user.model';
3
+ export declare enum AssistantCode {
4
+ CHAT_COMMON = "chat_common",
5
+ XPERT_SHARED = "xpert_shared",
6
+ CHATBI = "chatbi",
7
+ CLAWXPERT = "clawxpert"
8
+ }
9
+ export declare enum AssistantBindingScope {
10
+ TENANT = "tenant",
11
+ ORGANIZATION = "organization",
12
+ USER = "user"
13
+ }
14
+ export declare enum AssistantBindingSourceScope {
15
+ NONE = "none",
16
+ TENANT = "tenant",
17
+ ORGANIZATION = "organization"
18
+ }
19
+ export type AssistantManagement = 'system' | 'user';
20
+ export interface IAssistantBindingToolsetPreference {
21
+ toolsetId?: string | null;
22
+ toolsetName: string;
23
+ disabledTools: string[];
24
+ }
25
+ export interface IAssistantBindingMiddlewarePreference {
26
+ provider: string;
27
+ disabledTools: string[];
28
+ }
29
+ export interface IAssistantBindingSkillPreference {
30
+ workspaceId: string;
31
+ disabledSkillIds: string[];
32
+ }
33
+ export interface IAssistantBindingToolPreferences {
34
+ version: 1;
35
+ toolsets?: Record<string, IAssistantBindingToolsetPreference>;
36
+ middlewares?: Record<string, IAssistantBindingMiddlewarePreference>;
37
+ skills?: Record<string, IAssistantBindingSkillPreference>;
38
+ }
39
+ export interface IAssistantBinding extends IBasePerTenantAndOrganizationEntityModel {
40
+ code: AssistantCode;
41
+ scope: AssistantBindingScope;
42
+ assistantId?: string | null;
43
+ enabled?: boolean | null;
44
+ userId?: string | null;
45
+ user?: IUser;
46
+ preferences?: IAssistantBindingUserPreference[];
47
+ }
48
+ export interface IAssistantBindingUserPreference extends IBasePerTenantAndOrganizationEntityModel {
49
+ assistantBindingId: string;
50
+ assistantBinding?: IAssistantBinding;
51
+ userId?: string | null;
52
+ user?: IUser;
53
+ soul?: string | null;
54
+ profile?: string | null;
55
+ toolPreferences?: IAssistantBindingToolPreferences | null;
56
+ }
57
+ export interface IResolvedAssistantBinding extends IAssistantBinding {
58
+ sourceScope: AssistantBindingSourceScope;
59
+ }
60
+ export interface IAssistantBindingUpsertInput {
61
+ code: AssistantCode;
62
+ scope: AssistantBindingScope;
63
+ assistantId?: string | null;
64
+ enabled?: boolean;
65
+ }
66
+ export interface IAssistantBindingUserPreferenceUpsertInput {
67
+ scope: AssistantBindingScope;
68
+ soul?: string | null;
69
+ profile?: string | null;
70
+ toolPreferences?: IAssistantBindingToolPreferences | null;
71
+ }
72
+ export declare function getAssistantManagement(code: AssistantCode): AssistantManagement;
73
+ export declare function isUserManagedAssistant(code: AssistantCode): boolean;
74
+ export declare function isSystemManagedAssistant(code: AssistantCode): boolean;
@@ -0,0 +1,8 @@
1
+ import type { TChatEventMessage } from '@xpert-ai/chatkit-types';
2
+ export declare const CHAT_EVENT_TYPE_THREAD_CONTEXT_USAGE: "thread_context_usage";
3
+ export declare const CHAT_EVENT_TYPE_CONVERSATION_TITLE_SUMMARY: "conversation_title_summary";
4
+ export type TConversationTitleSummaryEvent = TChatEventMessage & {
5
+ id?: string;
6
+ type: typeof CHAT_EVENT_TYPE_CONVERSATION_TITLE_SUMMARY;
7
+ };
8
+ export declare function createConversationTitleSummaryEvent(event: Omit<TConversationTitleSummaryEvent, 'type'>): TConversationTitleSummaryEvent;
@@ -1,11 +1,11 @@
1
1
  import { MessageType } from '@langchain/core/messages';
2
+ import type { TChatMessageStep, TMessageContent, TMessageContentReasoning } from '@xpert-ai/chatkit-types';
2
3
  import { IBasePerTenantAndOrganizationEntityModel } from '../base-entity.model';
3
4
  import { IChatConversation } from './chat.model';
4
5
  import { LongTermMemoryTypeEnum } from './xpert.model';
5
6
  import { IXpertAgentExecution, XpertAgentExecutionStatusEnum } from './xpert-agent-execution.model';
6
7
  import { JSONValue } from '../core.model';
7
8
  import { IStorageFile } from '../storage-file.model';
8
- import { TChatMessageStep, TMessageContent, TMessageContentReasoning } from '@xpert-ai/chatkit-types';
9
9
  export type TSummaryJob = Record<LongTermMemoryTypeEnum, {
10
10
  jobId: number | string;
11
11
  status: string;
@@ -2,5 +2,9 @@ export declare enum AiFeatureEnum {
2
2
  FEATURE_COPILOT = "FEATURE_COPILOT",
3
3
  FEATURE_COPILOT_KNOWLEDGEBASE = "FEATURE_COPILOT_KNOWLEDGEBASE",
4
4
  FEATURE_COPILOT_CHAT = "FEATURE_COPILOT_CHAT",
5
- FEATURE_XPERT = "FEATURE_XPERT"
5
+ FEATURE_XPERT = "FEATURE_XPERT",
6
+ FEATURE_XPERT_CHATBI = "FEATURE_XPERT_CHATBI",
7
+ FEATURE_XPERT_CLAWXPERT = "FEATURE_XPERT_CLAWXPERT",
8
+ FEATURE_XPERT_CODEXPERT = "FEATURE_XPERT_CODEXPERT",
9
+ FEATURE_XPERT_DEEP_RESEARCH = "FEATURE_XPERT_DEEP_RESEARCH"
6
10
  }
package/src/ai/index.d.ts CHANGED
@@ -1,7 +1,44 @@
1
- export * from '@xpert-ai/chatkit-types';
1
+ export declare const STATE_VARIABLE_HUMAN = "human";
2
+ export declare enum ChatMessageTypeEnum {
3
+ MESSAGE = "message",
4
+ EVENT = "event"
5
+ }
6
+ export declare enum ChatMessageEventTypeEnum {
7
+ ON_CONVERSATION_START = "on_conversation_start",
8
+ ON_CONVERSATION_END = "on_conversation_end",
9
+ ON_MESSAGE_START = "on_message_start",
10
+ ON_MESSAGE_END = "on_message_end",
11
+ ON_TOOL_START = "on_tool_start",
12
+ ON_TOOL_END = "on_tool_end",
13
+ ON_TOOL_ERROR = "on_tool_error",
14
+ ON_TOOL_MESSAGE = "on_tool_message",
15
+ ON_AGENT_START = "on_agent_start",
16
+ ON_AGENT_END = "on_agent_end",
17
+ ON_RETRIEVER_START = "on_retriever_start",
18
+ ON_RETRIEVER_END = "on_retriever_end",
19
+ ON_RETRIEVER_ERROR = "on_retriever_error",
20
+ ON_INTERRUPT = "on_interrupt",
21
+ ON_ERROR = "on_error",
22
+ ON_CHAT_EVENT = "on_chat_event",
23
+ ON_CLIENT_EFFECT = "on_client_effect"
24
+ }
25
+ export declare enum ChatMessageStepCategory {
26
+ List = "list",
27
+ WebSearch = "web_search",
28
+ Files = "files",
29
+ File = "file",
30
+ Program = "program",
31
+ Iframe = "iframe",
32
+ Memory = "memory",
33
+ Tasks = "tasks",
34
+ Knowledges = "knowledges"
35
+ }
36
+ export type * from '@xpert-ai/chatkit-types';
2
37
  export type { TChatRequest } from './xpert-chat.model';
38
+ export * from './assistant-binding.model';
3
39
  export * from './ai-model.model';
4
40
  export * from './ai.model';
41
+ export * from './chat-event.model';
5
42
  export * from './chat.model';
6
43
  export * from './chat-message.model';
7
44
  export * from './chat-message-feedback.model';
@@ -1,4 +1,4 @@
1
- import { TMessageContent, TMessageContentComplex } from '@xpert-ai/chatkit-types';
1
+ import type { TMessageContent, TMessageContentComplex } from '@xpert-ai/chatkit-types';
2
2
  import { CopilotChatMessage } from './chat-message.model';
3
3
  export type TMessageJoinHint = 'none' | 'space' | 'line' | 'paragraph';
4
4
  export type TMessageAppendContext = {
@@ -48,5 +48,11 @@ export declare function createMessageAppendContextTracker(initial?: TMessageAppe
48
48
  */
49
49
  export declare function appendMessageContent(aiMessage: CopilotChatMessage, incoming: string | TMessageContentComplex, context?: TAppendMessageContentOptions): void;
50
50
  export declare function appendMessagePlainText(accumulator: string, incoming: string | TMessageContentComplex, context?: TMessageAppendContext): string;
51
+ /**
52
+ * Creates a display-only content view that reassembles text chunks belonging to
53
+ * the same stream id. This preserves markdown continuity without changing the
54
+ * underlying stored/streamed message structure.
55
+ */
56
+ export declare function mergeMessageContentForDisplay(content: TMessageContent | TMessageContentComplex | null | undefined): TMessageContentComplex[] | null;
51
57
  export declare function stringifyMessageContent(content: TMessageContent | TMessageContentComplex): string;
52
58
  export declare function filterMessageText(content: TMessageContent | TMessageContentComplex): string;
@@ -4,12 +4,28 @@ import { JsonSchemaObjectType } from "./types";
4
4
  import { IWorkflowNode, WorkflowNodeTypeEnum } from "./xpert-workflow.model";
5
5
  import { IBasePerWorkspaceEntityModel } from "./xpert-workspace.model";
6
6
  export type SkillId = string;
7
+ export interface ISkillRepositoryIndexStats {
8
+ comments?: number;
9
+ downloads?: number;
10
+ installsAllTime?: number;
11
+ installsCurrent?: number;
12
+ stars?: number;
13
+ versions?: number;
14
+ }
15
+ export interface ISkillRepositoryIndexPublisher {
16
+ handle?: string;
17
+ displayName?: string;
18
+ name?: string;
19
+ image?: string;
20
+ kind?: string;
21
+ }
7
22
  export interface SkillMetadata {
8
23
  name: string;
9
24
  displayName?: I18nObject;
10
25
  version: string;
11
26
  summary?: I18nObject;
12
27
  description?: I18nObject;
28
+ icon?: IconDefinition;
13
29
  tags?: string[];
14
30
  author?: {
15
31
  name: string;
@@ -59,15 +75,15 @@ export interface TSkillPackage {
59
75
  owners: string[];
60
76
  readers: string[];
61
77
  writers: string[];
62
- policies?: any;
78
+ policies?: Record<string, unknown>;
63
79
  };
64
80
  signatures?: string[];
65
- provenance?: any;
81
+ provenance?: Record<string, unknown>;
66
82
  }
67
83
  /**
68
- * 表示一个仓库(如 anthropics/skills
84
+ * Represents a repository (e.g. anthropics/skills)
69
85
  */
70
- export interface ISkillRepository<O = Record<string, any>, C = Record<string, any>> extends IBasePerTenantAndOrganizationEntityModel {
86
+ export interface ISkillRepository<O = Record<string, unknown>, C = Record<string, unknown>> extends IBasePerTenantAndOrganizationEntityModel {
71
87
  name: string;
72
88
  provider: string;
73
89
  /**
@@ -78,11 +94,11 @@ export interface ISkillRepository<O = Record<string, any>, C = Record<string, an
78
94
  * Options configured using the strategy's configSchema
79
95
  */
80
96
  options?: O;
81
- lastSyncAt?: string;
97
+ lastSyncAt?: Date;
82
98
  deletedAt?: Date;
83
99
  }
84
100
  /**
85
- * 仓库同步扫描得到的技能索引(每个技能目录一条)
101
+ * Skill index produced by repository sync scan (one per skill directory)
86
102
  */
87
103
  export interface ISkillRepositoryIndex extends IBasePerTenantAndOrganizationEntityModel {
88
104
  repositoryId: string;
@@ -90,35 +106,38 @@ export interface ISkillRepositoryIndex extends IBasePerTenantAndOrganizationEnti
90
106
  skillPath: string;
91
107
  skillId: string;
92
108
  name?: string;
109
+ link?: string;
110
+ publisher?: ISkillRepositoryIndexPublisher;
93
111
  description?: string;
94
112
  license?: string;
95
113
  tags?: string[];
96
114
  version?: string;
97
- resources?: any[];
115
+ stats?: ISkillRepositoryIndexStats;
116
+ resources?: Array<Record<string, unknown>>;
98
117
  deletedAt?: Date;
99
118
  }
100
119
  /**
101
- * 安装后的技能包主记录(skill.yaml
120
+ * Installed skill package record (skill.yaml)
102
121
  */
103
122
  export interface ISkillPackage extends IBasePerWorkspaceEntityModel, TSkillPackage {
104
123
  skillIndexId?: SkillId;
105
124
  skillIndex?: ISkillRepositoryIndex;
106
- name?: any;
125
+ name?: string;
107
126
  visibility: 'private' | 'team' | 'tenant';
108
127
  packagePath?: string;
109
128
  }
110
129
  /**
111
- * 技能的版本(1个 Skill 多版本共存)
130
+ * Skill version (multiple versions can coexist per skill)
112
131
  */
113
132
  export interface ISkillVersion extends IBasePerWorkspaceEntityModel {
114
133
  packageId: string;
115
134
  version: string;
116
- metadata: any;
117
- instructions: any;
135
+ metadata: SkillMetadata;
136
+ instructions: TSkillPackage['instructions'];
118
137
  installedAt?: string;
119
138
  }
120
139
  /**
121
- * 技能资源文件(scripts/templates/assets)记录
140
+ * Skill resource file record (scripts/templates/assets)
122
141
  */
123
142
  export interface ISkillResource extends IBasePerWorkspaceEntityModel {
124
143
  versionId: string;
@@ -126,10 +145,10 @@ export interface ISkillResource extends IBasePerWorkspaceEntityModel {
126
145
  type: 'script' | 'template' | 'asset' | 'doc';
127
146
  hash?: string;
128
147
  size?: number;
129
- meta?: any;
148
+ meta?: Record<string, unknown>;
130
149
  }
131
150
  /**
132
- * 租户/组织/团队/用户安装行为记录
151
+ * Tenant/organization/team/user installation record
133
152
  */
134
153
  export interface ISkillInstallation extends IBasePerTenantAndOrganizationEntityModel {
135
154
  versionId: string;
@@ -139,7 +158,7 @@ export interface ISkillInstallation extends IBasePerTenantAndOrganizationEntityM
139
158
  status: 'pending' | 'installed' | 'failed';
140
159
  }
141
160
  /**
142
- * 技能安装过程中详细日志
161
+ * Detailed logs during skill installation
143
162
  */
144
163
  export interface ISkillInstallLog extends IBasePerTenantAndOrganizationEntityModel {
145
164
  installationId: string;
@@ -148,14 +167,14 @@ export interface ISkillInstallLog extends IBasePerTenantAndOrganizationEntityMod
148
167
  timestamp: string;
149
168
  }
150
169
  /**
151
- * 技能运行期审计日志
170
+ * Runtime audit log for skills
152
171
  */
153
172
  export interface ISkillAuditLog extends IBasePerTenantAndOrganizationEntityModel {
154
173
  skillId: string;
155
174
  versionId: string;
156
175
  sessionId: string;
157
176
  eventType: string;
158
- metadata: any;
177
+ metadata: Record<string, unknown>;
159
178
  }
160
179
  export type TSkillSourceMeta = {
161
180
  /**
@@ -27,6 +27,15 @@ export type TXpertExecution = {
27
27
  xpertId?: string;
28
28
  parentId?: string;
29
29
  };
30
+ export type TXpertAgentExecutionCheckpoint = {
31
+ threadId: string;
32
+ checkpointNs: string;
33
+ checkpointId: string;
34
+ parentCheckpointId?: string | null;
35
+ createdAt?: string | null;
36
+ metadata?: Record<string, unknown> | null;
37
+ isCurrent?: boolean;
38
+ };
30
39
  /**
31
40
  * Corresponds to the run in the [Agent Protocol](https://github.com/langchain-ai/agent-protocol).
32
41
  */
@@ -1,4 +1,5 @@
1
- import { STATE_VARIABLE_HUMAN, TChatRequestHuman, TInterruptCommand } from '@xpert-ai/chatkit-types';
1
+ import type { TChatRequestHuman, TInterruptCommand } from '@xpert-ai/chatkit-types';
2
+ import { STATE_VARIABLE_HUMAN } from '@xpert-ai/chatkit-types';
2
3
  export type TXpertChatState = {
3
4
  [STATE_VARIABLE_HUMAN]?: TChatRequestHuman;
4
5
  } & Record<string, any>;
@@ -40,6 +41,7 @@ export type TXpertChatRetryRequest = {
40
41
  conversationId: string;
41
42
  source: TXpertChatSource;
42
43
  environmentId?: string;
44
+ checkpointId?: string;
43
45
  };
44
46
  export type TChatRequest = TXpertChatSendRequest | TXpertChatResumeRequest | TXpertChatRetryRequest;
45
47
  export type TXpertAgentChatRunRequest = {
@@ -16,7 +16,12 @@ export interface IXpertWorkspace extends IBasePerTenantAndOrganizationEntityMode
16
16
  environments?: IEnvironment[];
17
17
  members?: IUser[];
18
18
  }
19
- export type TXpertWorkspaceSettings = {};
19
+ export type TXpertWorkspaceSettings = {
20
+ system?: {
21
+ kind?: 'org-default' | 'user-default';
22
+ userId?: string;
23
+ };
24
+ };
20
25
  export type TXpertWorkspaceStatus = 'active' | 'deprecated' | 'archived';
21
26
  export interface IBasePerWorkspaceEntityModel extends IBasePerTenantAndOrganizationEntityModel {
22
27
  workspaceId?: string;
@@ -3,6 +3,7 @@ import { RunnableToolLike } from '@langchain/core/runnables';
3
3
  import { StructuredToolInterface } from '@langchain/core/tools';
4
4
  import { ITag } from '../tag-entity.model';
5
5
  import { IUser, LanguagesEnum } from '../user.model';
6
+ import { IUserGroup } from '../user-group.model';
6
7
  import { ICopilotModel, TCopilotModel } from './copilot-model.model';
7
8
  import { IKnowledgebase, TKBRecallParams } from './knowledgebase.model';
8
9
  import { ChecklistItem, I18nObject, IPoint, ISize, TAvatar } from '../types';
@@ -159,9 +160,9 @@ export type TXpert = {
159
160
  knowledgebases?: IKnowledgebase[];
160
161
  toolsets?: IXpertToolset[];
161
162
  /**
162
- * The corresponding person in charge, whose has the authority to execute this digital expert
163
+ * User groups that are allowed to use this published digital expert.
163
164
  */
164
- managers?: IUser[];
165
+ userGroups?: IUserGroup[];
165
166
  /**
166
167
  * Integrations for this xpert
167
168
  */
@@ -180,6 +181,11 @@ export interface IXpert extends IBasePerWorkspaceEntityModel, TXpert {
180
181
  knowledgebase?: IKnowledgebase;
181
182
  }
182
183
  export type TXpertOptions = {
184
+ bootstrap?: {
185
+ source: 'template';
186
+ templateKey: string;
187
+ workspaceKind: 'org-default';
188
+ };
183
189
  knowledge?: Record<string, {
184
190
  position?: IPoint;
185
191
  size?: ISize;
@@ -482,6 +488,10 @@ export type TChatOptions = {
482
488
  * Specify additional tools
483
489
  */
484
490
  tools?: (StructuredToolInterface | RunnableToolLike)[];
491
+ /**
492
+ * Per-request runtime context forwarded to agent middleware/tools.
493
+ */
494
+ context?: Record<string, unknown>;
485
495
  };
486
496
  /**
487
497
  * Knowledgebase retrieval settings
@@ -1,6 +1,6 @@
1
1
  import { IPoint } from '../types';
2
2
  import { IXpertAgent } from './xpert-agent.model';
3
- import { IXpert, TXpertTeamNode } from './xpert.model';
3
+ import { IXpert, TXpertTeamConnection, TXpertTeamDraft, TXpertTeamNode } from './xpert.model';
4
4
  export declare function omitXpertRelations(xpert: Partial<IXpert>): {
5
5
  environmentId?: string;
6
6
  workspaceId?: string;
@@ -11,10 +11,10 @@ export declare function omitXpertRelations(xpert: Partial<IXpert>): {
11
11
  organization?: import("..").IOrganization;
12
12
  tenantId?: string;
13
13
  tenant?: import("..").ITenant;
14
- id?: string;
15
- createdById?: string;
14
+ id?: import("../types").ID;
15
+ createdById?: import("../types").ID;
16
16
  createdBy?: import("..").IUser;
17
- updatedById?: string;
17
+ updatedById?: import("../types").ID;
18
18
  updatedBy?: import("..").IUser;
19
19
  createdAt?: Date;
20
20
  updatedAt?: Date;
@@ -59,7 +59,7 @@ export declare function createXpertGraph(xpert: IXpert, position: IPoint): {
59
59
  width: number;
60
60
  height: number;
61
61
  };
62
- connections: import("./xpert.model").TXpertTeamConnection[];
62
+ connections: TXpertTeamConnection[];
63
63
  };
64
64
  export declare function locateNodes(nodes: TXpertTeamNode[], position: IPoint): {
65
65
  size: {
@@ -82,3 +82,6 @@ export declare function createXpertNodes(xpert: IXpert, position: IPoint): {
82
82
  };
83
83
  };
84
84
  export declare function createAgentConnections(agent: IXpertAgent, collaborators: IXpert[]): any[];
85
+ export declare function replaceAgentInDraft(draft: TXpertTeamDraft, sourceKey: string, agent: Partial<IXpertAgent>, options?: {
86
+ requireNode?: boolean;
87
+ }): TXpertTeamDraft;
@@ -1,10 +1,68 @@
1
1
  import { IBasePerTenantAndOrganizationEntityModel } from './base-entity.model';
2
+ import { IUser } from './user.model';
3
+ /**
4
+ * Represents an API key used for authentication and authorization.
5
+ */
2
6
  export interface IApiKey extends IBasePerTenantAndOrganizationEntityModel {
3
7
  token: string;
4
8
  name?: string;
5
- type?: string;
9
+ /**
10
+ * Stable binding kind for resolving the technical principal behind this key.
11
+ */
12
+ type?: ApiKeyBindingType;
13
+ /**
14
+ * Stable binding target id/code. Examples:
15
+ * - assistant => xpertId
16
+ * - integration => integrationId
17
+ * - client => clientCode
18
+ */
6
19
  entityId?: string;
7
20
  validUntil?: Date;
8
21
  expired?: boolean;
9
22
  lastUsedAt?: Date;
23
+ /**
24
+ * Explicit technical principal bound to this apiKey.
25
+ * When set, it takes precedence over type/entityId resolution.
26
+ */
27
+ userId?: string;
28
+ user?: IUser;
29
+ }
30
+ /**
31
+ * Optional request header used by third-party callers to explicitly set the
32
+ * business user represented by the current request context.
33
+ */
34
+ export declare const API_PRINCIPAL_USER_ID_HEADER = "x-principal-user-id";
35
+ /**
36
+ * Stable binding kinds used to resolve long-lived technical principals.
37
+ */
38
+ export declare enum ApiKeyBindingType {
39
+ ASSISTANT = "assistant",
40
+ INTEGRATION = "integration",
41
+ CLIENT = "client",
42
+ /**
43
+ * @deprecated legacy type, do not use for new keys. Will be resolved as assistant for backward compatibility.
44
+ */
45
+ KNOWLEDGEBASE = "knowledgebase"
46
+ }
47
+ export type ApiPrincipalType = 'api_key' | 'client_secret';
48
+ export interface IApiPrincipal extends IUser {
49
+ apiKey: IApiKey;
50
+ principalType: ApiPrincipalType;
51
+ /**
52
+ * Resource owner / key creator. Used for audit and ownership metadata.
53
+ */
54
+ ownerUserId?: string | null;
55
+ /**
56
+ * Technical principal resolved from apiKey.userId or stable type/entityId binding.
57
+ */
58
+ apiKeyUserId?: string | null;
59
+ /**
60
+ * Explicit business user id requested by the caller via x-principal-user-id.
61
+ */
62
+ requestedUserId?: string | null;
63
+ /**
64
+ * Original organization context requested by the caller before api-key
65
+ * authentication normalized the request into tenant scope.
66
+ */
67
+ requestedOrganizationId?: string | null;
10
68
  }