@promptbook/cli 0.103.0-43 → 0.103.0-45
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/README.md +6 -18
- package/apps/agents-server/README.md +3 -0
- package/apps/agents-server/TODO.txt +6 -0
- package/apps/agents-server/config.ts.todo +312 -0
- package/apps/agents-server/next.config.ts +42 -0
- package/apps/agents-server/package.json +11 -0
- package/apps/agents-server/postcss.config.mjs +8 -0
- package/apps/agents-server/public/.gitkeep +0 -0
- package/apps/agents-server/public/favicon.ico +0 -0
- package/apps/agents-server/public/logo-blue-white-256.png +0 -0
- package/apps/agents-server/src/app/AddAgentButton.tsx +20 -0
- package/apps/agents-server/src/app/actions.ts +14 -0
- package/apps/agents-server/src/app/agents/[agentName]/AgentUrlCopy.tsx +41 -0
- package/apps/agents-server/src/app/agents/[agentName]/TODO.txt +1 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/chat/route.ts +60 -0
- package/apps/agents-server/src/app/agents/[agentName]/book+chat/SelfLearningBook.tsx +203 -0
- package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx +18 -0
- package/apps/agents-server/src/app/agents/[agentName]/page.tsx +155 -0
- package/apps/agents-server/src/app/api/chat/route.ts +32 -0
- package/apps/agents-server/src/app/api/chat-streaming/route.ts +44 -0
- package/apps/agents-server/src/app/api/long-running-task/route.ts +7 -0
- package/apps/agents-server/src/app/api/long-streaming/route.ts +20 -0
- package/apps/agents-server/src/app/globals.css +113 -0
- package/apps/agents-server/src/app/layout.tsx +72 -0
- package/apps/agents-server/src/app/page.tsx +115 -0
- package/apps/agents-server/src/deamons/longRunningTask.ts +37 -0
- package/apps/agents-server/src/supabase/TODO.txt +1 -0
- package/apps/agents-server/src/supabase/getSupabase.ts +25 -0
- package/apps/agents-server/src/supabase/getSupabaseForBrowser.ts +37 -0
- package/apps/agents-server/src/supabase/getSupabaseForServer.ts +48 -0
- package/apps/agents-server/src/supabase/getSupabaseForWorker.ts +42 -0
- package/apps/agents-server/src/tools/$provideAgentCollectionForServer.ts +49 -0
- package/apps/agents-server/src/tools/$provideExecutionToolsForServer.ts +110 -0
- package/apps/agents-server/src/tools/$provideOpenAiAssistantExecutionToolsForServer.ts +35 -0
- package/apps/agents-server/tailwind.config.ts +24 -0
- package/apps/agents-server/tsconfig.json +29 -0
- package/esm/index.es.js +57 -13
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +8 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +5 -0
- package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +2 -28
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +61 -9
- package/esm/typings/src/errors/DatabaseError.d.ts +3 -0
- package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +2 -1
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/remote-server/startAgentServer.d.ts +3 -0
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +1 -0
- package/esm/typings/src/types/typeAliases.d.ts +19 -1
- package/esm/typings/src/utils/color/$randomColor.d.ts +1 -0
- package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +5 -2
- package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +13 -0
- package/esm/typings/src/utils/random/$randomItem.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomSeed.d.ts +3 -0
- package/esm/typings/src/utils/random/$randomToken.d.ts +1 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +57 -13
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/commands/_common/parseCommand.test.d.ts +0 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
|
|
3
|
+
import logoImage from '@/public/logo-blue-white-256.png';
|
|
4
|
+
import { getSingleLlmExecutionTools } from '@promptbook-local/core';
|
|
5
|
+
import moment from 'moment';
|
|
6
|
+
import { headers } from 'next/headers';
|
|
7
|
+
import Image from 'next/image';
|
|
8
|
+
import Link from 'next/link';
|
|
9
|
+
import { AvatarProfile } from '../../../../src/book-components/AvatarProfile/AvatarProfile/AvatarProfile';
|
|
10
|
+
import { AboutPromptbookInformation } from '../../../../src/utils/misc/xAboutPromptbookInformation';
|
|
11
|
+
import { $sideEffect } from '../../../../src/utils/organization/$sideEffect';
|
|
12
|
+
import { getLongRunningTask } from '../deamons/longRunningTask';
|
|
13
|
+
import { $provideAgentCollectionForServer } from '../tools/$provideAgentCollectionForServer';
|
|
14
|
+
import { $provideExecutionToolsForServer } from '../tools/$provideExecutionToolsForServer';
|
|
15
|
+
import { AddAgentButton } from './AddAgentButton';
|
|
16
|
+
|
|
17
|
+
// Add calendar formats that include seconds
|
|
18
|
+
const calendarWithSeconds = {
|
|
19
|
+
sameDay: '[Today at] LTS',
|
|
20
|
+
nextDay: '[Tomorrow at] LTS',
|
|
21
|
+
nextWeek: 'dddd [at] LTS',
|
|
22
|
+
lastDay: '[Yesterday at] LTS',
|
|
23
|
+
lastWeek: '[Last] dddd [at] LTS',
|
|
24
|
+
sameElse: 'L [at] LTS',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default async function HomePage() {
|
|
28
|
+
$sideEffect(/* Note: [🐶] This will ensure dynamic rendering of page and avoid Next.js pre-render */ headers());
|
|
29
|
+
|
|
30
|
+
const collection = await $provideAgentCollectionForServer();
|
|
31
|
+
const agents = await collection.listAgents();
|
|
32
|
+
|
|
33
|
+
const longRunningTask = getLongRunningTask();
|
|
34
|
+
|
|
35
|
+
const executionTools = await $provideExecutionToolsForServer();
|
|
36
|
+
const models = await getSingleLlmExecutionTools(executionTools.llm).listModels();
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div className="min-h-screen bg-gradient-to-br from-blue-50 via-white to-purple-50">
|
|
40
|
+
<div className="container mx-auto px-4 py-16">
|
|
41
|
+
<h1 className="text-4xl font-bold text-gray-900 mb-4">
|
|
42
|
+
<Image src={logoImage} alt="Promptbook Logo" height={50} className="inline-block mr-4" />
|
|
43
|
+
Promptbook Agents Server
|
|
44
|
+
</h1>
|
|
45
|
+
|
|
46
|
+
<>
|
|
47
|
+
<h2 className="text-3xl text-gray-900 mt-16 mb-4">Agents ({agents.length})</h2>
|
|
48
|
+
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
|
|
49
|
+
{agents.map((agent) => (
|
|
50
|
+
<Link key={agent.agentName} href={`/agents/${agent.agentName}`}>
|
|
51
|
+
<AvatarProfile
|
|
52
|
+
{...{ agent }}
|
|
53
|
+
style={
|
|
54
|
+
!agent.meta.color
|
|
55
|
+
? {}
|
|
56
|
+
: {
|
|
57
|
+
backgroundColor: `${agent.meta.color}22`, // <- TODO: Use Color object here
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
className="block p-6 bg-white rounded-lg shadow-md hover:shadow-xl transition-shadow duration-300 border border-gray-200 hover:border-blue-400"
|
|
61
|
+
/>
|
|
62
|
+
</Link>
|
|
63
|
+
))}
|
|
64
|
+
<AddAgentButton />
|
|
65
|
+
</div>
|
|
66
|
+
</>
|
|
67
|
+
|
|
68
|
+
<>
|
|
69
|
+
<h2 className="text-3xl text-gray-900 mt-16 mb-4">Models ({models.length})</h2>
|
|
70
|
+
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
|
|
71
|
+
{models.map(({ modelName, modelTitle, modelDescription }) => (
|
|
72
|
+
<Link key={modelName} href={`#!!!`}>
|
|
73
|
+
<div className="block p-6 bg-white rounded-lg shadow-md hover:shadow-xl transition-shadow duration-300 border border-gray-200 hover:border-blue-400">
|
|
74
|
+
<h2 className="text-2xl font-semibold text-gray-900 mb-2">{modelTitle}</h2>
|
|
75
|
+
<code>{modelName}</code>
|
|
76
|
+
<p className="text-gray-600">{modelDescription}</p>
|
|
77
|
+
</div>
|
|
78
|
+
</Link>
|
|
79
|
+
))}
|
|
80
|
+
</div>
|
|
81
|
+
</>
|
|
82
|
+
|
|
83
|
+
<>
|
|
84
|
+
<h2 className="text-3xl text-gray-900 mt-16 mb-4">About</h2>
|
|
85
|
+
<AboutPromptbookInformation />
|
|
86
|
+
</>
|
|
87
|
+
|
|
88
|
+
<>
|
|
89
|
+
<h2 className="text-3xl text-gray-900 mt-16 mb-4">Technical Information</h2>
|
|
90
|
+
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
|
|
91
|
+
<Link
|
|
92
|
+
href={'#'}
|
|
93
|
+
className="block p-6 bg-white rounded-lg shadow-md hover:shadow-xl transition-shadow duration-300 border border-gray-200 hover:border-blue-400"
|
|
94
|
+
>
|
|
95
|
+
<h2 className="text-2xl font-semibold text-gray-900 mb-2">
|
|
96
|
+
Long running task {longRunningTask.taskId}
|
|
97
|
+
</h2>
|
|
98
|
+
<p className="text-gray-600">Tick: {longRunningTask.tick}</p>
|
|
99
|
+
<p className="text-gray-600">
|
|
100
|
+
Created At: {moment(longRunningTask.createdAt).calendar(undefined, calendarWithSeconds)}
|
|
101
|
+
</p>
|
|
102
|
+
<p className="text-gray-600">
|
|
103
|
+
Updated At: {moment(longRunningTask.updatedAt).calendar(undefined, calendarWithSeconds)}
|
|
104
|
+
</p>
|
|
105
|
+
</Link>
|
|
106
|
+
</div>
|
|
107
|
+
</>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* TODO: [🕋] Use here `AboutPromptbookInformation`
|
|
115
|
+
*/
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { forTime } from 'waitasecond';
|
|
2
|
+
import { just } from '../../../../src/utils/organization/just';
|
|
3
|
+
import { $randomToken } from '../../../../src/utils/random/$randomToken';
|
|
4
|
+
|
|
5
|
+
let longRunningTask: {
|
|
6
|
+
taskId: string;
|
|
7
|
+
tick: number;
|
|
8
|
+
createdAt: Date;
|
|
9
|
+
updatedAt: Date;
|
|
10
|
+
} | null = null;
|
|
11
|
+
|
|
12
|
+
export function getLongRunningTask() {
|
|
13
|
+
if (longRunningTask !== null) {
|
|
14
|
+
return longRunningTask;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const taskId = $randomToken(8);
|
|
18
|
+
let tick = 0;
|
|
19
|
+
|
|
20
|
+
longRunningTask = {
|
|
21
|
+
taskId,
|
|
22
|
+
tick,
|
|
23
|
+
createdAt: new Date(),
|
|
24
|
+
updatedAt: new Date(),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
(async () => {
|
|
28
|
+
while (just(true)) {
|
|
29
|
+
await forTime(1000);
|
|
30
|
+
// console.log(`Long running task ${taskId} tick ${tick}`);
|
|
31
|
+
longRunningTask.updatedAt = new Date();
|
|
32
|
+
longRunningTask.tick = ++tick;
|
|
33
|
+
}
|
|
34
|
+
})();
|
|
35
|
+
|
|
36
|
+
return longRunningTask;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
TODO: !!!! Rename all to $provide...
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AgentsDatabaseSchema } from '@promptbook-local/types';
|
|
2
|
+
import { $isRunningInBrowser, $isRunningInNode, $isRunningInWebWorker } from '@promptbook-local/utils';
|
|
3
|
+
import type { SupabaseClient } from '@supabase/supabase-js';
|
|
4
|
+
import { getSupabaseForBrowser } from './getSupabaseForBrowser';
|
|
5
|
+
import { getSupabaseForServer } from './getSupabaseForServer';
|
|
6
|
+
import { getSupabaseForWorker } from './getSupabaseForWorker';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Get supabase client in any environment
|
|
10
|
+
*
|
|
11
|
+
* Note: The client is cached, so it's safe to call this function multiple times
|
|
12
|
+
*
|
|
13
|
+
* @returns instance of supabase client
|
|
14
|
+
*/
|
|
15
|
+
export function getSupabase(): SupabaseClient<AgentsDatabaseSchema> {
|
|
16
|
+
if ($isRunningInNode()) {
|
|
17
|
+
return getSupabaseForServer();
|
|
18
|
+
} else if ($isRunningInBrowser()) {
|
|
19
|
+
return getSupabaseForBrowser();
|
|
20
|
+
} else if ($isRunningInWebWorker()) {
|
|
21
|
+
return getSupabaseForWorker();
|
|
22
|
+
} else {
|
|
23
|
+
throw new Error('Unknown environment, cannot determine how to get Supabase client');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createClient, SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
import { AgentsDatabaseSchema } from '@promptbook-local/types';
|
|
3
|
+
import { $isRunningInBrowser } from '@promptbook-local/utils';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Internal cache for `getSupabaseForBrowser`
|
|
7
|
+
*
|
|
8
|
+
* @private
|
|
9
|
+
* @singleton
|
|
10
|
+
*/
|
|
11
|
+
let supabase: SupabaseClient<AgentsDatabaseSchema>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Get supabase client
|
|
15
|
+
*
|
|
16
|
+
* Note: The client is cached, so it's safe to call this function multiple times
|
|
17
|
+
* Note: This function is available ONLY in browser, use getSupabaseForServer in node
|
|
18
|
+
*
|
|
19
|
+
* @returns instance of supabase client
|
|
20
|
+
*/
|
|
21
|
+
export function getSupabaseForBrowser(): typeof supabase {
|
|
22
|
+
if (!$isRunningInBrowser()) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
'Function `getSupabaseForBrowser` can not be used on server or worker, use `getSupabaseForServer` or `getSupabaseForWorker` instead.',
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!supabase) {
|
|
29
|
+
// Create a single supabase client for interacting with your database
|
|
30
|
+
supabase = createClient<AgentsDatabaseSchema>(
|
|
31
|
+
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
32
|
+
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return supabase;
|
|
37
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AgentsDatabaseSchema } from '@promptbook-local/types';
|
|
2
|
+
import { $isRunningInNode } from '@promptbook-local/utils';
|
|
3
|
+
import { createClient, SupabaseClient } from '@supabase/supabase-js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Internal cache for `getSupabaseForServer`
|
|
7
|
+
*
|
|
8
|
+
* @private
|
|
9
|
+
* @singleton
|
|
10
|
+
*/
|
|
11
|
+
let supabase: SupabaseClient<AgentsDatabaseSchema>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Get supabase client
|
|
15
|
+
*
|
|
16
|
+
* Note: The client is cached, so it's safe to call this function multiple times
|
|
17
|
+
* Note: This function is available ONLY on server/node, use getSupabaseForClient in browser
|
|
18
|
+
*
|
|
19
|
+
* @returns instance of supabase client
|
|
20
|
+
*/
|
|
21
|
+
export function getSupabaseForServer(): typeof supabase {
|
|
22
|
+
if (!$isRunningInNode()) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
'Function `getSupabaseForServer` can not be used in browser, use `getSupabaseForBrowser` instead.',
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!supabase) {
|
|
29
|
+
// Create a single supabase client for interacting with your database
|
|
30
|
+
supabase = createClient<AgentsDatabaseSchema>(
|
|
31
|
+
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
32
|
+
process.env.SUPABASE_SERVICE_ROLE_KEY!,
|
|
33
|
+
{
|
|
34
|
+
auth: {
|
|
35
|
+
autoRefreshToken: false,
|
|
36
|
+
persistSession: false,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
// Access auth admin api
|
|
44
|
+
const adminAuthClient = supabase.auth.admin;
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
return supabase;
|
|
48
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { AgentsDatabaseSchema } from '@promptbook-local/types';
|
|
2
|
+
import { $isRunningInWebWorker } from '@promptbook-local/utils';
|
|
3
|
+
import { createClient, SupabaseClient } from '@supabase/supabase-js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Internal cache for `getSupabaseForWorker`
|
|
7
|
+
*
|
|
8
|
+
* @private
|
|
9
|
+
* @singleton
|
|
10
|
+
*/
|
|
11
|
+
let supabase: SupabaseClient<AgentsDatabaseSchema>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Get supabase client
|
|
15
|
+
*
|
|
16
|
+
* Note: The client is cached, so it's safe to call this function multiple times
|
|
17
|
+
* Note: This function is available ONLY in worker, use getSupabaseForBrowser for main thread
|
|
18
|
+
*
|
|
19
|
+
* @returns instance of supabase client
|
|
20
|
+
*/
|
|
21
|
+
export function getSupabaseForWorker(): typeof supabase {
|
|
22
|
+
if (!$isRunningInWebWorker) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
'Function `getSupabaseForWorker` can not be used in browser, use `getSupabaseForBrowser` instead.',
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!supabase) {
|
|
29
|
+
// Create a single supabase client for interacting with your database
|
|
30
|
+
supabase = createClient<AgentsDatabaseSchema>(
|
|
31
|
+
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
32
|
+
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return supabase;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* TODO: Fix> No storage option exists to persist the session, which may result in unexpected behavior when using auth.
|
|
41
|
+
If you want to set persistSession to true, please provide a storage option or you may set persistSession to false to disable this warning.
|
|
42
|
+
*/
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
|
|
3
|
+
import { AgentCollectionInSupabase } from '@promptbook-local/core';
|
|
4
|
+
import { AgentCollection } from '@promptbook-local/types';
|
|
5
|
+
import { getSupabaseForServer } from '../supabase/getSupabaseForServer';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Cache of provided agent collection
|
|
9
|
+
* @private internal cache for `$provideAgentCollectionForServer`
|
|
10
|
+
*/
|
|
11
|
+
let agentCollection: null | AgentCollection = null;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* !!!!
|
|
15
|
+
*/
|
|
16
|
+
export async function $provideAgentCollectionForServer(): Promise<AgentCollection> {
|
|
17
|
+
// <- Note: This function is potentially async
|
|
18
|
+
|
|
19
|
+
// TODO: !!!! [🌕] DRY
|
|
20
|
+
|
|
21
|
+
const isVerbose = true; // <- TODO: !!!! Pass
|
|
22
|
+
|
|
23
|
+
if (agentCollection !== null) {
|
|
24
|
+
console.log('!!! Returning cached agent collection');
|
|
25
|
+
return agentCollection;
|
|
26
|
+
// TODO: !!!! Be aware of options changes
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
console.log('!!! Creating NEW agent collection');
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
// TODO: [🧟♂️][◽] DRY:
|
|
33
|
+
const collection = new AgentCollectionInDirectory(path, tools, {
|
|
34
|
+
isVerbose,
|
|
35
|
+
isRecursive: true,
|
|
36
|
+
isLazyLoaded: false,
|
|
37
|
+
isCrashedOnError: true,
|
|
38
|
+
// <- TODO: [🍖] Add `intermediateFilesStrategy`
|
|
39
|
+
});
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
const supabase = getSupabaseForServer();
|
|
43
|
+
|
|
44
|
+
agentCollection = new AgentCollectionInSupabase(supabase, {
|
|
45
|
+
isVerbose,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return agentCollection;
|
|
49
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
_AnthropicClaudeMetadataRegistration,
|
|
5
|
+
_AzureOpenAiMetadataRegistration,
|
|
6
|
+
_BoilerplateScraperMetadataRegistration,
|
|
7
|
+
_DeepseekMetadataRegistration,
|
|
8
|
+
_DocumentScraperMetadataRegistration,
|
|
9
|
+
_GoogleMetadataRegistration,
|
|
10
|
+
_LegacyDocumentScraperMetadataRegistration,
|
|
11
|
+
_MarkdownScraperMetadataRegistration,
|
|
12
|
+
_MarkitdownScraperMetadataRegistration,
|
|
13
|
+
_OllamaMetadataRegistration,
|
|
14
|
+
_OpenAiAssistantMetadataRegistration,
|
|
15
|
+
_OpenAiCompatibleMetadataRegistration,
|
|
16
|
+
_OpenAiMetadataRegistration,
|
|
17
|
+
_PdfScraperMetadataRegistration,
|
|
18
|
+
_WebsiteScraperMetadataRegistration,
|
|
19
|
+
} from '@promptbook-local/core';
|
|
20
|
+
import { _GoogleRegistration } from '@promptbook-local/google';
|
|
21
|
+
import { _OpenAiRegistration } from '@promptbook-local/openai';
|
|
22
|
+
import { ExecutionTools, TODO_any } from '@promptbook-local/types';
|
|
23
|
+
import { $provideLlmToolsForCli } from '../../../../src/cli/common/$provideLlmToolsForCli';
|
|
24
|
+
import { $provideExecutablesForNode } from '../../../../src/executables/$provideExecutablesForNode';
|
|
25
|
+
import { $provideFilesystemForNode } from '../../../../src/scrapers/_common/register/$provideFilesystemForNode';
|
|
26
|
+
import { $provideScrapersForNode } from '../../../../src/scrapers/_common/register/$provideScrapersForNode';
|
|
27
|
+
import { $provideScriptingForNode } from '../../../../src/scrapers/_common/register/$provideScriptingForNode';
|
|
28
|
+
import { $sideEffect } from '../../../../src/utils/organization/$sideEffect';
|
|
29
|
+
|
|
30
|
+
$sideEffect(
|
|
31
|
+
_AnthropicClaudeMetadataRegistration,
|
|
32
|
+
_AzureOpenAiMetadataRegistration,
|
|
33
|
+
_DeepseekMetadataRegistration,
|
|
34
|
+
_GoogleMetadataRegistration,
|
|
35
|
+
_OllamaMetadataRegistration,
|
|
36
|
+
_OpenAiMetadataRegistration,
|
|
37
|
+
_OpenAiAssistantMetadataRegistration,
|
|
38
|
+
_OpenAiCompatibleMetadataRegistration,
|
|
39
|
+
_BoilerplateScraperMetadataRegistration,
|
|
40
|
+
_LegacyDocumentScraperMetadataRegistration,
|
|
41
|
+
_DocumentScraperMetadataRegistration,
|
|
42
|
+
_MarkdownScraperMetadataRegistration,
|
|
43
|
+
_MarkitdownScraperMetadataRegistration,
|
|
44
|
+
_PdfScraperMetadataRegistration,
|
|
45
|
+
_WebsiteScraperMetadataRegistration,
|
|
46
|
+
// <- TODO: !!! Export all registrations from one variabile in `@promptbook/core`
|
|
47
|
+
);
|
|
48
|
+
$sideEffect(/* [㊗] */ _OpenAiRegistration);
|
|
49
|
+
$sideEffect(/* [㊗] */ _GoogleRegistration);
|
|
50
|
+
// <- TODO: !!!! Allow to dynamically install required metadata
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Cache of provided execution tools
|
|
54
|
+
*
|
|
55
|
+
* @private internal cache for `$provideExecutionToolsForServer`
|
|
56
|
+
*/
|
|
57
|
+
let executionTools: null | ExecutionTools = null;
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
TODO: [▶️]
|
|
63
|
+
type ProvideExecutionToolsForServerOptions = {
|
|
64
|
+
isLlmProvided
|
|
65
|
+
}
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* !!!!
|
|
70
|
+
*/
|
|
71
|
+
export async function $provideExecutionToolsForServer(): Promise<ExecutionTools> {
|
|
72
|
+
// TODO: !!!! [🌕] DRY
|
|
73
|
+
|
|
74
|
+
// const path = '../../agents'; // <- TODO: !!!! Pass
|
|
75
|
+
const isVerbose = true; // <- TODO: !!!! Pass
|
|
76
|
+
const isCacheReloaded = false; // <- TODO: !!!! Pass
|
|
77
|
+
const cliOptions = {
|
|
78
|
+
provider: 'BRING_YOUR_OWN_KEYS',
|
|
79
|
+
} as TODO_any; // <- TODO: !!!! Pass
|
|
80
|
+
|
|
81
|
+
if (executionTools !== null) {
|
|
82
|
+
console.log('!!! Returning cached execution tools');
|
|
83
|
+
return executionTools;
|
|
84
|
+
// TODO: !!!! Be aware of options changes
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
console.log('!!! Creating NEW execution tools');
|
|
88
|
+
|
|
89
|
+
// TODO: DRY [◽]
|
|
90
|
+
const prepareAndScrapeOptions = {
|
|
91
|
+
isVerbose,
|
|
92
|
+
isCacheReloaded,
|
|
93
|
+
}; /* <- TODO: ` satisfies PrepareAndScrapeOptions` */
|
|
94
|
+
const fs = await $provideFilesystemForNode(prepareAndScrapeOptions);
|
|
95
|
+
const { /* [0] strategy,*/ llm } = await $provideLlmToolsForCli({
|
|
96
|
+
cliOptions,
|
|
97
|
+
...prepareAndScrapeOptions,
|
|
98
|
+
});
|
|
99
|
+
const executables = await $provideExecutablesForNode(prepareAndScrapeOptions);
|
|
100
|
+
|
|
101
|
+
executionTools = {
|
|
102
|
+
llm,
|
|
103
|
+
fs,
|
|
104
|
+
executables,
|
|
105
|
+
scrapers: await $provideScrapersForNode({ fs, llm, executables }, prepareAndScrapeOptions),
|
|
106
|
+
script: await $provideScriptingForNode(prepareAndScrapeOptions),
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return executionTools;
|
|
110
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
|
|
3
|
+
import { OpenAiAssistantExecutionTools } from '@promptbook-local/openai';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Cache of provided OpenAiAssistantExecutionTools
|
|
7
|
+
*
|
|
8
|
+
* @private internal cache for `$provideOpenAiAssistantExecutionToolsForServer`
|
|
9
|
+
*/
|
|
10
|
+
let executionTools: null | OpenAiAssistantExecutionTools = null;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* !!!!
|
|
14
|
+
*/
|
|
15
|
+
export async function $provideOpenAiAssistantExecutionToolsForServer(): Promise<OpenAiAssistantExecutionTools> {
|
|
16
|
+
// TODO: !!!! [🌕] DRY
|
|
17
|
+
const isVerbose = true; // <- TODO: !!!! Pass
|
|
18
|
+
|
|
19
|
+
if (executionTools !== null) {
|
|
20
|
+
console.log('!!! Returning cached OpenAiAssistantExecutionTools');
|
|
21
|
+
return executionTools;
|
|
22
|
+
// TODO: !!!! Be aware of options changes
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
console.log('!!! Creating NEW OpenAiAssistantExecutionTools');
|
|
26
|
+
|
|
27
|
+
executionTools = new OpenAiAssistantExecutionTools({
|
|
28
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
29
|
+
assistantId: '!!!! null',
|
|
30
|
+
isCreatingNewAssistantsAllowed: true,
|
|
31
|
+
isVerbose,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return executionTools;
|
|
35
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Config } from 'tailwindcss';
|
|
2
|
+
|
|
3
|
+
const config: Config = {
|
|
4
|
+
content: [
|
|
5
|
+
'./src/pages/**/*.{js,ts,jsx,tsx,mdx}',
|
|
6
|
+
'./src/components/**/*.{js,ts,jsx,tsx,mdx}',
|
|
7
|
+
'./src/app/**/*.{js,ts,jsx,tsx,mdx}',
|
|
8
|
+
],
|
|
9
|
+
theme: {
|
|
10
|
+
extend: {
|
|
11
|
+
fontFamily: {
|
|
12
|
+
sans: ['var(--font-geist-sans)', 'Arial', 'Helvetica', 'sans-serif'],
|
|
13
|
+
mono: ['var(--font-geist-mono)', 'Courier New', 'monospace'],
|
|
14
|
+
},
|
|
15
|
+
colors: {
|
|
16
|
+
background: 'var(--background)',
|
|
17
|
+
foreground: 'var(--foreground)',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
plugins: [],
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default config;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "esnext",
|
|
4
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noEmit": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"module": "esnext",
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"jsx": "preserve",
|
|
15
|
+
"incremental": true,
|
|
16
|
+
"plugins": [
|
|
17
|
+
{
|
|
18
|
+
"name": "next"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"paths": {
|
|
22
|
+
"@/*": ["./*"],
|
|
23
|
+
"@common/*": ["../_common/*"],
|
|
24
|
+
"@promptbook-local/*": ["../../src/_packages/*.index"]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
|
28
|
+
"exclude": ["node_modules"]
|
|
29
|
+
}
|