@undefineds.co/models 0.2.34 → 0.2.37
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 +13 -16
- package/dist/agent.repository.d.ts +48 -0
- package/dist/agent.repository.js +1 -1
- package/dist/agent.schema.d.ts +24 -0
- package/dist/agent.schema.js +16 -5
- package/dist/ai-config/index.d.ts +28 -2
- package/dist/ai-config/index.js +154 -13
- package/dist/ai-model.schema.js +11 -12
- package/dist/ai-provider.schema.d.ts +4 -0
- package/dist/ai-provider.schema.js +11 -10
- package/dist/ai-runtime.schema.d.ts +4 -4
- package/dist/ai-runtime.schema.js +43 -45
- package/dist/approval.schema.d.ts +0 -1
- package/dist/approval.schema.js +2 -11
- package/dist/audit.schema.d.ts +0 -1
- package/dist/audit.schema.js +2 -11
- package/dist/automation-rule.schema.d.ts +63 -0
- package/dist/automation-rule.schema.js +51 -0
- package/dist/bin/udfs.js +3 -3
- package/dist/chat.repository.d.ts +4 -4
- package/dist/chat.repository.js +1 -1
- package/dist/chat.schema.d.ts +2 -2
- package/dist/chat.schema.js +3 -4
- package/dist/chat.utils.d.ts +7 -0
- package/dist/chat.utils.js +35 -6
- package/dist/contact.repository.d.ts +4 -4
- package/dist/contact.repository.js +1 -1
- package/dist/contact.schema.d.ts +2 -2
- package/dist/contact.schema.js +2 -3
- package/dist/credential.schema.js +21 -22
- package/dist/delivery.schema.d.ts +81 -0
- package/dist/delivery.schema.js +64 -0
- package/dist/evidence.schema.d.ts +40 -0
- package/dist/evidence.schema.js +48 -0
- package/dist/favorite/favorite.schema.d.ts +3 -5
- package/dist/favorite/favorite.schema.js +2 -3
- package/dist/favorite/starred-sync.d.ts +1 -1
- package/dist/favorite/starred-sync.js +11 -13
- package/dist/fixtures/contracts-chat-contact.js +3 -3
- package/dist/grant.schema.d.ts +2 -3
- package/dist/grant.schema.js +6 -9
- package/dist/idea.schema.d.ts +32 -0
- package/dist/idea.schema.js +36 -0
- package/dist/inbox-notification.schema.js +1 -2
- package/dist/index.d.ts +19 -14
- package/dist/index.js +20 -18
- package/dist/issue.repository.js +1 -1
- package/dist/issue.schema.js +1 -2
- package/dist/knowledge/knowledge-folder.schema.d.ts +1 -1
- package/dist/knowledge/knowledge-folder.schema.js +1 -1
- package/dist/message.repository.d.ts +8 -12
- package/dist/message.repository.js +1 -1
- package/dist/message.schema.d.ts +11 -9
- package/dist/message.schema.js +29 -13
- package/dist/namespaces.d.ts +0 -2
- package/dist/namespaces.js +121 -92
- package/dist/pod-storage-descriptor.d.ts +0 -6
- package/dist/pod-storage-descriptor.js +11 -12
- package/dist/profile.repository.d.ts +2 -2
- package/dist/profile.repository.js +2 -2
- package/dist/report.schema.d.ts +58 -0
- package/dist/report.schema.js +73 -0
- package/dist/repository.d.ts +15 -4
- package/dist/repository.js +16 -5
- package/dist/resource-id-defaults.d.ts +1 -12
- package/dist/resource-id-defaults.js +65 -72
- package/dist/resource-refs.d.ts +25 -0
- package/dist/resource-refs.js +45 -0
- package/dist/run.schema.d.ts +13 -17
- package/dist/run.schema.js +12 -13
- package/dist/schedule.schema.d.ts +56 -0
- package/dist/schedule.schema.js +46 -0
- package/dist/schema.d.ts +275 -192
- package/dist/schema.js +18 -10
- package/dist/session/index.d.ts +1 -1
- package/dist/session/index.js +1 -1
- package/dist/session/session.schema.d.ts +4 -6
- package/dist/session/session.schema.js +5 -16
- package/dist/session.repository.d.ts +8 -8
- package/dist/session.repository.js +1 -1
- package/dist/settings/settings.schema.d.ts +2 -0
- package/dist/settings/settings.schema.js +8 -3
- package/dist/sidecar/persistence-mapping.d.ts +1 -1
- package/dist/sidecar/sidecar-events.d.ts +36 -36
- package/dist/skill.schema.d.ts +39 -0
- package/dist/skill.schema.js +31 -0
- package/dist/task.schema.d.ts +22 -32
- package/dist/task.schema.js +17 -25
- package/dist/thread.repository.d.ts +8 -8
- package/dist/thread.repository.js +1 -1
- package/dist/thread.schema.d.ts +15 -10
- package/dist/thread.schema.js +32 -13
- package/dist/types/collaboration-blocks.d.ts +3 -1
- package/dist/types/message-block.d.ts +3 -1
- package/dist/vocab/chat.vocab.d.ts +1 -1
- package/dist/vocab/chat.vocab.js +1 -1
- package/dist/vocab/contact.vocab.d.ts +1 -1
- package/dist/vocab/contact.vocab.js +1 -1
- package/dist/vocab/index.d.ts +2 -0
- package/dist/vocab/index.js +2 -0
- package/dist/vocab/message.vocab.d.ts +2 -1
- package/dist/vocab/message.vocab.js +2 -1
- package/dist/vocab/session.vocab.d.ts +16 -0
- package/dist/vocab/session.vocab.js +17 -0
- package/dist/vocab/sidecar.vocab.d.ts +19 -1
- package/dist/vocab/sidecar.vocab.js +22 -4
- package/dist/vocab/thread.vocab.d.ts +2 -0
- package/dist/vocab/thread.vocab.js +2 -0
- package/dist/vocab/workflow.vocab.d.ts +135 -0
- package/dist/vocab/workflow.vocab.js +136 -0
- package/package.json +3 -3
- package/skills/solid-modeling/SKILL.md +70 -17
- package/dist/file/file.schema.d.ts +0 -60
- package/dist/file/file.schema.js +0 -53
- package/dist/file/index.d.ts +0 -1
- package/dist/file/index.js +0 -1
- package/dist/matrix.repository.d.ts +0 -183
- package/dist/matrix.repository.js +0 -20
- package/dist/matrix.schema.d.ts +0 -136
- package/dist/matrix.schema.js +0 -100
package/README.md
CHANGED
|
@@ -17,8 +17,6 @@ yarn workspace @undefineds.co/models test
|
|
|
17
17
|
```ts
|
|
18
18
|
import {
|
|
19
19
|
UDFS,
|
|
20
|
-
XPOD_AI,
|
|
21
|
-
XPOD_CREDENTIAL,
|
|
22
20
|
agentResource,
|
|
23
21
|
aiModelResource,
|
|
24
22
|
aiProviderResource,
|
|
@@ -53,13 +51,6 @@ https://undefineds.co/ns#
|
|
|
53
51
|
|
|
54
52
|
Use `udfs:` terms in models-level RDF contracts.
|
|
55
53
|
|
|
56
|
-
AI service catalog resources currently use the Xpod AI vocabularies:
|
|
57
|
-
|
|
58
|
-
```text
|
|
59
|
-
https://vocab.xpod.dev/ai#
|
|
60
|
-
https://vocab.xpod.dev/credential#
|
|
61
|
-
```
|
|
62
|
-
|
|
63
54
|
## Core Runtime Semantics
|
|
64
55
|
|
|
65
56
|
The shared chat/runtime model is:
|
|
@@ -169,16 +160,16 @@ AI Secretary has both:
|
|
|
169
160
|
```text
|
|
170
161
|
Contact
|
|
171
162
|
contactType: agent
|
|
172
|
-
|
|
163
|
+
entity: Agent context-root URI
|
|
173
164
|
|
|
174
165
|
Agent
|
|
175
|
-
|
|
176
|
-
|
|
166
|
+
root: /agents/__secretary__/
|
|
167
|
+
meta: /agents/__secretary__/.meta
|
|
177
168
|
```
|
|
178
169
|
|
|
179
170
|
External people, services, or bots may appear as Contacts without being LinX
|
|
180
|
-
Agents. If something is modeled as an executable LinX Agent,
|
|
181
|
-
|
|
171
|
+
Agents. If something is modeled as an executable LinX Agent, the Agent resource
|
|
172
|
+
identity is the context-root container itself.
|
|
182
173
|
|
|
183
174
|
## Resource Ownership
|
|
184
175
|
|
|
@@ -212,7 +203,7 @@ Representative paths:
|
|
|
212
203
|
/.data/chat/{chatId}/index.ttl#this
|
|
213
204
|
/.data/chat/{chatId}/index.ttl#{threadId}
|
|
214
205
|
/.data/chat/{chatId}/{yyyy}/{MM}/{dd}/messages.ttl#{messageId}
|
|
215
|
-
|
|
206
|
+
/agents/{agentId}/
|
|
216
207
|
/.data/sessions/{yyyy}/{MM}/{dd}/{sessionId}.ttl
|
|
217
208
|
/settings/providers/{providerId}.ttl
|
|
218
209
|
/settings/providers/{providerId}.ttl#{modelId}
|
|
@@ -221,7 +212,13 @@ Representative paths:
|
|
|
221
212
|
|
|
222
213
|
Schema fields that are RDF relations should store resource URIs, not hidden
|
|
223
214
|
`xxxId` foreign keys. Short ids are acceptable at repository/helper boundaries
|
|
224
|
-
when the helper derives the canonical URI internally.
|
|
215
|
+
when the helper derives the canonical URI internally. If a fact must be
|
|
216
|
+
queried, synced, approved, audited, or used to reconstruct shared state, model
|
|
217
|
+
it as an explicit field or URI relation instead of hiding it in `metadata`.
|
|
218
|
+
`metadata` is only for opaque protocol ids, local cache keys, UI state,
|
|
219
|
+
compatibility data, and non-structural context. Prefer semantic relation names
|
|
220
|
+
such as `chat`, `thread`, `message`, `task`, `delivery`, `session`,
|
|
221
|
+
`workspace`, `source`, and `trigger`.
|
|
225
222
|
|
|
226
223
|
## Design Rules
|
|
227
224
|
|
|
@@ -3,12 +3,24 @@ export declare const agentRepository: import("@undefineds.co/drizzle-solid/dist/
|
|
|
3
3
|
name: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, false>;
|
|
4
4
|
description: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
5
5
|
avatarUrl: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
6
|
+
root: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
7
|
+
identity: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
8
|
+
hasSkill: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"array", "uri", false, false>;
|
|
6
9
|
instructions: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
7
10
|
provider: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
8
11
|
model: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
12
|
+
backend: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
13
|
+
runtime: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
14
|
+
transport: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
15
|
+
endpoint: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
16
|
+
credentialSource: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
9
17
|
temperature: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"integer", null, false, true>;
|
|
10
18
|
tools: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"array", "string", false, false>;
|
|
11
19
|
contextRound: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"integer", null, false, true>;
|
|
20
|
+
authorityPolicy: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"object", null, false, false>;
|
|
21
|
+
toolPolicy: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"object", null, false, false>;
|
|
22
|
+
metadata: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"object", null, false, false>;
|
|
23
|
+
enabled: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"boolean", null, false, true>;
|
|
12
24
|
ttsModel: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
13
25
|
videoModel: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
14
26
|
createdAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, true, true>;
|
|
@@ -19,12 +31,24 @@ export declare const agentRepository: import("@undefineds.co/drizzle-solid/dist/
|
|
|
19
31
|
name: string;
|
|
20
32
|
description: string;
|
|
21
33
|
avatarUrl: string;
|
|
34
|
+
root: string;
|
|
35
|
+
identity: string;
|
|
36
|
+
hasSkill: string[];
|
|
22
37
|
instructions: string;
|
|
23
38
|
provider: string;
|
|
24
39
|
model: string;
|
|
40
|
+
backend: string;
|
|
41
|
+
runtime: string;
|
|
42
|
+
transport: string;
|
|
43
|
+
endpoint: string;
|
|
44
|
+
credentialSource: string;
|
|
25
45
|
temperature: number;
|
|
26
46
|
tools: string[];
|
|
27
47
|
contextRound: number;
|
|
48
|
+
authorityPolicy: Record<string, unknown>;
|
|
49
|
+
toolPolicy: Record<string, unknown>;
|
|
50
|
+
metadata: Record<string, unknown>;
|
|
51
|
+
enabled: boolean;
|
|
28
52
|
ttsModel: string;
|
|
29
53
|
videoModel: string;
|
|
30
54
|
createdAt: Date;
|
|
@@ -35,12 +59,24 @@ export declare const agentRepository: import("@undefineds.co/drizzle-solid/dist/
|
|
|
35
59
|
id?: string | undefined;
|
|
36
60
|
description?: string | undefined;
|
|
37
61
|
avatarUrl?: string | undefined;
|
|
62
|
+
root?: string | undefined;
|
|
63
|
+
identity?: string | undefined;
|
|
64
|
+
hasSkill?: string[] | undefined;
|
|
38
65
|
instructions?: string | undefined;
|
|
39
66
|
provider?: string | undefined;
|
|
40
67
|
model?: string | undefined;
|
|
68
|
+
backend?: string | undefined;
|
|
69
|
+
runtime?: string | undefined;
|
|
70
|
+
transport?: string | undefined;
|
|
71
|
+
endpoint?: string | undefined;
|
|
72
|
+
credentialSource?: string | undefined;
|
|
41
73
|
temperature?: number | undefined;
|
|
42
74
|
tools?: string[] | undefined;
|
|
43
75
|
contextRound?: number | undefined;
|
|
76
|
+
authorityPolicy?: Record<string, unknown> | undefined;
|
|
77
|
+
toolPolicy?: Record<string, unknown> | undefined;
|
|
78
|
+
metadata?: Record<string, unknown> | undefined;
|
|
79
|
+
enabled?: boolean | undefined;
|
|
44
80
|
ttsModel?: string | undefined;
|
|
45
81
|
videoModel?: string | undefined;
|
|
46
82
|
createdAt?: Date | undefined;
|
|
@@ -51,12 +87,24 @@ export declare const agentRepository: import("@undefineds.co/drizzle-solid/dist/
|
|
|
51
87
|
name?: string | undefined;
|
|
52
88
|
description?: string | null | undefined;
|
|
53
89
|
avatarUrl?: string | null | undefined;
|
|
90
|
+
root?: string | null | undefined;
|
|
91
|
+
identity?: string | null | undefined;
|
|
92
|
+
hasSkill?: string[] | null | undefined;
|
|
54
93
|
instructions?: string | null | undefined;
|
|
55
94
|
provider?: string | null | undefined;
|
|
56
95
|
model?: string | null | undefined;
|
|
96
|
+
backend?: string | null | undefined;
|
|
97
|
+
runtime?: string | null | undefined;
|
|
98
|
+
transport?: string | null | undefined;
|
|
99
|
+
endpoint?: string | null | undefined;
|
|
100
|
+
credentialSource?: string | null | undefined;
|
|
57
101
|
temperature?: number | null | undefined;
|
|
58
102
|
tools?: string[] | null | undefined;
|
|
59
103
|
contextRound?: number | null | undefined;
|
|
104
|
+
authorityPolicy?: Record<string, unknown> | null | undefined;
|
|
105
|
+
toolPolicy?: Record<string, unknown> | null | undefined;
|
|
106
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
107
|
+
enabled?: boolean | null | undefined;
|
|
60
108
|
ttsModel?: string | null | undefined;
|
|
61
109
|
videoModel?: string | null | undefined;
|
|
62
110
|
createdAt?: Date | undefined;
|
package/dist/agent.repository.js
CHANGED
|
@@ -2,6 +2,6 @@ import { definePodRepository } from './repository.js';
|
|
|
2
2
|
import { agentResource } from './agent.schema.js';
|
|
3
3
|
export const agentRepository = definePodRepository({
|
|
4
4
|
namespace: 'agent',
|
|
5
|
-
|
|
5
|
+
resource: agentResource,
|
|
6
6
|
searchableFields: ['name', 'description', 'instructions'],
|
|
7
7
|
});
|
package/dist/agent.schema.d.ts
CHANGED
|
@@ -3,12 +3,24 @@ export declare const agentResource: import("@undefineds.co/drizzle-solid/dist/co
|
|
|
3
3
|
name: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, false>;
|
|
4
4
|
description: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
5
5
|
avatarUrl: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
6
|
+
root: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
7
|
+
identity: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
8
|
+
hasSkill: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"array", "uri", false, false>;
|
|
6
9
|
instructions: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
7
10
|
provider: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
8
11
|
model: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
12
|
+
backend: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
13
|
+
runtime: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
14
|
+
transport: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
15
|
+
endpoint: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
16
|
+
credentialSource: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
9
17
|
temperature: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"integer", null, false, true>;
|
|
10
18
|
tools: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"array", "string", false, false>;
|
|
11
19
|
contextRound: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"integer", null, false, true>;
|
|
20
|
+
authorityPolicy: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"object", null, false, false>;
|
|
21
|
+
toolPolicy: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"object", null, false, false>;
|
|
22
|
+
metadata: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"object", null, false, false>;
|
|
23
|
+
enabled: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"boolean", null, false, true>;
|
|
12
24
|
ttsModel: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
13
25
|
videoModel: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
14
26
|
createdAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, true, true>;
|
|
@@ -20,12 +32,24 @@ export declare const agentTable: import("@undefineds.co/drizzle-solid/dist/core/
|
|
|
20
32
|
name: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, false>;
|
|
21
33
|
description: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
22
34
|
avatarUrl: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
35
|
+
root: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
36
|
+
identity: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
37
|
+
hasSkill: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"array", "uri", false, false>;
|
|
23
38
|
instructions: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
24
39
|
provider: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
25
40
|
model: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
41
|
+
backend: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
42
|
+
runtime: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
43
|
+
transport: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
44
|
+
endpoint: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
45
|
+
credentialSource: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
26
46
|
temperature: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"integer", null, false, true>;
|
|
27
47
|
tools: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"array", "string", false, false>;
|
|
28
48
|
contextRound: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"integer", null, false, true>;
|
|
49
|
+
authorityPolicy: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"object", null, false, false>;
|
|
50
|
+
toolPolicy: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"object", null, false, false>;
|
|
51
|
+
metadata: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"object", null, false, false>;
|
|
52
|
+
enabled: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"boolean", null, false, true>;
|
|
29
53
|
ttsModel: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
30
54
|
videoModel: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
31
55
|
createdAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, true, true>;
|
package/dist/agent.schema.js
CHANGED
|
@@ -1,27 +1,38 @@
|
|
|
1
|
-
import { podTable, string, integer, timestamp, text, real, uri, id } from "@undefineds.co/drizzle-solid";
|
|
1
|
+
import { boolean, object, podTable, string, integer, timestamp, text, real, uri, id } from "@undefineds.co/drizzle-solid";
|
|
2
2
|
import { UDFS, DCTerms, FOAF, VCARD } from "./namespaces.js";
|
|
3
3
|
export const agentResource = podTable("agent", {
|
|
4
|
-
id: id("id"),
|
|
4
|
+
id: id("id").default("{key}/"),
|
|
5
5
|
name: string("name").predicate(FOAF.name).notNull(),
|
|
6
6
|
description: text("description").predicate(DCTerms.description),
|
|
7
7
|
avatarUrl: uri("avatarUrl").predicate(VCARD.hasPhoto),
|
|
8
|
+
root: uri("root").predicate(UDFS.root),
|
|
9
|
+
identity: uri("identity").predicate(UDFS.webId),
|
|
10
|
+
hasSkill: uri("hasSkill").array().predicate(UDFS.hasSkill),
|
|
8
11
|
instructions: text("instructions").predicate(UDFS.systemMessage),
|
|
9
12
|
provider: string("provider").predicate(UDFS.provider),
|
|
10
13
|
model: string("model").predicate(UDFS.model),
|
|
14
|
+
backend: string("backend").predicate(UDFS.backend),
|
|
15
|
+
runtime: string("runtime").predicate(UDFS.runtime),
|
|
16
|
+
transport: string("transport").predicate(UDFS.transport),
|
|
17
|
+
endpoint: uri("endpoint").predicate(UDFS.endpoint),
|
|
18
|
+
credentialSource: string("credentialSource").predicate(UDFS.credentialSource),
|
|
11
19
|
temperature: real("temperature").predicate(UDFS.temperature).default(0.7),
|
|
12
20
|
tools: text("tools").array().predicate(UDFS.tools),
|
|
13
21
|
contextRound: integer("contextRound").predicate(UDFS.contextRound).default(4),
|
|
22
|
+
authorityPolicy: object("authorityPolicy").predicate(UDFS.authorityPolicy),
|
|
23
|
+
toolPolicy: object("toolPolicy").predicate(UDFS.toolPolicy),
|
|
24
|
+
metadata: object("metadata").predicate(UDFS.metadata),
|
|
25
|
+
enabled: boolean("enabled").predicate(UDFS.enabled).default(true),
|
|
14
26
|
ttsModel: string("ttsModel").predicate(UDFS.ttsModel),
|
|
15
27
|
videoModel: string("videoModel").predicate(UDFS.videoModel),
|
|
16
28
|
createdAt: timestamp("createdAt").predicate(DCTerms.created).notNull().defaultNow(),
|
|
17
29
|
updatedAt: timestamp("updatedAt").predicate(DCTerms.modified).notNull().defaultNow(),
|
|
18
30
|
deletedAt: timestamp("deletedAt").predicate(UDFS.deletedAt),
|
|
19
31
|
}, {
|
|
20
|
-
base: '
|
|
21
|
-
sparqlEndpoint: '
|
|
32
|
+
base: '/agents/',
|
|
33
|
+
sparqlEndpoint: '/agents/-/sparql',
|
|
22
34
|
type: FOAF.Agent,
|
|
23
35
|
namespace: UDFS,
|
|
24
|
-
subjectTemplate: '{id}.ttl',
|
|
25
36
|
});
|
|
26
37
|
// Compatibility alias. New model code should prefer `agentResource`.
|
|
27
38
|
export const agentTable = agentResource;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AIModelInsert, AIModelRow } from '../ai-model.schema';
|
|
2
|
-
import type
|
|
2
|
+
import { type AIProviderInsert, type AIProviderRow } from '../ai-provider.schema';
|
|
3
3
|
import type { CredentialInsert, CredentialRow } from '../credential.schema';
|
|
4
4
|
export interface AIConfigProviderCatalogEntry {
|
|
5
5
|
id: string;
|
|
@@ -30,6 +30,11 @@ export interface AIConfigUpdate {
|
|
|
30
30
|
enabled?: boolean;
|
|
31
31
|
apiKey?: string;
|
|
32
32
|
baseUrl?: string;
|
|
33
|
+
supportsBackend?: string;
|
|
34
|
+
rotationPolicy?: string;
|
|
35
|
+
credentialId?: string;
|
|
36
|
+
credentialLabel?: string;
|
|
37
|
+
credentialBaseUrl?: string;
|
|
33
38
|
models?: AIConfigModel[];
|
|
34
39
|
}
|
|
35
40
|
export interface BuildAIConfigProviderStateMapOptions {
|
|
@@ -49,6 +54,9 @@ export interface AIConfigCredentialSelection {
|
|
|
49
54
|
proxyUrl?: string;
|
|
50
55
|
isDefault: boolean;
|
|
51
56
|
}
|
|
57
|
+
export interface AIConfigBackendCredentialSelection extends AIConfigCredentialSelection {
|
|
58
|
+
backend: string;
|
|
59
|
+
}
|
|
52
60
|
export interface AIConfigMutationPlan {
|
|
53
61
|
providerId: string;
|
|
54
62
|
providerPayload?: AIProviderInsert;
|
|
@@ -67,6 +75,15 @@ export declare const LINX_LITE_MODEL_ID = "linx-lite";
|
|
|
67
75
|
export declare const LINX_MODEL_ID = "linx";
|
|
68
76
|
export declare const DEFAULT_LINX_MODEL_ID = "linx-lite";
|
|
69
77
|
export declare const UNDEFINEDS_AI_MODEL_IDS: readonly ["linx-lite", "linx"];
|
|
78
|
+
interface AIConfigRepositoryDb {
|
|
79
|
+
select(): {
|
|
80
|
+
from(resource: unknown): {
|
|
81
|
+
execute(): Promise<unknown[]>;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
findById<T = unknown>(resource: unknown, id: string): Promise<T | null>;
|
|
85
|
+
updateById(resource: unknown, id: string, data: Record<string, unknown>): Promise<unknown>;
|
|
86
|
+
}
|
|
70
87
|
export declare function getAIConfigProviderCatalog(): readonly AIConfigProviderCatalogEntry[];
|
|
71
88
|
export declare function getAIConfigProviderMetadata(providerId: string): AIConfigProviderCatalogEntry;
|
|
72
89
|
export declare function normalizeAIConfigResourceId(raw?: string | null): string;
|
|
@@ -74,11 +91,19 @@ export declare function normalizeAIConfigModelId(raw?: string | null, providerId
|
|
|
74
91
|
export declare function normalizeAIConfigProviderId(raw?: string | null): string;
|
|
75
92
|
export declare function sameAIConfigProviderFamily(left?: string | null, right?: string | null): boolean;
|
|
76
93
|
export declare function getAIConfigProviderFamilyIds(providerId: string): string[];
|
|
94
|
+
export declare function getAIConfigProviderIdsForBackend(backend: string): string[];
|
|
77
95
|
export declare function getAIConfigDefaultBaseUrl(providerId: string): string | undefined;
|
|
78
96
|
export declare function getDefaultAIConfigCredentialId(providerId: string): string;
|
|
79
97
|
export declare function aiConfigProviderRef(providerId: string): string;
|
|
80
98
|
export declare function aiConfigModelRef(providerId: string, modelId?: string): string;
|
|
81
|
-
export declare function selectAIConfigCredential(providerId: string, credentialRows: Array<Partial<CredentialRow> & Record<string, unknown>>, providerRows?: Array<Partial<AIProviderRow> & Record<string, unknown
|
|
99
|
+
export declare function selectAIConfigCredential(providerId: string, credentialRows: Array<Partial<CredentialRow> & Record<string, unknown>>, providerRows?: Array<Partial<AIProviderRow> & Record<string, unknown>>, options?: {
|
|
100
|
+
rotationPolicy?: string;
|
|
101
|
+
}): AIConfigCredentialSelection | undefined;
|
|
102
|
+
export declare function selectAIConfigCredentialForBackend(backend: string, credentialRows: Array<Partial<CredentialRow> & Record<string, unknown>>, providerRows?: Array<Partial<AIProviderRow> & Record<string, unknown>>): AIConfigBackendCredentialSelection | undefined;
|
|
103
|
+
export declare const aiConfigRepository: {
|
|
104
|
+
loadCredentialForBackend(db: AIConfigRepositoryDb, backend: string): Promise<AIConfigBackendCredentialSelection | undefined>;
|
|
105
|
+
markCredentialUsed(db: AIConfigRepositoryDb, selection: Pick<AIConfigCredentialSelection, "credentialId"> | undefined, usedAt?: Date): Promise<void>;
|
|
106
|
+
};
|
|
82
107
|
export declare function aiConfigProviderUri(providerId: string): string;
|
|
83
108
|
export declare function aiConfigModelUri(modelId: string, providerId?: string): string;
|
|
84
109
|
export declare function buildAIConfigProviderStateMap(options: BuildAIConfigProviderStateMapOptions): Record<string, AIConfigProviderState>;
|
|
@@ -93,3 +118,4 @@ export declare function buildAIConfigDisconnectPlan(input: {
|
|
|
93
118
|
providerId: string;
|
|
94
119
|
currentCredentialRows: Array<Partial<CredentialRow> & Record<string, unknown>>;
|
|
95
120
|
}): AIConfigDisconnectPlan;
|
|
121
|
+
export {};
|
package/dist/ai-config/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { aiProviderResource } from '../ai-provider.schema.js';
|
|
2
|
+
import { credentialResource } from '../credential.schema.js';
|
|
1
3
|
export const UNDEFINEDS_AI_PROVIDER_ID = 'undefineds';
|
|
2
4
|
export const UNDEFINEDS_AI_PROVIDER_DISPLAY_NAME = 'undefineds';
|
|
3
5
|
export const UNDEFINEDS_AI_BASE_URL = 'https://api.undefineds.co/v1';
|
|
@@ -126,6 +128,34 @@ function normalizeOptionalTimestamp(value) {
|
|
|
126
128
|
function normalizeOptionalInteger(value) {
|
|
127
129
|
return typeof value === 'number' && Number.isFinite(value) ? value : 0;
|
|
128
130
|
}
|
|
131
|
+
function normalizeBackendId(value) {
|
|
132
|
+
return normalizeText(String(value ?? ''));
|
|
133
|
+
}
|
|
134
|
+
function normalizeRotationPolicy(value) {
|
|
135
|
+
const normalized = normalizeOptionalText(value)?.toLowerCase();
|
|
136
|
+
return normalized === 'round_robin' || normalized === 'round-robin' ? 'round_robin' : 'default';
|
|
137
|
+
}
|
|
138
|
+
function parseBackendList(value) {
|
|
139
|
+
if (Array.isArray(value)) {
|
|
140
|
+
return value.flatMap(parseBackendList);
|
|
141
|
+
}
|
|
142
|
+
if (typeof value !== 'string') {
|
|
143
|
+
return [];
|
|
144
|
+
}
|
|
145
|
+
return value
|
|
146
|
+
.split(/[\s,;|]+/u)
|
|
147
|
+
.map(normalizeBackendId)
|
|
148
|
+
.filter(Boolean);
|
|
149
|
+
}
|
|
150
|
+
function uniqueStrings(values) {
|
|
151
|
+
return Array.from(new Set(values.filter(Boolean)));
|
|
152
|
+
}
|
|
153
|
+
function aiConfigProviderSupportsBackend(row, backend) {
|
|
154
|
+
const normalizedBackend = normalizeBackendId(backend);
|
|
155
|
+
if (!normalizedBackend)
|
|
156
|
+
return false;
|
|
157
|
+
return parseBackendList(row.supportsBackend).includes(normalizedBackend);
|
|
158
|
+
}
|
|
129
159
|
export function getAIConfigProviderCatalog() {
|
|
130
160
|
return AI_CONFIG_PROVIDER_CATALOG;
|
|
131
161
|
}
|
|
@@ -202,6 +232,9 @@ export function getAIConfigProviderFamilyIds(providerId) {
|
|
|
202
232
|
const metadata = getAIConfigProviderMetadata(providerId);
|
|
203
233
|
return [metadata.id, ...(metadata.aliases ?? [])];
|
|
204
234
|
}
|
|
235
|
+
export function getAIConfigProviderIdsForBackend(backend) {
|
|
236
|
+
return getAIConfigProviderFamilyIds(backend);
|
|
237
|
+
}
|
|
205
238
|
export function getAIConfigDefaultBaseUrl(providerId) {
|
|
206
239
|
return getAIConfigProviderMetadata(providerId).defaultBaseUrl;
|
|
207
240
|
}
|
|
@@ -220,7 +253,7 @@ export function aiConfigModelRef(providerId, modelId) {
|
|
|
220
253
|
const model = normalizeAIConfigModelStorageId(modelId, provider);
|
|
221
254
|
return provider && model ? `/settings/providers/${provider}.ttl#${model}` : model;
|
|
222
255
|
}
|
|
223
|
-
export function selectAIConfigCredential(providerId, credentialRows, providerRows = []) {
|
|
256
|
+
export function selectAIConfigCredential(providerId, credentialRows, providerRows = [], options = {}) {
|
|
224
257
|
const provider = normalizeAIConfigProviderId(providerId);
|
|
225
258
|
if (!provider)
|
|
226
259
|
return undefined;
|
|
@@ -245,9 +278,12 @@ export function selectAIConfigCredential(providerId, credentialRows, providerRow
|
|
|
245
278
|
return normalizeAIConfigResourceId(String(left.id ?? left['@id'] ?? ''))
|
|
246
279
|
.localeCompare(normalizeAIConfigResourceId(String(right.id ?? right['@id'] ?? '')));
|
|
247
280
|
};
|
|
248
|
-
const defaults = candidates.filter((row) => normalizeOptionalBoolean(row.isDefault));
|
|
249
|
-
const credential = [...(defaults.length > 0 ? defaults : candidates)].sort(sortByRotation)[0];
|
|
250
281
|
const providerRow = providerRows.find((row) => sameAIConfigProviderFamily(aiConfigProviderRowId(row), provider));
|
|
282
|
+
const rotationPolicy = normalizeRotationPolicy(options.rotationPolicy ?? providerRow?.rotationPolicy);
|
|
283
|
+
const defaults = rotationPolicy === 'round_robin'
|
|
284
|
+
? []
|
|
285
|
+
: candidates.filter((row) => normalizeOptionalBoolean(row.isDefault));
|
|
286
|
+
const credential = [...(defaults.length > 0 ? defaults : candidates)].sort(sortByRotation)[0];
|
|
251
287
|
const apiKey = normalizeOptionalText(credential.apiKey);
|
|
252
288
|
if (!apiKey)
|
|
253
289
|
return undefined;
|
|
@@ -264,6 +300,91 @@ export function selectAIConfigCredential(providerId, credentialRows, providerRow
|
|
|
264
300
|
isDefault: normalizeOptionalBoolean(credential.isDefault),
|
|
265
301
|
};
|
|
266
302
|
}
|
|
303
|
+
export function selectAIConfigCredentialForBackend(backend, credentialRows, providerRows = []) {
|
|
304
|
+
const normalizedBackend = normalizeBackendId(backend);
|
|
305
|
+
if (!normalizedBackend)
|
|
306
|
+
return undefined;
|
|
307
|
+
const explicitProviderIds = providerRows
|
|
308
|
+
.filter((row) => aiConfigProviderSupportsBackend(row, normalizedBackend))
|
|
309
|
+
.map(aiConfigProviderRowId)
|
|
310
|
+
.filter(Boolean);
|
|
311
|
+
const familyProviderIds = getAIConfigProviderIdsForBackend(normalizedBackend);
|
|
312
|
+
const providerIds = uniqueStrings([...explicitProviderIds, ...familyProviderIds]);
|
|
313
|
+
for (const providerId of providerIds) {
|
|
314
|
+
const providerRow = providerRows.find((row) => sameAIConfigProviderFamily(aiConfigProviderRowId(row), providerId));
|
|
315
|
+
const selected = selectAIConfigCredential(providerId, credentialRows, providerRows, {
|
|
316
|
+
rotationPolicy: normalizeOptionalText(providerRow?.rotationPolicy),
|
|
317
|
+
});
|
|
318
|
+
if (!selected)
|
|
319
|
+
continue;
|
|
320
|
+
return {
|
|
321
|
+
...selected,
|
|
322
|
+
backend: normalizedBackend,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
return undefined;
|
|
326
|
+
}
|
|
327
|
+
async function listAIConfigCredentialRows(db) {
|
|
328
|
+
return await db.select().from(credentialResource).execute();
|
|
329
|
+
}
|
|
330
|
+
async function findAIConfigProviderRows(db, providerIds) {
|
|
331
|
+
const rows = [];
|
|
332
|
+
const seen = new Set();
|
|
333
|
+
for (const providerId of providerIds) {
|
|
334
|
+
for (const candidate of aiConfigProviderIdCandidates(providerId)) {
|
|
335
|
+
if (!candidate || seen.has(candidate))
|
|
336
|
+
continue;
|
|
337
|
+
seen.add(candidate);
|
|
338
|
+
const row = await db.findById(aiProviderResource, candidate)
|
|
339
|
+
.catch((error) => {
|
|
340
|
+
if (isMissingAIConfigExactReadError(error)) {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
throw error;
|
|
344
|
+
});
|
|
345
|
+
if (row) {
|
|
346
|
+
rows.push(row);
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return rows;
|
|
352
|
+
}
|
|
353
|
+
function collectAIConfigProviderIdsForBackend(backend, credentialRows) {
|
|
354
|
+
const ids = new Set(getAIConfigProviderIdsForBackend(backend));
|
|
355
|
+
for (const row of credentialRows) {
|
|
356
|
+
const providerId = aiConfigCredentialProviderId(row);
|
|
357
|
+
if (providerId)
|
|
358
|
+
ids.add(providerId);
|
|
359
|
+
}
|
|
360
|
+
return Array.from(ids);
|
|
361
|
+
}
|
|
362
|
+
function aiConfigProviderIdCandidates(providerId) {
|
|
363
|
+
const normalized = normalizeAIConfigResourceId(providerId) || providerId;
|
|
364
|
+
return uniqueStrings([
|
|
365
|
+
normalized,
|
|
366
|
+
`${normalized}.ttl`,
|
|
367
|
+
]);
|
|
368
|
+
}
|
|
369
|
+
function isMissingAIConfigExactReadError(error) {
|
|
370
|
+
if (!error || typeof error !== 'object') {
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
const message = 'message' in error && typeof error.message === 'string' ? error.message : '';
|
|
374
|
+
return /404|not found|missing/i.test(message);
|
|
375
|
+
}
|
|
376
|
+
export const aiConfigRepository = {
|
|
377
|
+
async loadCredentialForBackend(db, backend) {
|
|
378
|
+
const credentialRows = await listAIConfigCredentialRows(db);
|
|
379
|
+
const providerRows = await findAIConfigProviderRows(db, collectAIConfigProviderIdsForBackend(backend, credentialRows));
|
|
380
|
+
return selectAIConfigCredentialForBackend(backend, credentialRows, providerRows);
|
|
381
|
+
},
|
|
382
|
+
async markCredentialUsed(db, selection, usedAt = new Date()) {
|
|
383
|
+
if (!selection?.credentialId)
|
|
384
|
+
return;
|
|
385
|
+
await db.updateById(credentialResource, selection.credentialId, { lastUsedAt: usedAt });
|
|
386
|
+
},
|
|
387
|
+
};
|
|
267
388
|
// Compatibility aliases for older app/CLI call sites. New code should prefer
|
|
268
389
|
// `aiConfigProviderRef` / `aiConfigModelRef`, which match current resource schemas.
|
|
269
390
|
export function aiConfigProviderUri(providerId) {
|
|
@@ -356,15 +477,29 @@ export function buildAIConfigMutationPlan(input) {
|
|
|
356
477
|
const providerId = normalizeAIConfigProviderId(input.providerId);
|
|
357
478
|
const metadata = getAIConfigProviderMetadata(providerId);
|
|
358
479
|
const existingProvider = input.currentProviderRows.find((row) => sameAIConfigProviderFamily(aiConfigProviderRowId(row), providerId));
|
|
359
|
-
const existingCredential =
|
|
480
|
+
const existingCredential = (input.updates.credentialId
|
|
481
|
+
? input.currentCredentialRows.find((row) => normalizeAIConfigResourceId(String(row.id ?? row['@id'] ?? '')) === normalizeAIConfigResourceId(input.updates.credentialId))
|
|
482
|
+
: undefined)
|
|
483
|
+
?? selectAIConfigCredential(providerId, input.currentCredentialRows, input.currentProviderRows)?.credential
|
|
360
484
|
?? input.currentCredentialRows.find((row) => sameAIConfigProviderFamily(aiConfigCredentialProviderId(row), providerId));
|
|
361
485
|
const existingModels = input.currentModelRows.filter((row) => sameAIConfigProviderFamily(aiConfigModelProviderId(row), providerId));
|
|
362
|
-
const
|
|
486
|
+
const hasProviderUpdate = input.updates.enabled !== undefined ||
|
|
487
|
+
input.updates.apiKey !== undefined ||
|
|
488
|
+
input.updates.baseUrl !== undefined ||
|
|
489
|
+
input.updates.supportsBackend !== undefined ||
|
|
490
|
+
input.updates.rotationPolicy !== undefined ||
|
|
491
|
+
input.updates.models !== undefined;
|
|
492
|
+
const hasCredentialUpdate = input.updates.enabled !== undefined ||
|
|
493
|
+
input.updates.apiKey !== undefined ||
|
|
494
|
+
input.updates.credentialId !== undefined ||
|
|
495
|
+
input.updates.credentialLabel !== undefined ||
|
|
496
|
+
input.updates.credentialBaseUrl !== undefined ||
|
|
497
|
+
input.updates.baseUrl !== undefined;
|
|
363
498
|
let providerPayload;
|
|
364
499
|
let credentialPayload;
|
|
365
500
|
const modelUpserts = [];
|
|
366
501
|
const modelDeleteIds = [];
|
|
367
|
-
if (
|
|
502
|
+
if (hasProviderUpdate) {
|
|
368
503
|
const selectedModelId = input.updates.models
|
|
369
504
|
? preferredSelectedModelId(input.updates.models)
|
|
370
505
|
: normalizeAIConfigModelStorageId(typeof existingProvider?.hasModel === 'string' ? existingProvider.hasModel : '', providerId);
|
|
@@ -375,11 +510,16 @@ export function buildAIConfigMutationPlan(input) {
|
|
|
375
510
|
metadata.defaultBaseUrl,
|
|
376
511
|
proxyUrl: typeof existingProvider?.proxyUrl === 'string' ? existingProvider.proxyUrl : undefined,
|
|
377
512
|
hasModel: selectedModelId ? aiConfigModelRef(providerId, selectedModelId) : undefined,
|
|
513
|
+
supportsBackend: input.updates.supportsBackend ??
|
|
514
|
+
(typeof existingProvider?.supportsBackend === 'string' ? existingProvider.supportsBackend : undefined),
|
|
515
|
+
rotationPolicy: input.updates.rotationPolicy ??
|
|
516
|
+
(typeof existingProvider?.rotationPolicy === 'string' ? existingProvider.rotationPolicy : undefined),
|
|
378
517
|
};
|
|
379
518
|
}
|
|
380
|
-
if (
|
|
519
|
+
if (hasCredentialUpdate) {
|
|
381
520
|
credentialPayload = {
|
|
382
|
-
id: normalizeAIConfigResourceId(
|
|
521
|
+
id: normalizeAIConfigResourceId(input.updates.credentialId) ||
|
|
522
|
+
normalizeAIConfigResourceId(typeof existingCredential?.id === 'string' ? existingCredential.id : '') ||
|
|
383
523
|
getDefaultAIConfigCredentialId(providerId),
|
|
384
524
|
provider: aiConfigProviderRef(providerId),
|
|
385
525
|
service: typeof existingCredential?.service === 'string' && existingCredential.service ? existingCredential.service : 'ai',
|
|
@@ -392,11 +532,12 @@ export function buildAIConfigMutationPlan(input) {
|
|
|
392
532
|
: 'active',
|
|
393
533
|
apiKey: input.updates.apiKey ??
|
|
394
534
|
(typeof existingCredential?.apiKey === 'string' ? existingCredential.apiKey : undefined),
|
|
395
|
-
baseUrl: input.updates.
|
|
396
|
-
(typeof existingCredential?.baseUrl === 'string' ? existingCredential.baseUrl : undefined),
|
|
397
|
-
label:
|
|
398
|
-
|
|
399
|
-
|
|
535
|
+
baseUrl: input.updates.credentialBaseUrl ??
|
|
536
|
+
(input.updates.baseUrl !== undefined ? undefined : typeof existingCredential?.baseUrl === 'string' ? existingCredential.baseUrl : undefined),
|
|
537
|
+
label: input.updates.credentialLabel ??
|
|
538
|
+
(typeof existingCredential?.label === 'string' && existingCredential.label
|
|
539
|
+
? existingCredential.label
|
|
540
|
+
: `${metadata.displayName} Key`),
|
|
400
541
|
isDefault: existingCredential?.isDefault === undefined ? true : Boolean(existingCredential.isDefault),
|
|
401
542
|
};
|
|
402
543
|
}
|
package/dist/ai-model.schema.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { id, integer, podTable, string, timestamp, uri } from "@undefineds.co/drizzle-solid";
|
|
2
2
|
import { aiProviderResource } from "./ai-provider.schema.js";
|
|
3
|
-
import {
|
|
3
|
+
import { UDFS } from "./namespaces.js";
|
|
4
4
|
export const aiModelResource = podTable("aiModel", {
|
|
5
|
-
id: id("id"),
|
|
6
|
-
displayName: string("displayName").predicate(
|
|
7
|
-
modelType: string("modelType").predicate(
|
|
8
|
-
isProvidedBy: uri("isProvidedBy").predicate(
|
|
9
|
-
dimension: integer("dimension").predicate(
|
|
10
|
-
status: string("status").predicate(
|
|
11
|
-
createdAt: timestamp("createdAt").predicate(
|
|
12
|
-
updatedAt: timestamp("updatedAt").predicate(
|
|
5
|
+
id: id("id").default("{isProvidedBy.doc}#{key}"),
|
|
6
|
+
displayName: string("displayName").predicate(UDFS.displayName),
|
|
7
|
+
modelType: string("modelType").predicate(UDFS.modelType).default("chat"),
|
|
8
|
+
isProvidedBy: uri("isProvidedBy").predicate(UDFS.isProvidedBy).link(aiProviderResource),
|
|
9
|
+
dimension: integer("dimension").predicate(UDFS.dimension),
|
|
10
|
+
status: string("status").predicate(UDFS.status).default("active"),
|
|
11
|
+
createdAt: timestamp("createdAt").predicate(UDFS.createdAt).notNull().defaultNow(),
|
|
12
|
+
updatedAt: timestamp("updatedAt").predicate(UDFS.updatedAt).notNull().defaultNow(),
|
|
13
13
|
}, {
|
|
14
14
|
base: "/settings/providers/",
|
|
15
|
-
type:
|
|
16
|
-
namespace:
|
|
17
|
-
subjectTemplate: "{isProvidedBy|id}.ttl#{id}",
|
|
15
|
+
type: UDFS.Model,
|
|
16
|
+
namespace: UDFS,
|
|
18
17
|
});
|
|
19
18
|
// Compatibility alias. New model code should prefer `aiModelResource`.
|
|
20
19
|
export const aiModelTable = aiModelResource;
|
|
@@ -5,6 +5,8 @@ export declare const aiProviderResource: import("@undefineds.co/drizzle-solid/di
|
|
|
5
5
|
proxyUrl: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
6
6
|
hasModel: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
7
7
|
defaultModel: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
8
|
+
supportsBackend: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
9
|
+
rotationPolicy: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
8
10
|
}>>;
|
|
9
11
|
export declare const aiProviderTable: import("@undefineds.co/drizzle-solid/dist/core/schema").PodTableWithColumns<import("@undefineds.co/drizzle-solid/dist/core/schema").ResolvedColumns<{
|
|
10
12
|
id: import("@undefineds.co/drizzle-solid/dist/core/schema").PodStringColumn<false, false>;
|
|
@@ -13,6 +15,8 @@ export declare const aiProviderTable: import("@undefineds.co/drizzle-solid/dist/
|
|
|
13
15
|
proxyUrl: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
14
16
|
hasModel: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
15
17
|
defaultModel: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
18
|
+
supportsBackend: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
19
|
+
rotationPolicy: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
16
20
|
}>>;
|
|
17
21
|
export type AIProviderRow = typeof aiProviderResource.$inferSelect;
|
|
18
22
|
export type AIProviderInsert = typeof aiProviderResource.$inferInsert;
|