@api-client/core 0.19.1 → 0.19.3
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/build/src/browser.d.ts +5 -1
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +4 -0
- package/build/src/browser.js.map +1 -1
- package/build/src/index.d.ts +4 -0
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +4 -0
- package/build/src/index.js.map +1 -1
- package/build/src/mocking/ModelingMock.d.ts +2 -0
- package/build/src/mocking/ModelingMock.d.ts.map +1 -1
- package/build/src/mocking/ModelingMock.js +2 -0
- package/build/src/mocking/ModelingMock.js.map +1 -1
- package/build/src/mocking/lib/Ai.d.ts +11 -0
- package/build/src/mocking/lib/Ai.d.ts.map +1 -0
- package/build/src/mocking/lib/Ai.js +53 -0
- package/build/src/mocking/lib/Ai.js.map +1 -0
- package/build/src/modeling/ai/DataDomainDelta.d.ts +146 -0
- package/build/src/modeling/ai/DataDomainDelta.d.ts.map +1 -0
- package/build/src/modeling/ai/DataDomainDelta.js +729 -0
- package/build/src/modeling/ai/DataDomainDelta.js.map +1 -0
- package/build/src/modeling/ai/DomainSerialization.d.ts +20 -0
- package/build/src/modeling/ai/DomainSerialization.d.ts.map +1 -0
- package/build/src/modeling/ai/DomainSerialization.js +185 -0
- package/build/src/modeling/ai/DomainSerialization.js.map +1 -0
- package/build/src/modeling/ai/domain_response_schema.d.ts +806 -0
- package/build/src/modeling/ai/domain_response_schema.d.ts.map +1 -0
- package/build/src/modeling/ai/domain_response_schema.js +289 -0
- package/build/src/modeling/ai/domain_response_schema.js.map +1 -0
- package/build/src/modeling/ai/domain_tools.d.ts +68 -0
- package/build/src/modeling/ai/domain_tools.d.ts.map +1 -0
- package/build/src/modeling/ai/domain_tools.js +71 -0
- package/build/src/modeling/ai/domain_tools.js.map +1 -0
- package/build/src/modeling/ai/index.d.ts +10 -0
- package/build/src/modeling/ai/index.d.ts.map +1 -0
- package/build/src/modeling/ai/index.js +9 -0
- package/build/src/modeling/ai/index.js.map +1 -0
- package/build/src/modeling/ai/message_parser.d.ts +23 -0
- package/build/src/modeling/ai/message_parser.d.ts.map +1 -0
- package/build/src/modeling/ai/message_parser.js +93 -0
- package/build/src/modeling/ai/message_parser.js.map +1 -0
- package/build/src/modeling/ai/prompts/domain_system.d.ts +6 -0
- package/build/src/modeling/ai/prompts/domain_system.d.ts.map +1 -0
- package/build/src/modeling/ai/prompts/domain_system.js +80 -0
- package/build/src/modeling/ai/prompts/domain_system.js.map +1 -0
- package/build/src/modeling/ai/tools/DataDomain.tools.d.ts +25 -0
- package/build/src/modeling/ai/tools/DataDomain.tools.d.ts.map +1 -0
- package/build/src/modeling/ai/tools/DataDomain.tools.js +334 -0
- package/build/src/modeling/ai/tools/DataDomain.tools.js.map +1 -0
- package/build/src/modeling/ai/tools/Semantic.tools.d.ts +48 -0
- package/build/src/modeling/ai/tools/Semantic.tools.d.ts.map +1 -0
- package/build/src/modeling/ai/tools/Semantic.tools.js +36 -0
- package/build/src/modeling/ai/tools/Semantic.tools.js.map +1 -0
- package/build/src/modeling/ai/tools/config.d.ts +13 -0
- package/build/src/modeling/ai/tools/config.d.ts.map +1 -0
- package/build/src/modeling/ai/tools/config.js +2 -0
- package/build/src/modeling/ai/tools/config.js.map +1 -0
- package/build/src/modeling/ai/types.d.ts +302 -0
- package/build/src/modeling/ai/types.d.ts.map +1 -0
- package/build/src/modeling/ai/types.js +40 -0
- package/build/src/modeling/ai/types.js.map +1 -0
- package/build/src/models/AiMessage.d.ts +185 -0
- package/build/src/models/AiMessage.d.ts.map +1 -0
- package/build/src/models/AiMessage.js +203 -0
- package/build/src/models/AiMessage.js.map +1 -0
- package/build/src/models/AiSession.d.ts +80 -0
- package/build/src/models/AiSession.d.ts.map +1 -0
- package/build/src/models/AiSession.js +102 -0
- package/build/src/models/AiSession.js.map +1 -0
- package/build/src/models/kinds.d.ts +2 -0
- package/build/src/models/kinds.d.ts.map +1 -1
- package/build/src/models/kinds.js +2 -0
- package/build/src/models/kinds.js.map +1 -1
- package/build/src/sdk/AiSdk.d.ts +93 -0
- package/build/src/sdk/AiSdk.d.ts.map +1 -0
- package/build/src/sdk/AiSdk.js +348 -0
- package/build/src/sdk/AiSdk.js.map +1 -0
- package/build/src/sdk/RouteBuilder.d.ts +7 -0
- package/build/src/sdk/RouteBuilder.d.ts.map +1 -1
- package/build/src/sdk/RouteBuilder.js +18 -0
- package/build/src/sdk/RouteBuilder.js.map +1 -1
- package/build/src/sdk/Sdk.d.ts +2 -0
- package/build/src/sdk/Sdk.d.ts.map +1 -1
- package/build/src/sdk/Sdk.js +2 -0
- package/build/src/sdk/Sdk.js.map +1 -1
- package/build/src/sdk/SdkBase.d.ts +4 -0
- package/build/src/sdk/SdkBase.d.ts.map +1 -1
- package/build/src/sdk/SdkBase.js.map +1 -1
- package/build/src/sdk/SdkMock.d.ts +15 -0
- package/build/src/sdk/SdkMock.d.ts.map +1 -1
- package/build/src/sdk/SdkMock.js +118 -0
- package/build/src/sdk/SdkMock.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +22 -22
- package/package.json +3 -3
- package/src/mocking/ModelingMock.ts +2 -0
- package/src/mocking/lib/Ai.ts +71 -0
- package/src/modeling/ai/DataDomainDelta.ts +798 -0
- package/src/modeling/ai/DomainSerialization.ts +199 -0
- package/src/modeling/ai/domain_response_schema.ts +301 -0
- package/src/modeling/ai/domain_tools.ts +76 -0
- package/src/modeling/ai/message_parser.ts +101 -0
- package/src/modeling/ai/prompts/domain_system.ts +79 -0
- package/src/modeling/ai/readme.md +8 -0
- package/src/modeling/ai/tools/DataDomain.tools.ts +365 -0
- package/src/modeling/ai/tools/Semantic.tools.ts +38 -0
- package/src/modeling/ai/tools/config.ts +13 -0
- package/src/modeling/ai/tools/readme.md +3 -0
- package/src/modeling/ai/types.ts +306 -0
- package/src/models/AiMessage.ts +335 -0
- package/src/models/AiSession.ts +160 -0
- package/src/models/kinds.ts +2 -0
- package/src/sdk/AiSdk.ts +395 -0
- package/src/sdk/RouteBuilder.ts +27 -0
- package/src/sdk/Sdk.ts +3 -0
- package/src/sdk/SdkBase.ts +4 -0
- package/src/sdk/SdkMock.ts +185 -0
- package/tests/unit/mocking/current/Ai.spec.ts +109 -0
- package/tests/unit/modeling/ai/DataDomainDelta.spec.ts +419 -0
- package/tests/unit/modeling/ai/DomainAiTools.spec.ts +29 -0
- package/tests/unit/modeling/ai/DomainSerialization.spec.ts +143 -0
- package/tests/unit/modeling/ai/message_parser.spec.ts +157 -0
- package/tests/unit/modeling/ai/tools/DataDomain.tools.spec.ts +64 -0
- package/tests/unit/modeling/ai/tools/Semantic.tools.spec.ts +55 -0
- package/tests/unit/models/AiMessage.spec.ts +216 -0
- package/tests/unit/models/AiSession.spec.ts +147 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { AiMessageKind } from './kinds.js';
|
|
2
|
+
import { nanoid } from '../nanoid.js';
|
|
3
|
+
import { DataDomainDelta } from '../modeling/ai/DataDomainDelta.js';
|
|
4
|
+
/**
|
|
5
|
+
* The base class for all AI messages.
|
|
6
|
+
* It provides common functionality for all message types.
|
|
7
|
+
*/
|
|
8
|
+
export class AiMessageBase {
|
|
9
|
+
/**
|
|
10
|
+
* The kind of the schema.
|
|
11
|
+
*/
|
|
12
|
+
static get Kind() {
|
|
13
|
+
return AiMessageKind;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The kind of the schema.
|
|
17
|
+
*/
|
|
18
|
+
get kind() {
|
|
19
|
+
return AiMessageKind;
|
|
20
|
+
}
|
|
21
|
+
key;
|
|
22
|
+
role;
|
|
23
|
+
createdAt;
|
|
24
|
+
updatedAt;
|
|
25
|
+
session;
|
|
26
|
+
text;
|
|
27
|
+
deleted;
|
|
28
|
+
deletedInfo;
|
|
29
|
+
static createBaseSchema(input) {
|
|
30
|
+
const { key = nanoid(), session, text = '', createdAt = 0, updatedAt = 0 } = input;
|
|
31
|
+
if (!session) {
|
|
32
|
+
throw new Error('Session is required to create an AiMessage.');
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
key,
|
|
36
|
+
kind: AiMessageKind,
|
|
37
|
+
session,
|
|
38
|
+
text,
|
|
39
|
+
createdAt,
|
|
40
|
+
updatedAt,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
constructor(input = {}, role) {
|
|
44
|
+
const base = AiMessageBase.createBaseSchema(input);
|
|
45
|
+
this.key = base.key;
|
|
46
|
+
this.role = role;
|
|
47
|
+
this.session = base.session;
|
|
48
|
+
this.text = base.text;
|
|
49
|
+
this.createdAt = base.createdAt;
|
|
50
|
+
this.updatedAt = base.updatedAt;
|
|
51
|
+
this.deleted = input.deleted || false;
|
|
52
|
+
this.deletedInfo = input.deletedInfo;
|
|
53
|
+
}
|
|
54
|
+
toJSON() {
|
|
55
|
+
const result = {
|
|
56
|
+
kind: this.kind,
|
|
57
|
+
key: this.key,
|
|
58
|
+
role: this.role,
|
|
59
|
+
session: this.session,
|
|
60
|
+
text: this.text,
|
|
61
|
+
createdAt: this.createdAt,
|
|
62
|
+
updatedAt: this.updatedAt,
|
|
63
|
+
};
|
|
64
|
+
if (this.deleted && this.deletedInfo) {
|
|
65
|
+
Object.assign(result, {
|
|
66
|
+
deleted: this.deleted,
|
|
67
|
+
deletedInfo: { ...this.deletedInfo },
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export class AiUserMessage extends AiMessageBase {
|
|
74
|
+
state;
|
|
75
|
+
static createSchema(input) {
|
|
76
|
+
const base = AiMessageBase.createBaseSchema(input);
|
|
77
|
+
return {
|
|
78
|
+
...base,
|
|
79
|
+
role: 'user',
|
|
80
|
+
state: 'complete',
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
constructor(input = {}) {
|
|
84
|
+
super(input, 'user');
|
|
85
|
+
this.state = 'complete';
|
|
86
|
+
}
|
|
87
|
+
toJSON() {
|
|
88
|
+
return {
|
|
89
|
+
...super.toJSON(),
|
|
90
|
+
state: this.state,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export class AiModelMessage extends AiMessageBase {
|
|
95
|
+
state;
|
|
96
|
+
applied;
|
|
97
|
+
thoughts;
|
|
98
|
+
/**
|
|
99
|
+
* The delta of the message, if any.
|
|
100
|
+
*/
|
|
101
|
+
delta;
|
|
102
|
+
/**
|
|
103
|
+
* The reasoning of the delta.
|
|
104
|
+
* Format in markdown.
|
|
105
|
+
*/
|
|
106
|
+
reasoning;
|
|
107
|
+
static createSchema(input) {
|
|
108
|
+
const base = AiMessageBase.createBaseSchema(input);
|
|
109
|
+
return {
|
|
110
|
+
...base,
|
|
111
|
+
role: 'model',
|
|
112
|
+
state: input.state || 'loading',
|
|
113
|
+
applied: input.applied,
|
|
114
|
+
thoughts: input.thoughts || '',
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
constructor(input = {}) {
|
|
118
|
+
super(input, 'model');
|
|
119
|
+
this.state = input.state || 'loading';
|
|
120
|
+
this.applied = input.applied;
|
|
121
|
+
this.thoughts = input.thoughts || '';
|
|
122
|
+
}
|
|
123
|
+
toJSON() {
|
|
124
|
+
const result = {
|
|
125
|
+
...super.toJSON(),
|
|
126
|
+
state: this.state,
|
|
127
|
+
thoughts: this.thoughts,
|
|
128
|
+
};
|
|
129
|
+
if (this.applied !== undefined) {
|
|
130
|
+
result.applied = this.applied;
|
|
131
|
+
}
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Adds a thought to the message. Useful when streaming.
|
|
136
|
+
* @param thought The thought to add.
|
|
137
|
+
*/
|
|
138
|
+
addThought(thought) {
|
|
139
|
+
if (!thought) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
this.thoughts += thought;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Adds a text chunk to the message. Useful when streaming.
|
|
146
|
+
* @param text The text chunk to add.
|
|
147
|
+
*/
|
|
148
|
+
addText(text) {
|
|
149
|
+
if (!text) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
this.text += text;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Processes the message.
|
|
156
|
+
* If the message is not valid JSON, it will throw an error.
|
|
157
|
+
* It sets the delta and reasoning fields, if found in the message.
|
|
158
|
+
*/
|
|
159
|
+
processMessage() {
|
|
160
|
+
if (!this.text) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const parsed = JSON.parse(this.text);
|
|
164
|
+
if (parsed.delta) {
|
|
165
|
+
this.delta = DataDomainDelta.normalize(parsed.delta);
|
|
166
|
+
}
|
|
167
|
+
if (parsed.reasoning) {
|
|
168
|
+
this.reasoning = parsed.reasoning;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Processes the message safely.
|
|
173
|
+
* If the message is not valid JSON, it will be ignored.
|
|
174
|
+
*/
|
|
175
|
+
processMessageSafe() {
|
|
176
|
+
try {
|
|
177
|
+
this.processMessage();
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
// do nothing
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Creates an empty model message. Useful when initializing LLM flow.
|
|
185
|
+
* @param session The session key.
|
|
186
|
+
* @returns An empty model message.
|
|
187
|
+
*/
|
|
188
|
+
static createEmpty(session) {
|
|
189
|
+
return new AiModelMessage({
|
|
190
|
+
session,
|
|
191
|
+
state: 'loading',
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
export const AiMessageFactory = {
|
|
196
|
+
fromSchema(schema) {
|
|
197
|
+
if (schema.role === 'model') {
|
|
198
|
+
return new AiModelMessage(schema);
|
|
199
|
+
}
|
|
200
|
+
return new AiUserMessage(schema);
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
//# sourceMappingURL=AiMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiMessage.js","sourceRoot":"","sources":["../../../src/models/AiMessage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AA0GnE;;;GAGG;AACH,MAAM,OAAgB,aAAa;IAGjC;;OAEG;IACH,MAAM,KAAK,IAAI;QACb,OAAO,aAAa,CAAA;IACtB,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,aAAa,CAAA;IACtB,CAAC;IAED,GAAG,CAAQ;IACX,IAAI,CAAW;IACf,SAAS,CAAQ;IACjB,SAAS,CAAQ;IACjB,OAAO,CAAQ;IACf,IAAI,CAAQ;IACZ,OAAO,CAAS;IAChB,WAAW,CAAY;IAEb,MAAM,CAAC,gBAAgB,CAAC,KAAmC;QACnE,MAAM,EAAE,GAAG,GAAG,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,CAAC,EAAE,GAAG,KAAK,CAAA;QAClF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;QAChE,CAAC;QACD,OAAO;YACL,GAAG;YACH,IAAI,EAAE,aAAa;YACnB,OAAO;YACP,IAAI;YACJ,SAAS;YACT,SAAS;SACV,CAAA;IACH,CAAC;IAED,YAAY,QAAoB,EAAE,EAAE,IAAe;QACjD,MAAM,IAAI,GAAG,aAAa,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;QAClD,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI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I,aAAa,CAAC,MAAsC,CAAC,CAAA;IAClE,CAAC;CACF,CAAA","sourcesContent":["import type { IDeletion } from './store/Deletion.js'\nimport { AiMessageKind } from './kinds.js'\nimport { nanoid } from '../nanoid.js'\nimport type { AiDomainDelta } from '../modeling/ai/types.js'\nimport { DataDomainDelta } from '../modeling/ai/DataDomainDelta.js'\n\nexport type AiMessageRole = 'user' | 'model'\nexport type AiMessageState = 'loading' | 'complete' | 'error' | 'terminated'\n\n/**\n * The base interface representing a single message in the domain manipulation chat history.\n * It tracks metadata like timestamps, the associated session, and the raw text content.\n * See `AiUserMessage` and `AiModelMessage` for specific role implementations.\n */\nexport interface AiMessageSchemaBase {\n readonly kind: typeof AiMessageKind\n /**\n * The datastore key of the message.\n */\n key: string\n /**\n * The role of the message.\n */\n role: AiMessageRole\n /**\n * The timestamp of when the message was created.\n */\n createdAt: number\n /**\n * The timestamp of when the message was last updated.\n */\n updatedAt: number\n /**\n * The datastore key of the session.\n */\n session: string\n /**\n * The text of the message.\n */\n text: string\n /**\n * Whether the message is deleted.\n */\n deleted?: boolean\n /**\n * The information about the delete information.\n * Always set when the `deleted` is true.\n */\n deletedInfo?: IDeletion\n}\n\n/**\n * The schema for a user message.\n */\nexport interface AiUserMessageSchema extends AiMessageSchemaBase {\n /**\n * The role of the message.\n */\n role: 'user'\n /**\n * The state of the user message.\n * Can only be `complete`.\n */\n state: 'complete'\n /**\n * The user utterance.\n * Note, the actual message sent to the LLM may be different from the utterance\n * as it has additional instructions and the domain context. However, we are not storing\n * the full message in the datastore, only the utterance.\n */\n text: string\n}\n\n/**\n * The schema for a model message.\n */\nexport interface AiModelMessageSchema extends AiMessageSchemaBase {\n /**\n * The role of the message.\n */\n role: 'model'\n /**\n * The full text of the message returned by the LLM.\n * It is most likely a structured message that needs to be parsed\n * to the corresponding message object.\n */\n text: string\n /**\n * The state of the message.\n * - loading: the message is being generated\n * - complete: the message is complete\n * - error: the message generation failed\n * - terminated: the message generation was terminated by the user\n */\n state: AiMessageState\n /**\n * Whether the message has been applied.\n */\n applied?: boolean\n /**\n * The thoughts of the message.\n */\n thoughts?: string\n}\n\n/**\n * A union type representing any valid chat message in the AI session history.\n */\nexport type AiMessageSchema = AiUserMessageSchema | AiModelMessageSchema\n\n/**\n * The base class for all AI messages.\n * It provides common functionality for all message types.\n */\nexport abstract class AiMessageBase<\n T extends AiMessageSchemaBase = AiMessageSchemaBase,\n> implements AiMessageSchemaBase {\n /**\n * The kind of the schema.\n */\n static get Kind(): typeof AiMessageKind {\n return AiMessageKind\n }\n\n /**\n * The kind of the schema.\n */\n get kind(): typeof AiMessageKind {\n return AiMessageKind\n }\n\n key: string\n role: T['role']\n createdAt: number\n updatedAt: number\n session: string\n text: string\n deleted: boolean\n deletedInfo?: IDeletion\n\n protected static createBaseSchema(input: Partial<AiMessageSchemaBase>): Omit<AiMessageSchemaBase, 'role'> {\n const { key = nanoid(), session, text = '', createdAt = 0, updatedAt = 0 } = input\n if (!session) {\n throw new Error('Session is required to create an AiMessage.')\n }\n return {\n key,\n kind: AiMessageKind,\n session,\n text,\n createdAt,\n updatedAt,\n }\n }\n\n constructor(input: Partial<T> = {}, role: T['role']) {\n const base = AiMessageBase.createBaseSchema(input)\n this.key = base.key\n this.role = role\n this.session = base.session\n this.text = base.text\n this.createdAt = base.createdAt\n this.updatedAt = base.updatedAt\n this.deleted = input.deleted || false\n this.deletedInfo = input.deletedInfo\n }\n\n toJSON(): T {\n const result = {\n kind: this.kind,\n key: this.key,\n role: this.role,\n session: this.session,\n text: this.text,\n createdAt: this.createdAt,\n updatedAt: this.updatedAt,\n }\n if (this.deleted && this.deletedInfo) {\n Object.assign(result, {\n deleted: this.deleted,\n deletedInfo: { ...this.deletedInfo },\n })\n }\n return result as unknown as T\n }\n}\n\nexport class AiUserMessage extends AiMessageBase<AiUserMessageSchema> implements AiUserMessageSchema {\n state: 'complete'\n\n static createSchema(input: Partial<AiUserMessageSchema>): AiUserMessageSchema {\n const base = AiMessageBase.createBaseSchema(input)\n return {\n ...base,\n role: 'user',\n state: 'complete',\n }\n }\n\n constructor(input: Partial<AiUserMessageSchema> = {}) {\n super(input, 'user')\n this.state = 'complete'\n }\n\n override toJSON(): AiUserMessageSchema {\n return {\n ...super.toJSON(),\n state: this.state,\n }\n }\n}\n\nexport class AiModelMessage extends AiMessageBase<AiModelMessageSchema> implements AiModelMessageSchema {\n state: AiMessageState\n applied?: boolean\n thoughts: string\n\n /**\n * The delta of the message, if any.\n */\n delta?: AiDomainDelta\n /**\n * The reasoning of the delta.\n * Format in markdown.\n */\n reasoning?: string\n\n static createSchema(input: Partial<AiModelMessageSchema>): AiModelMessageSchema {\n const base = AiMessageBase.createBaseSchema(input)\n return {\n ...base,\n role: 'model',\n state: input.state || 'loading',\n applied: input.applied,\n thoughts: input.thoughts || '',\n }\n }\n\n constructor(input: Partial<AiModelMessageSchema> = {}) {\n super(input, 'model')\n this.state = input.state || 'loading'\n this.applied = input.applied\n this.thoughts = input.thoughts || ''\n }\n\n override toJSON(): AiModelMessageSchema {\n const result: AiModelMessageSchema = {\n ...super.toJSON(),\n state: this.state,\n thoughts: this.thoughts,\n }\n if (this.applied !== undefined) {\n result.applied = this.applied\n }\n return result\n }\n\n /**\n * Adds a thought to the message. Useful when streaming.\n * @param thought The thought to add.\n */\n addThought(thought?: string): void {\n if (!thought) {\n return\n }\n this.thoughts += thought\n }\n\n /**\n * Adds a text chunk to the message. Useful when streaming.\n * @param text The text chunk to add.\n */\n addText(text?: string): void {\n if (!text) {\n return\n }\n this.text += text\n }\n\n /**\n * Processes the message.\n * If the message is not valid JSON, it will throw an error.\n * It sets the delta and reasoning fields, if found in the message.\n */\n processMessage(): void {\n if (!this.text) {\n return\n }\n const parsed = JSON.parse(this.text)\n if (parsed.delta) {\n this.delta = DataDomainDelta.normalize(parsed.delta)\n }\n if (parsed.reasoning) {\n this.reasoning = parsed.reasoning\n }\n }\n\n /**\n * Processes the message safely.\n * If the message is not valid JSON, it will be ignored.\n */\n processMessageSafe(): void {\n try {\n this.processMessage()\n } catch {\n // do nothing\n }\n }\n\n /**\n * Creates an empty model message. Useful when initializing LLM flow.\n * @param session The session key.\n * @returns An empty model message.\n */\n static createEmpty(session: string): AiModelMessage {\n return new AiModelMessage({\n session,\n state: 'loading',\n })\n }\n}\n\n/**\n * A union type representing any valid chat message in the AI session history.\n */\nexport type AiMessage = AiUserMessage | AiModelMessage\n\nexport const AiMessageFactory = {\n fromSchema(schema: Partial<AiMessageSchema>): AiMessage {\n if (schema.role === 'model') {\n return new AiModelMessage(schema as Partial<AiModelMessageSchema>)\n }\n return new AiUserMessage(schema as Partial<AiUserMessageSchema>)\n },\n}\n"]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { IDeletion } from './store/Deletion.js';
|
|
2
|
+
import { AiSessionKind } from './kinds.js';
|
|
3
|
+
import type { AiModelMessage } from './AiMessage.js';
|
|
4
|
+
export type AiSessionApp = 'domain' | 'api' | 'general';
|
|
5
|
+
export interface AiSessionSchema {
|
|
6
|
+
/**
|
|
7
|
+
* The kind of the schema
|
|
8
|
+
* This is set by the API and is used to identify the schema.
|
|
9
|
+
* @readonly
|
|
10
|
+
*/
|
|
11
|
+
readonly kind: typeof AiSessionKind;
|
|
12
|
+
/**
|
|
13
|
+
* The key of the session
|
|
14
|
+
* This is set by the API and is used to identify the session.
|
|
15
|
+
*/
|
|
16
|
+
key: string;
|
|
17
|
+
/**
|
|
18
|
+
* The application the session is for.
|
|
19
|
+
* Each app must query for its own sessions.
|
|
20
|
+
*/
|
|
21
|
+
app: AiSessionApp;
|
|
22
|
+
/**
|
|
23
|
+
* The title of the session.
|
|
24
|
+
*/
|
|
25
|
+
title: string;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the session is pinned.
|
|
28
|
+
*/
|
|
29
|
+
pinned: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the user has renamed the session.
|
|
32
|
+
*/
|
|
33
|
+
userRenamed: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The creation timestamp of the session.
|
|
36
|
+
*/
|
|
37
|
+
createdAt: number;
|
|
38
|
+
/**
|
|
39
|
+
* The update timestamp of the session.
|
|
40
|
+
*/
|
|
41
|
+
updatedAt: number;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the file object is deleted.
|
|
44
|
+
*/
|
|
45
|
+
deleted?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* The information about the delete information.
|
|
48
|
+
* Always set when the `delete` is true.
|
|
49
|
+
*/
|
|
50
|
+
deletedInfo?: IDeletion;
|
|
51
|
+
}
|
|
52
|
+
export declare class AiSession implements AiSessionSchema {
|
|
53
|
+
static get Kind(): typeof AiSessionKind;
|
|
54
|
+
get kind(): typeof AiSessionKind;
|
|
55
|
+
key: string;
|
|
56
|
+
app: AiSessionApp;
|
|
57
|
+
title: string;
|
|
58
|
+
pinned: boolean;
|
|
59
|
+
userRenamed: boolean;
|
|
60
|
+
createdAt: number;
|
|
61
|
+
updatedAt: number;
|
|
62
|
+
deleted: boolean;
|
|
63
|
+
deletedInfo?: IDeletion;
|
|
64
|
+
/**
|
|
65
|
+
* Checks if the given value is a valid AiSessionApp.
|
|
66
|
+
*/
|
|
67
|
+
static isSessionApp(app: unknown): app is AiSessionApp;
|
|
68
|
+
static createSchema(input: Partial<AiSessionSchema>): AiSessionSchema;
|
|
69
|
+
constructor(input?: Partial<AiSessionSchema>);
|
|
70
|
+
toJSON(): AiSessionSchema;
|
|
71
|
+
/**
|
|
72
|
+
* Processes the agent response and extracts the session title if available.
|
|
73
|
+
* It looks for a JSON object in the response text and extracts the `sessionTitle`.
|
|
74
|
+
*
|
|
75
|
+
* @param message The agent response.
|
|
76
|
+
* @returns {string | null} The session title if found, otherwise null.
|
|
77
|
+
*/
|
|
78
|
+
static extractSessionTitle(message: AiModelMessage): string | null;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=AiSession.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiSession.d.ts","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G,IAAI,YAAY;IAItD,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe;gBAyBzD,KAAK,GAAE,OAAO,CAAC,eAAe,CAAM;IAahD,MAAM,IAAI,eAAe;IAkBzB;;;;;;OAMG;IACH,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI;CAenE"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { AiSessionKind } from './kinds.js';
|
|
2
|
+
import { nanoid } from '../nanoid.js';
|
|
3
|
+
export class AiSession {
|
|
4
|
+
static get Kind() {
|
|
5
|
+
return AiSessionKind;
|
|
6
|
+
}
|
|
7
|
+
get kind() {
|
|
8
|
+
return AiSessionKind;
|
|
9
|
+
}
|
|
10
|
+
key;
|
|
11
|
+
app;
|
|
12
|
+
title;
|
|
13
|
+
pinned;
|
|
14
|
+
userRenamed;
|
|
15
|
+
createdAt;
|
|
16
|
+
updatedAt;
|
|
17
|
+
deleted;
|
|
18
|
+
deletedInfo;
|
|
19
|
+
/**
|
|
20
|
+
* Checks if the given value is a valid AiSessionApp.
|
|
21
|
+
*/
|
|
22
|
+
static isSessionApp(app) {
|
|
23
|
+
return ['domain', 'api', 'general'].includes(app);
|
|
24
|
+
}
|
|
25
|
+
static createSchema(input) {
|
|
26
|
+
const { key = nanoid(), app, title = '', createdAt = 0, updatedAt = 0, pinned = false, userRenamed = false } = input;
|
|
27
|
+
if (!app) {
|
|
28
|
+
throw new Error('App is required to create an AiSession schema.');
|
|
29
|
+
}
|
|
30
|
+
if (!AiSession.isSessionApp(app)) {
|
|
31
|
+
throw new Error(`Invalid app: ${app}`);
|
|
32
|
+
}
|
|
33
|
+
const result = {
|
|
34
|
+
key,
|
|
35
|
+
kind: AiSessionKind,
|
|
36
|
+
app,
|
|
37
|
+
title,
|
|
38
|
+
pinned,
|
|
39
|
+
userRenamed,
|
|
40
|
+
createdAt,
|
|
41
|
+
updatedAt,
|
|
42
|
+
};
|
|
43
|
+
if (input.deleted) {
|
|
44
|
+
result.deleted = input.deleted;
|
|
45
|
+
result.deletedInfo = input.deletedInfo;
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
constructor(input = {}) {
|
|
50
|
+
const init = AiSession.createSchema(input);
|
|
51
|
+
this.key = init.key;
|
|
52
|
+
this.app = init.app;
|
|
53
|
+
this.title = init.title;
|
|
54
|
+
this.pinned = init.pinned;
|
|
55
|
+
this.userRenamed = init.userRenamed;
|
|
56
|
+
this.createdAt = init.createdAt;
|
|
57
|
+
this.updatedAt = init.updatedAt;
|
|
58
|
+
this.deleted = init.deleted || false;
|
|
59
|
+
this.deletedInfo = init.deletedInfo;
|
|
60
|
+
}
|
|
61
|
+
toJSON() {
|
|
62
|
+
const result = {
|
|
63
|
+
kind: this.kind,
|
|
64
|
+
key: this.key,
|
|
65
|
+
app: this.app,
|
|
66
|
+
title: this.title,
|
|
67
|
+
pinned: this.pinned,
|
|
68
|
+
userRenamed: this.userRenamed,
|
|
69
|
+
createdAt: this.createdAt,
|
|
70
|
+
updatedAt: this.updatedAt,
|
|
71
|
+
};
|
|
72
|
+
if (this.deleted && this.deletedInfo) {
|
|
73
|
+
result.deleted = this.deleted;
|
|
74
|
+
result.deletedInfo = { ...this.deletedInfo };
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Processes the agent response and extracts the session title if available.
|
|
80
|
+
* It looks for a JSON object in the response text and extracts the `sessionTitle`.
|
|
81
|
+
*
|
|
82
|
+
* @param message The agent response.
|
|
83
|
+
* @returns {string | null} The session title if found, otherwise null.
|
|
84
|
+
*/
|
|
85
|
+
static extractSessionTitle(message) {
|
|
86
|
+
const txt = message.text;
|
|
87
|
+
if (!txt) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const json = JSON.parse(txt);
|
|
92
|
+
if (json.sessionTitle) {
|
|
93
|
+
return String(json.sessionTitle);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
// ignore
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=AiSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiSession.js","sourceRoot":"","sources":["../../../src/models/AiSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAqDrC,MAAM,OAAO,SAAS;IACpB,MAAM,KAAK,IAAI;QACb,OAAO,aAAa,CAAA;IACtB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,aAAa,CAAA;IACtB,CAAC;IAED,GAAG,CAAQ;IACX,GAAG,CAAc;IACjB,KAAK,CAAQ;IACb,MAAM,CAAS;IACf,WAAW,CAAS;IACpB,SAAS,CAAQ;IACjB,SAAS,CAAQ;IACjB,OAAO,CAAS;IAChB,WAAW,CAAY;IAEvB;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,GAAY;QAC9B,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,GAAa,CAAC,CAAA;IAC7D,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,KAA+B;QACjD,MAAM,EAAE,GAAG,GAAG,MAAM,EAAE,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,EAAE,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,EAAE,WAAW,GAAG,KAAK,EAAE,GAAG,KAAK,CAAA;QACpH,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAA;QACnE,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAA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AAI,CAAC,MAAM;YACnB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAA;QACD,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;YAC7B,MAAM,CAAC,WAAW,GAAG,EAAE,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;QAC9C,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,mBAAmB,CAAC,OAAuB;QAChD,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAA;QACxB,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,IAAI,CAAA;QACb,CAAC;QACD,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAC5B,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACtB,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;YAClC,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF","sourcesContent":["import type { IDeletion } from './store/Deletion.js'\nimport { AiSessionKind } from './kinds.js'\nimport { nanoid } from '../nanoid.js'\nimport type { AiModelMessage } from './AiMessage.js'\n\nexport type AiSessionApp = 'domain' | 'api' | 'general'\n\nexport interface AiSessionSchema {\n /**\n * The kind of the schema\n * This is set by the API and is used to identify the schema.\n * @readonly\n */\n readonly kind: typeof AiSessionKind\n /**\n * The key of the session\n * This is set by the API and is used to identify the session.\n */\n key: string\n /**\n * The application the session is for.\n * Each app must query for its own sessions.\n */\n app: AiSessionApp\n /**\n * The title of the session.\n */\n title: string\n /**\n * Whether the session is pinned.\n */\n pinned: boolean\n /**\n * Whether the user has renamed the session.\n */\n userRenamed: boolean\n /**\n * The creation timestamp of the session.\n */\n createdAt: number\n /**\n * The update timestamp of the session.\n */\n updatedAt: number\n /**\n * Whether the file object is deleted.\n */\n deleted?: boolean\n /**\n * The information about the delete information.\n * Always set when the `delete` is true.\n */\n deletedInfo?: IDeletion\n}\n\nexport class AiSession implements AiSessionSchema {\n static get Kind(): typeof AiSessionKind {\n return AiSessionKind\n }\n\n get kind(): typeof AiSessionKind {\n return AiSessionKind\n }\n\n key: string\n app: AiSessionApp\n title: string\n pinned: boolean\n userRenamed: boolean\n createdAt: number\n updatedAt: number\n deleted: boolean\n deletedInfo?: IDeletion\n\n /**\n * Checks if the given value is a valid AiSessionApp.\n */\n static isSessionApp(app: unknown): app is AiSessionApp {\n return ['domain', 'api', 'general'].includes(app as string)\n }\n\n static createSchema(input: Partial<AiSessionSchema>): AiSessionSchema {\n const { key = nanoid(), app, title = '', createdAt = 0, updatedAt = 0, pinned = false, userRenamed = false } = input\n if (!app) {\n throw new Error('App is required to create an AiSession schema.')\n }\n if (!AiSession.isSessionApp(app)) {\n throw new Error(`Invalid app: ${app}`)\n }\n const result: AiSessionSchema = {\n key,\n kind: AiSessionKind,\n app,\n title,\n pinned,\n userRenamed,\n createdAt,\n updatedAt,\n }\n if (input.deleted) {\n result.deleted = input.deleted\n result.deletedInfo = input.deletedInfo\n }\n return result\n }\n\n constructor(input: Partial<AiSessionSchema> = {}) {\n const init = AiSession.createSchema(input)\n this.key = init.key\n this.app = init.app\n this.title = init.title\n this.pinned = init.pinned\n this.userRenamed = init.userRenamed\n this.createdAt = init.createdAt\n this.updatedAt = init.updatedAt\n this.deleted = init.deleted || false\n this.deletedInfo = init.deletedInfo\n }\n\n toJSON(): AiSessionSchema {\n const result: AiSessionSchema = {\n kind: this.kind,\n key: this.key,\n app: this.app,\n title: this.title,\n pinned: this.pinned,\n userRenamed: this.userRenamed,\n createdAt: this.createdAt,\n updatedAt: this.updatedAt,\n }\n if (this.deleted && this.deletedInfo) {\n result.deleted = this.deleted\n result.deletedInfo = { ...this.deletedInfo }\n }\n return result\n }\n\n /**\n * Processes the agent response and extracts the session title if available.\n * It looks for a JSON object in the response text and extracts the `sessionTitle`.\n *\n * @param message The agent response.\n * @returns {string | null} The session title if found, otherwise null.\n */\n static extractSessionTitle(message: AiModelMessage): string | null {\n const txt = message.text\n if (!txt) {\n return null\n }\n try {\n const json = JSON.parse(txt)\n if (json.sessionTitle) {\n return String(json.sessionTitle)\n }\n } catch {\n // ignore\n }\n return null\n }\n}\n"]}
|
|
@@ -24,4 +24,6 @@ export declare const ApiModelKind = "Core#ApiModel";
|
|
|
24
24
|
export declare const ExposedEntityKind = "Core#ExposedEntity";
|
|
25
25
|
export declare const ApiFileKind = "Core#ApiFile";
|
|
26
26
|
export declare const GroupKind = "Core#Group";
|
|
27
|
+
export declare const AiSessionKind = "Core#AiSession";
|
|
28
|
+
export declare const AiMessageKind = "Core#AiMessage";
|
|
27
29
|
//# sourceMappingURL=kinds.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kinds.d.ts","sourceRoot":"","sources":["../../../src/models/kinds.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,uBAAuB,CAAA;AACrD,eAAO,MAAM,YAAY,sBAAsB,CAAA;AAC/C,eAAO,MAAM,gBAAgB,sBAAsB,CAAA;AACnD,eAAO,MAAM,mBAAmB,yBAAyB,CAAA;AACzD,eAAO,MAAM,UAAU,gBAAgB,CAAA;AACvC,eAAO,MAAM,WAAW,iBAAiB,CAAA;AACzC,eAAO,MAAM,SAAS,eAAe,CAAA;AACrC,eAAO,MAAM,YAAY,kBAAkB,CAAA;AAC3C,eAAO,MAAM,YAAY,kBAAkB,CAAA;AAC3C,eAAO,MAAM,wBAAwB,8BAA8B,CAAA;AACnE,eAAO,MAAM,QAAQ,cAAc,CAAA;AACnC,eAAO,MAAM,cAAc,oBAAoB,CAAA;AAC/C,eAAO,MAAM,c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AAM,gBAAgB,kBAAkB,CAAA;AAC/C,eAAO,MAAM,qBAAqB,uBAAuB,CAAA;AACzD,eAAO,MAAM,kBAAkB,oBAAoB,CAAA;AACnD,eAAO,MAAM,eAAe,qBAAqB,CAAA;AACjD,eAAO,MAAM,sBAAsB,4BAA4B,CAAA;AAC/D,eAAO,MAAM,gBAAgB,sBAAsB,CAAA;AACnD,eAAO,MAAM,cAAc,oBAAoB,CAAA;AAC/C,eAAO,MAAM,YAAY,kBAAkB,CAAA;AAC3C,eAAO,MAAM,iBAAiB,uBAAuB,CAAA;AACrD,eAAO,MAAM,WAAW,iBAAiB,CAAA;AACzC,eAAO,MAAM,SAAS,eAAe,CAAA;AACrC,eAAO,MAAM,aAAa,mBAAmB,CAAA;AAC7C,eAAO,MAAM,aAAa,mBAAmB,CAAA"}
|
|
@@ -24,4 +24,6 @@ export const ApiModelKind = 'Core#ApiModel';
|
|
|
24
24
|
export const ExposedEntityKind = 'Core#ExposedEntity';
|
|
25
25
|
export const ApiFileKind = 'Core#ApiFile';
|
|
26
26
|
export const GroupKind = 'Core#Group';
|
|
27
|
+
export const AiSessionKind = 'Core#AiSession';
|
|
28
|
+
export const AiMessageKind = 'Core#AiMessage';
|
|
27
29
|
//# sourceMappingURL=kinds.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kinds.js","sourceRoot":"","sources":["../../../src/models/kinds.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAA;AACrD,MAAM,CAAC,MAAM,YAAY,GAAG,mBAAmB,CAAA;AAC/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,mBAAmB,CAAA;AACnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,sBAAsB,CAAA;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAA;AACvC,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAA;AACzC,MAAM,CAAC,MAAM,SAAS,GAAG,YAAY,CAAA;AACrC,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAA;AAC3C,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAA;AAC3C,MAAM,CAAC,MAAM,wBAAwB,GAAG,2BAA2B,CAAA;AACnE,MAAM,CAAC,MAAM,QAAQ,GAAG,WAAW,CAAA;AACnC,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAA;AAC/C,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAA;AAC3C,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAA;AACrD,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAA;AAC7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAA;AAC/C,MAAM,CAAC,MAAM,qBAAqB,GAAG,oBAAoB,CAAA;AACzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAA;AACnD,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAA;AACjD,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAA;AAC/D,MAAM,CAAC,MAAM,gBAAgB,GAAG,mBAAmB,CAAA;AACnD,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAA;AAC/C,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAA;AAC3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAA;AACrD,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAA;AACzC,MAAM,CAAC,MAAM,SAAS,GAAG,YAAY,CAAA","sourcesContent":["export const ProjectFolderKind = 'Core#ProjectFolder'\nexport const ResponseKind = 'Core#HttpResponse'\nexport const HttpResponseKind = 'Core#HttpResponse'\nexport const CertificateFileKind = 'Core#CertificateFile'\nexport const FolderKind = 'Core#Folder'\nexport const ProjectKind = 'Core#Project'\nexport const ThingKind = 'Core#Thing'\nexport const DeletionKind = 'Core#Deletion'\nexport const RevisionKind = 'Core#Revision'\nexport const UnresolvedDependencyKind = 'Core#UnresolvedDependency'\nexport const UserKind = 'Core#User'\nexport const DomainFileKind = 'Data#DomainFile'\nexport const DataDomainKind = 'Data#Domain'\nexport const DomainNamespaceKind = 'Domain#Namespace'\nexport const DomainModelKind = 'Domain#Model'\nexport const DomainEntityKind = 'Domain#Entity'\nexport const DomainAssociationKind = 'Domain#Association'\nexport const DomainPropertyKind = 'Domain#Property'\nexport const DataCatalogKind = 'Core#DataCatalog'\nexport const DataCatalogVersionKind = 'Core#DataCatalogVersion'\nexport const OrganizationKind = 'Core#Organization'\nexport const InvitationKind = 'Core#Invitation'\nexport const ApiModelKind = 'Core#ApiModel'\nexport const ExposedEntityKind = 'Core#ExposedEntity'\nexport const ApiFileKind = 'Core#ApiFile'\nexport const GroupKind = 'Core#Group'\n"]}
|
|
1
|
+
{"version":3,"file":"kinds.js","sourceRoot":"","sources":["../../../src/models/kinds.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAA;AACrD,MAAM,CAAC,MAAM,YAAY,GAAG,mBAAmB,CAAA;AAC/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,mBAAmB,CAAA;AACnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,sBAAsB,CAAA;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAA;AACvC,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAA;AACzC,MAAM,CAAC,MAAM,SAAS,GAAG,YAAY,CAAA;AACrC,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAA;AAC3C,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAA;AAC3C,MAAM,CAAC,MAAM,wBAAwB,GAAG,2BAA2B,CAAA;AACnE,MAAM,CAAC,MAAM,QAAQ,GAAG,WAAW,CAAA;AACnC,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAA;AAC/C,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAA;AAC3C,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAA;AACrD,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAA;AAC7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAA;AAC/C,MAAM,CAAC,MAAM,qBAAqB,GAAG,oBAAoB,CAAA;AACzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAA;AACnD,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAA;AACjD,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAA;AAC/D,MAAM,CAAC,MAAM,gBAAgB,GAAG,mBAAmB,CAAA;AACnD,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAA;AAC/C,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAA;AAC3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAA;AACrD,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAA;AACzC,MAAM,CAAC,MAAM,SAAS,GAAG,YAAY,CAAA;AACrC,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAA;AAC7C,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAA","sourcesContent":["export const ProjectFolderKind = 'Core#ProjectFolder'\nexport const ResponseKind = 'Core#HttpResponse'\nexport const HttpResponseKind = 'Core#HttpResponse'\nexport const CertificateFileKind = 'Core#CertificateFile'\nexport const FolderKind = 'Core#Folder'\nexport const ProjectKind = 'Core#Project'\nexport const ThingKind = 'Core#Thing'\nexport const DeletionKind = 'Core#Deletion'\nexport const RevisionKind = 'Core#Revision'\nexport const UnresolvedDependencyKind = 'Core#UnresolvedDependency'\nexport const UserKind = 'Core#User'\nexport const DomainFileKind = 'Data#DomainFile'\nexport const DataDomainKind = 'Data#Domain'\nexport const DomainNamespaceKind = 'Domain#Namespace'\nexport const DomainModelKind = 'Domain#Model'\nexport const DomainEntityKind = 'Domain#Entity'\nexport const DomainAssociationKind = 'Domain#Association'\nexport const DomainPropertyKind = 'Domain#Property'\nexport const DataCatalogKind = 'Core#DataCatalog'\nexport const DataCatalogVersionKind = 'Core#DataCatalogVersion'\nexport const OrganizationKind = 'Core#Organization'\nexport const InvitationKind = 'Core#Invitation'\nexport const ApiModelKind = 'Core#ApiModel'\nexport const ExposedEntityKind = 'Core#ExposedEntity'\nexport const ApiFileKind = 'Core#ApiFile'\nexport const GroupKind = 'Core#Group'\nexport const AiSessionKind = 'Core#AiSession'\nexport const AiMessageKind = 'Core#AiMessage'\n"]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { ContextListOptions, ContextListResult } from '../events/BaseEvents.js';
|
|
2
|
+
import type { AiStreamEvent } from '../modeling/ai/types.js';
|
|
3
|
+
import type { AiMessageSchema } from '../models/AiMessage.js';
|
|
4
|
+
import type { AiSessionApp, AiSessionSchema } from '../models/AiSession.js';
|
|
5
|
+
import { SdkBase, type SdkOptions } from './SdkBase.js';
|
|
6
|
+
export declare class AiSdk extends SdkBase {
|
|
7
|
+
/**
|
|
8
|
+
* Modifies the domain of a file.
|
|
9
|
+
* @param oid The organization id.
|
|
10
|
+
* @param fid The domain file id.
|
|
11
|
+
* @param goal The goal to modify the domain for.
|
|
12
|
+
* @param sid The conversation session id, if any. When provided it will be used to continue the conversation.
|
|
13
|
+
* @param request The request options.
|
|
14
|
+
*/
|
|
15
|
+
modifyDomain(oid: string, fid: string, goal: string, sid?: string, request?: SdkOptions): AsyncGenerator<AiStreamEvent>;
|
|
16
|
+
sessions: {
|
|
17
|
+
/**
|
|
18
|
+
* Lists the AI sessions for the given organization and application.
|
|
19
|
+
* @param oid The organization id.
|
|
20
|
+
* @param app The application id.
|
|
21
|
+
* @param options The list options.
|
|
22
|
+
* @param request The request options.
|
|
23
|
+
* @returns The list of AI sessions.
|
|
24
|
+
*/
|
|
25
|
+
list: (oid: string, app: AiSessionApp, options?: ContextListOptions, request?: SdkOptions) => Promise<ContextListResult<AiSessionSchema>>;
|
|
26
|
+
/**
|
|
27
|
+
* Reads the AI session for the given organization, application and session id.
|
|
28
|
+
* @param oid The organization id.
|
|
29
|
+
* @param app The application id.
|
|
30
|
+
* @param sid The session id.
|
|
31
|
+
* @param request The request options.
|
|
32
|
+
* @returns The AI session.
|
|
33
|
+
*/
|
|
34
|
+
read: (oid: string, app: AiSessionApp, sid: string, request?: SdkOptions) => Promise<AiSessionSchema>;
|
|
35
|
+
/**
|
|
36
|
+
* Creates the AI session for the given organization, application and session id.
|
|
37
|
+
* @param oid The organization id.
|
|
38
|
+
* @param app The application id.
|
|
39
|
+
* @param session The AI session to create.
|
|
40
|
+
* @param request The request options.
|
|
41
|
+
* @returns The created AI session.
|
|
42
|
+
*/
|
|
43
|
+
create: (oid: string, app: AiSessionApp, session: Partial<AiSessionSchema>, request?: SdkOptions) => Promise<AiSessionSchema>;
|
|
44
|
+
/**
|
|
45
|
+
* Deletes the AI session for the given organization, application and session id.
|
|
46
|
+
* The API performs a soft delete of the session.
|
|
47
|
+
* @param oid The organization id.
|
|
48
|
+
* @param app The application id.
|
|
49
|
+
* @param sid The session id.
|
|
50
|
+
* @param request The request options.
|
|
51
|
+
*/
|
|
52
|
+
delete: (oid: string, app: AiSessionApp, sid: string, request?: SdkOptions) => Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Updates the AI session for the given organization, application and session id.
|
|
55
|
+
* @param oid The organization id.
|
|
56
|
+
* @param app The application id.
|
|
57
|
+
* @param session The AI session to update.
|
|
58
|
+
* @param request The request options.
|
|
59
|
+
* @returns The updated AI session.
|
|
60
|
+
*/
|
|
61
|
+
update: (oid: string, app: AiSessionApp, session: AiSessionSchema, request?: SdkOptions) => Promise<AiSessionSchema>;
|
|
62
|
+
};
|
|
63
|
+
messages: {
|
|
64
|
+
/**
|
|
65
|
+
* Lists the AI messages for the given organization and session id.
|
|
66
|
+
* @param oid The organization id.
|
|
67
|
+
* @param sid The session id.
|
|
68
|
+
* @param options The list options.
|
|
69
|
+
* @param request The request options.
|
|
70
|
+
* @returns The list of AI messages.
|
|
71
|
+
*/
|
|
72
|
+
list: (oid: string, sid: string, options?: ContextListOptions, request?: SdkOptions) => Promise<ContextListResult<AiMessageSchema>>;
|
|
73
|
+
/**
|
|
74
|
+
* Deletes the AI message for the given organization, session and message id.
|
|
75
|
+
* The API performs a soft delete of the message.
|
|
76
|
+
* @param oid The organization id.
|
|
77
|
+
* @param sid The session id.
|
|
78
|
+
* @param mid The message id.
|
|
79
|
+
* @param request The request options.
|
|
80
|
+
*/
|
|
81
|
+
delete: (oid: string, sid: string, mid: string, request?: SdkOptions) => Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Updates the AI message for the given organization, session and message id.
|
|
84
|
+
* @param oid The organization id.
|
|
85
|
+
* @param sid The session id.
|
|
86
|
+
* @param message The AI message to update.
|
|
87
|
+
* @param request The request options.
|
|
88
|
+
* @returns The updated AI message.
|
|
89
|
+
*/
|
|
90
|
+
update: (oid: string, sid: string, message: AiMessageSchema, request?: SdkOptions) => Promise<AiMessageSchema>;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=AiSdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiSdk.d.ts","sourceRoot":"","sources":["../../../src/sdk/AiSdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAa,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAG3E,OAAO,EAKL,OAAO,EACP,KAAK,UAAU,EAChB,MAAM,cAAc,CAAA;AAErB,qBAAa,KAAM,SAAQ,OAAO;IAChC;;;;;;;OAOG;IACI,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