@promptbook/cli 0.103.0-53 → 0.103.0-55
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/apps/agents-server/config.ts +0 -2
- package/apps/agents-server/src/app/admin/api-tokens/ApiTokensClient.tsx +186 -0
- package/apps/agents-server/src/app/admin/api-tokens/page.tsx +13 -0
- package/apps/agents-server/src/app/admin/chat-feedback/ChatFeedbackClient.tsx +79 -6
- package/apps/agents-server/src/app/admin/chat-history/ChatHistoryClient.tsx +171 -69
- package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +10 -2
- package/apps/agents-server/src/app/agents/[agentName]/api/mcp/route.ts +203 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/route.ts +3 -1
- package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/systemMessage/route.ts +3 -1
- package/apps/agents-server/src/app/agents/[agentName]/api/openai/chat/completions/route.ts +10 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/openrouter/chat/completions/route.ts +10 -0
- package/apps/agents-server/src/app/agents/[agentName]/links/page.tsx +218 -0
- package/apps/agents-server/src/app/agents/[agentName]/page.tsx +24 -3
- package/apps/agents-server/src/app/api/api-tokens/route.ts +76 -0
- package/apps/agents-server/src/app/api/auth/change-password/route.ts +75 -0
- package/apps/agents-server/src/app/api/chat-feedback/export/route.ts +55 -0
- package/apps/agents-server/src/app/api/chat-history/export/route.ts +55 -0
- package/apps/agents-server/src/app/docs/[docId]/page.tsx +1 -0
- package/apps/agents-server/src/app/docs/page.tsx +1 -0
- package/apps/agents-server/src/components/ChangePasswordDialog/ChangePasswordDialog.tsx +41 -0
- package/apps/agents-server/src/components/ChangePasswordForm/ChangePasswordForm.tsx +159 -0
- package/apps/agents-server/src/components/Header/Header.tsx +94 -33
- package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +2 -1
- package/apps/agents-server/src/database/migrations/2025-12-0010-llm-cache.sql +12 -0
- package/apps/agents-server/src/database/migrations/2025-12-0060-api-tokens.sql +13 -0
- package/apps/agents-server/src/database/schema.ts +51 -0
- package/apps/agents-server/src/middleware.ts +50 -2
- package/apps/agents-server/src/tools/$provideCdnForServer.ts +3 -7
- package/apps/agents-server/src/tools/$provideExecutionToolsForServer.ts +10 -1
- package/apps/agents-server/src/utils/cache/SupabaseCacheStorage.ts +55 -0
- package/apps/agents-server/src/utils/cdn/classes/VercelBlobStorage.ts +63 -0
- package/apps/agents-server/src/utils/convertToCsv.ts +31 -0
- package/apps/agents-server/src/utils/handleChatCompletion.ts +183 -0
- package/apps/agents-server/src/utils/resolveInheritedAgentSource.ts +93 -0
- package/esm/index.es.js +846 -131
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +8 -6
- package/esm/typings/src/_packages/types.index.d.ts +1 -1
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +4 -0
- package/esm/typings/src/commitments/ACTION/ACTION.d.ts +4 -0
- package/esm/typings/src/commitments/CLOSED/CLOSED.d.ts +35 -0
- package/esm/typings/src/commitments/COMPONENT/COMPONENT.d.ts +28 -0
- package/esm/typings/src/commitments/DELETE/DELETE.d.ts +4 -0
- package/esm/typings/src/commitments/FORMAT/FORMAT.d.ts +4 -0
- package/esm/typings/src/commitments/FROM/FROM.d.ts +34 -0
- package/esm/typings/src/commitments/GOAL/GOAL.d.ts +4 -0
- package/esm/typings/src/commitments/IMPORTANT/IMPORTANT.d.ts +26 -0
- package/esm/typings/src/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +4 -0
- package/esm/typings/src/commitments/LANGUAGE/LANGUAGE.d.ts +35 -0
- package/esm/typings/src/commitments/MEMORY/MEMORY.d.ts +4 -0
- package/esm/typings/src/commitments/MESSAGE/AgentMessageCommitmentDefinition.d.ts +4 -0
- package/esm/typings/src/commitments/MESSAGE/InitialMessageCommitmentDefinition.d.ts +4 -0
- package/esm/typings/src/commitments/MESSAGE/MESSAGE.d.ts +4 -0
- package/esm/typings/src/commitments/MESSAGE/UserMessageCommitmentDefinition.d.ts +4 -0
- package/esm/typings/src/commitments/META/META.d.ts +4 -0
- package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +4 -0
- package/esm/typings/src/commitments/META_IMAGE/META_IMAGE.d.ts +4 -0
- package/esm/typings/src/commitments/META_LINK/META_LINK.d.ts +4 -0
- package/esm/typings/src/commitments/MODEL/MODEL.d.ts +4 -0
- package/esm/typings/src/commitments/NOTE/NOTE.d.ts +4 -0
- package/esm/typings/src/commitments/OPEN/OPEN.d.ts +35 -0
- package/esm/typings/src/commitments/PERSONA/PERSONA.d.ts +4 -0
- package/esm/typings/src/commitments/RULE/RULE.d.ts +4 -0
- package/esm/typings/src/commitments/SAMPLE/SAMPLE.d.ts +4 -0
- package/esm/typings/src/commitments/SCENARIO/SCENARIO.d.ts +4 -0
- package/esm/typings/src/commitments/STYLE/STYLE.d.ts +4 -0
- package/esm/typings/src/commitments/_base/BaseCommitmentDefinition.d.ts +5 -0
- package/esm/typings/src/commitments/_base/CommitmentDefinition.d.ts +5 -0
- package/esm/typings/src/commitments/_base/NotYetImplementedCommitmentDefinition.d.ts +4 -0
- package/esm/typings/src/commitments/index.d.ts +1 -82
- package/esm/typings/src/commitments/registry.d.ts +68 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +3 -3
- package/umd/index.umd.js +846 -131
- package/umd/index.umd.js.map +1 -1
- package/apps/agents-server/src/utils/cdn/classes/DigitalOceanSpaces.ts +0 -119
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { GetObjectCommand, PutObjectCommand, PutObjectCommandInput, S3Client } from '@aws-sdk/client-s3';
|
|
2
|
-
import { NotYetImplementedError } from '@promptbook-local/core';
|
|
3
|
-
import { gzip, ungzip } from 'node-gzip';
|
|
4
|
-
import { TODO_USE } from '../../../../../../src/utils/organization/TODO_USE';
|
|
5
|
-
import { validateMimeType } from '../../validators/validateMimeType';
|
|
6
|
-
import type { IFile, IIFilesStorageWithCdn } from '../interfaces/IFilesStorage';
|
|
7
|
-
|
|
8
|
-
type IDigitalOceanSpacesConfig = {
|
|
9
|
-
readonly bucket: string;
|
|
10
|
-
readonly pathPrefix: string;
|
|
11
|
-
readonly endpoint: string;
|
|
12
|
-
readonly accessKeyId: string;
|
|
13
|
-
readonly secretAccessKey: string;
|
|
14
|
-
readonly cdnPublicUrl: URL;
|
|
15
|
-
readonly gzip: boolean;
|
|
16
|
-
|
|
17
|
-
// TODO: [⛳️] Probbably prefix should be in this config not on the consumer side
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export class DigitalOceanSpaces implements IIFilesStorageWithCdn {
|
|
21
|
-
public get cdnPublicUrl() {
|
|
22
|
-
return this.config.cdnPublicUrl;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private s3: S3Client;
|
|
26
|
-
|
|
27
|
-
public constructor(private readonly config: IDigitalOceanSpacesConfig) {
|
|
28
|
-
this.s3 = new S3Client({
|
|
29
|
-
region: 'auto',
|
|
30
|
-
endpoint: 'https://' + config.endpoint,
|
|
31
|
-
credentials: {
|
|
32
|
-
accessKeyId: config.accessKeyId,
|
|
33
|
-
secretAccessKey: config.secretAccessKey,
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public getItemUrl(key: string): URL {
|
|
39
|
-
return new URL(this.config.pathPrefix + '/' + key, this.cdnPublicUrl);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public async getItem(key: string): Promise<IFile | null> {
|
|
43
|
-
const parameters = {
|
|
44
|
-
Bucket: this.config.bucket,
|
|
45
|
-
Key: this.config.pathPrefix + '/' + key,
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
const { Body, ContentType, ContentEncoding } = await this.s3.send(new GetObjectCommand(parameters));
|
|
50
|
-
|
|
51
|
-
// const blob = new Blob([await Body?.transformToByteArray()!]);
|
|
52
|
-
|
|
53
|
-
if (ContentEncoding === 'gzip') {
|
|
54
|
-
return {
|
|
55
|
-
type: validateMimeType(ContentType),
|
|
56
|
-
data: await ungzip(await Body!.transformToByteArray()),
|
|
57
|
-
};
|
|
58
|
-
} else {
|
|
59
|
-
return {
|
|
60
|
-
type: validateMimeType(ContentType),
|
|
61
|
-
data: (await Body!.transformToByteArray()) as Buffer,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
} catch (error) {
|
|
65
|
-
if (error instanceof Error && error.name.match(/^NoSuchKey/)) {
|
|
66
|
-
return null;
|
|
67
|
-
} else {
|
|
68
|
-
throw error;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
public async removeItem(key: string): Promise<void> {
|
|
74
|
-
TODO_USE(key);
|
|
75
|
-
throw new NotYetImplementedError(`DigitalOceanSpaces.removeItem is not implemented yet`);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public async setItem(key: string, file: IFile): Promise<void> {
|
|
79
|
-
// TODO: Put putObjectRequestAdditional into processedFile
|
|
80
|
-
const putObjectRequestAdditional: Partial<PutObjectCommandInput> = {};
|
|
81
|
-
|
|
82
|
-
let processedFile: IFile;
|
|
83
|
-
if (this.config.gzip) {
|
|
84
|
-
const gzipped = await gzip(file.data);
|
|
85
|
-
const sizePercentageAfterCompression = gzipped.byteLength / file.data.byteLength;
|
|
86
|
-
if (sizePercentageAfterCompression < 0.7) {
|
|
87
|
-
// consolex.log(`Gzipping ${key} (${Math.floor(sizePercentageAfterCompression * 100)}%)`);
|
|
88
|
-
processedFile = { ...file, data: gzipped };
|
|
89
|
-
putObjectRequestAdditional.ContentEncoding = 'gzip';
|
|
90
|
-
} else {
|
|
91
|
-
processedFile = file;
|
|
92
|
-
// consolex.log(`NOT Gzipping ${key} (${Math.floor(sizePercentageAfterCompression * 100)}%)`);
|
|
93
|
-
}
|
|
94
|
-
} else {
|
|
95
|
-
processedFile = file;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const uploadResult = await this.s3.send(
|
|
99
|
-
new PutObjectCommand({
|
|
100
|
-
Bucket: this.config.bucket,
|
|
101
|
-
Key: this.config.pathPrefix + '/' + key,
|
|
102
|
-
ContentType: processedFile.type,
|
|
103
|
-
...putObjectRequestAdditional,
|
|
104
|
-
Body: processedFile.data,
|
|
105
|
-
// TODO: Public read access / just private to extending class
|
|
106
|
-
ACL: 'public-read',
|
|
107
|
-
}),
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
if (!uploadResult.ETag) {
|
|
111
|
-
throw new Error(`Upload result does not contain ETag`);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* TODO: Implement Read-only mode
|
|
118
|
-
* TODO: [☹️] Unite with `PromptbookStorage` and move to `/src/...`
|
|
119
|
-
*/
|