@undefineds.co/models 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +578 -0
- package/dist/_drizzle-solid/columns.d.ts +37 -0
- package/dist/_drizzle-solid/columns.js +1 -0
- package/dist/_drizzle-solid/pod-table.d.ts +3 -0
- package/dist/_drizzle-solid/pod-table.js +1 -0
- package/dist/_drizzle-solid/types.d.ts +40 -0
- package/dist/_drizzle-solid/types.js +1 -0
- package/dist/agent.providers.d.ts +13 -0
- package/dist/agent.providers.js +69 -0
- package/dist/agent.repository.d.ts +85 -0
- package/dist/agent.repository.js +7 -0
- package/dist/agent.schema.d.ts +1 -0
- package/dist/agent.schema.js +1 -0
- package/dist/ai-config/index.d.ts +61 -0
- package/dist/ai-config/index.js +294 -0
- package/dist/ai-config.d.ts +1 -0
- package/dist/ai-config.js +1 -0
- package/dist/ai-model.schema.d.ts +1 -0
- package/dist/ai-model.schema.js +1 -0
- package/dist/ai-provider.schema.d.ts +1 -0
- package/dist/ai-provider.schema.js +1 -0
- package/dist/approval.schema.d.ts +1 -0
- package/dist/approval.schema.js +1 -0
- package/dist/audit.schema.d.ts +1 -0
- package/dist/audit.schema.js +1 -0
- package/dist/chat.repository.d.ts +61 -0
- package/dist/chat.repository.js +8 -0
- package/dist/chat.schema.d.ts +1 -0
- package/dist/chat.schema.js +1 -0
- package/dist/chat.utils.d.ts +3 -0
- package/dist/chat.utils.js +30 -0
- package/dist/contact.repository.d.ts +85 -0
- package/dist/contact.repository.js +8 -0
- package/dist/contact.schema.d.ts +1 -0
- package/dist/contact.schema.js +1 -0
- package/dist/core/agent-provider.schema.d.ts +1 -0
- package/dist/core/agent-provider.schema.js +1 -0
- package/dist/core/agent-status.schema.d.ts +12 -0
- package/dist/core/agent-status.schema.js +18 -0
- package/dist/core/agent.schema.d.ts +72 -0
- package/dist/core/agent.schema.js +38 -0
- package/dist/core/ai-config.schema.d.ts +11 -0
- package/dist/core/ai-config.schema.js +18 -0
- package/dist/core/ai-model.schema.d.ts +15 -0
- package/dist/core/ai-model.schema.js +21 -0
- package/dist/core/ai-provider.schema.d.ts +16 -0
- package/dist/core/ai-provider.schema.js +28 -0
- package/dist/core/approval.schema.d.ts +21 -0
- package/dist/core/approval.schema.js +33 -0
- package/dist/core/audit.schema.d.ts +17 -0
- package/dist/core/audit.schema.js +29 -0
- package/dist/core/chat.schema.d.ts +36 -0
- package/dist/core/chat.schema.js +45 -0
- package/dist/core/contact.schema.d.ts +47 -0
- package/dist/core/contact.schema.js +59 -0
- package/dist/core/credential.schema.d.ts +56 -0
- package/dist/core/credential.schema.js +40 -0
- package/dist/core/extension/extension.schema.d.ts +4 -0
- package/dist/core/extension/extension.schema.js +11 -0
- package/dist/core/extension/index.d.ts +1 -0
- package/dist/core/extension/index.js +1 -0
- package/dist/core/extension.d.ts +1 -0
- package/dist/core/extension.js +1 -0
- package/dist/core/favorite/favorite.schema.d.ts +24 -0
- package/dist/core/favorite/favorite.schema.js +34 -0
- package/dist/core/favorite/index.d.ts +1 -0
- package/dist/core/favorite/index.js +1 -0
- package/dist/core/file/file.schema.d.ts +39 -0
- package/dist/core/file/file.schema.js +51 -0
- package/dist/core/file/index.d.ts +1 -0
- package/dist/core/file/index.js +1 -0
- package/dist/core/file.d.ts +1 -0
- package/dist/core/file.js +1 -0
- package/dist/core/grant.schema.d.ts +16 -0
- package/dist/core/grant.schema.js +29 -0
- package/dist/core/import/import-job.schema.d.ts +5 -0
- package/dist/core/import/import-job.schema.js +5 -0
- package/dist/core/import/index.d.ts +1 -0
- package/dist/core/import/index.js +1 -0
- package/dist/core/import.d.ts +1 -0
- package/dist/core/import.js +1 -0
- package/dist/core/inbox-notification.schema.d.ts +9 -0
- package/dist/core/inbox-notification.schema.js +16 -0
- package/dist/core/index.d.ts +31 -0
- package/dist/core/index.js +32 -0
- package/dist/core/knowledge/index.d.ts +1 -0
- package/dist/core/knowledge/index.js +1 -0
- package/dist/core/knowledge/knowledge-folder.schema.d.ts +7 -0
- package/dist/core/knowledge/knowledge-folder.schema.js +6 -0
- package/dist/core/knowledge.d.ts +1 -0
- package/dist/core/knowledge.js +1 -0
- package/dist/core/message.schema.d.ts +33 -0
- package/dist/core/message.schema.js +49 -0
- package/dist/core/namespaces.d.ts +176 -0
- package/dist/core/namespaces.js +289 -0
- package/dist/core/profile.d.ts +16 -0
- package/dist/core/profile.js +19 -0
- package/dist/core/schema.d.ts +304 -0
- package/dist/core/schema.js +46 -0
- package/dist/core/session/index.d.ts +1 -0
- package/dist/core/session/index.js +1 -0
- package/dist/core/session/session.schema.d.ts +6 -0
- package/dist/core/session/session.schema.js +6 -0
- package/dist/core/session.d.ts +1 -0
- package/dist/core/session.js +1 -0
- package/dist/core/settings/index.d.ts +1 -0
- package/dist/core/settings/index.js +1 -0
- package/dist/core/settings/settings.schema.d.ts +49 -0
- package/dist/core/settings/settings.schema.js +63 -0
- package/dist/core/settings.d.ts +1 -0
- package/dist/core/settings.js +1 -0
- package/dist/core/thread.schema.d.ts +28 -0
- package/dist/core/thread.schema.js +36 -0
- package/dist/core/types/collaboration-blocks.d.ts +52 -0
- package/dist/core/types/collaboration-blocks.js +7 -0
- package/dist/core/types/message-block.d.ts +270 -0
- package/dist/core/types/message-block.js +125 -0
- package/dist/core/vector-store.schema.d.ts +25 -0
- package/dist/core/vector-store.schema.js +35 -0
- package/dist/core/vocab/_namespaces.d.ts +1 -0
- package/dist/core/vocab/_namespaces.js +3 -0
- package/dist/core/vocab/chat.vocab.d.ts +16 -0
- package/dist/core/vocab/chat.vocab.js +22 -0
- package/dist/core/vocab/contact.vocab.d.ts +21 -0
- package/dist/core/vocab/contact.vocab.js +22 -0
- package/dist/core/vocab/index.d.ts +6 -0
- package/dist/core/vocab/index.js +6 -0
- package/dist/core/vocab/message.vocab.d.ts +20 -0
- package/dist/core/vocab/message.vocab.js +24 -0
- package/dist/core/vocab/sidecar.vocab.d.ts +46 -0
- package/dist/core/vocab/sidecar.vocab.js +47 -0
- package/dist/core/vocab/thread.vocab.d.ts +11 -0
- package/dist/core/vocab/thread.vocab.js +14 -0
- package/dist/core/vocab/workspace.vocab.d.ts +12 -0
- package/dist/core/vocab/workspace.vocab.js +13 -0
- package/dist/core/vocab.d.ts +1 -0
- package/dist/core/vocab.js +1 -0
- package/dist/core/workspace.schema.d.ts +35 -0
- package/dist/core/workspace.schema.js +106 -0
- package/dist/core.d.ts +1 -0
- package/dist/core.js +1 -0
- package/dist/credential.schema.d.ts +1 -0
- package/dist/credential.schema.js +1 -0
- package/dist/discovery/index.d.ts +31 -0
- package/dist/discovery/index.js +147 -0
- package/dist/discovery/models.json +2623 -0
- package/dist/discovery/providers.json +156 -0
- package/dist/discovery/types.d.ts +103 -0
- package/dist/discovery/types.js +12 -0
- package/dist/discovery/vercel.d.ts +25 -0
- package/dist/discovery/vercel.js +95 -0
- package/dist/discovery.d.ts +1 -0
- package/dist/discovery.js +1 -0
- package/dist/extension/extension.schema.d.ts +1 -0
- package/dist/extension/extension.schema.js +1 -0
- package/dist/extension/index.d.ts +1 -0
- package/dist/extension/index.js +1 -0
- package/dist/extension.d.ts +1 -0
- package/dist/extension.js +1 -0
- package/dist/favorite/favorite.schema.d.ts +1 -0
- package/dist/favorite/favorite.schema.js +1 -0
- package/dist/favorite/index.d.ts +2 -0
- package/dist/favorite/index.js +7 -0
- package/dist/favorite/starred-sync.d.ts +66 -0
- package/dist/favorite/starred-sync.js +156 -0
- package/dist/favorite.d.ts +1 -0
- package/dist/favorite.js +1 -0
- package/dist/file/file.schema.d.ts +1 -0
- package/dist/file/file.schema.js +1 -0
- package/dist/file/index.d.ts +1 -0
- package/dist/file/index.js +1 -0
- package/dist/file.d.ts +1 -0
- package/dist/file.js +1 -0
- package/dist/fixtures/contracts-chat-contact.d.ts +13 -0
- package/dist/fixtures/contracts-chat-contact.js +76 -0
- package/dist/grant.schema.d.ts +1 -0
- package/dist/grant.schema.js +1 -0
- package/dist/import/import-job.schema.d.ts +5 -0
- package/dist/import/import-job.schema.js +5 -0
- package/dist/import/index.d.ts +1 -0
- package/dist/import/index.js +1 -0
- package/dist/import.d.ts +1 -0
- package/dist/import.js +1 -0
- package/dist/inbox-notification.schema.d.ts +1 -0
- package/dist/inbox-notification.schema.js +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +83 -0
- package/dist/knowledge/index.d.ts +1 -0
- package/dist/knowledge/index.js +1 -0
- package/dist/knowledge/knowledge-folder.schema.d.ts +1 -0
- package/dist/knowledge/knowledge-folder.schema.js +1 -0
- package/dist/knowledge.d.ts +1 -0
- package/dist/knowledge.js +1 -0
- package/dist/message.repository.d.ts +81 -0
- package/dist/message.repository.js +8 -0
- package/dist/message.schema.d.ts +1 -0
- package/dist/message.schema.js +1 -0
- package/dist/namespaces.d.ts +1 -0
- package/dist/namespaces.js +1 -0
- package/dist/profile.d.ts +1 -0
- package/dist/profile.js +1 -0
- package/dist/repository.d.ts +59 -0
- package/dist/repository.js +186 -0
- package/dist/schema.d.ts +1 -0
- package/dist/schema.js +1 -0
- package/dist/session/index.d.ts +1 -0
- package/dist/session/index.js +1 -0
- package/dist/session/session.schema.d.ts +1 -0
- package/dist/session/session.schema.js +1 -0
- package/dist/session.d.ts +1 -0
- package/dist/session.js +1 -0
- package/dist/settings/index.d.ts +1 -0
- package/dist/settings/index.js +1 -0
- package/dist/settings/settings.schema.d.ts +1 -0
- package/dist/settings/settings.schema.js +1 -0
- package/dist/settings.d.ts +1 -0
- package/dist/settings.js +1 -0
- package/dist/sidecar/index.d.ts +2 -0
- package/dist/sidecar/index.js +2 -0
- package/dist/sidecar/persistence-mapping.d.ts +51 -0
- package/dist/sidecar/persistence-mapping.js +44 -0
- package/dist/sidecar/sidecar-events.d.ts +632 -0
- package/dist/sidecar/sidecar-events.js +133 -0
- package/dist/thread.repository.d.ts +41 -0
- package/dist/thread.repository.js +8 -0
- package/dist/thread.schema.d.ts +1 -0
- package/dist/thread.schema.js +1 -0
- package/dist/types/collaboration-blocks.d.ts +52 -0
- package/dist/types/collaboration-blocks.js +7 -0
- package/dist/types/message-block.d.ts +270 -0
- package/dist/types/message-block.js +125 -0
- package/dist/vocab/_namespaces.d.ts +1 -0
- package/dist/vocab/_namespaces.js +3 -0
- package/dist/vocab/chat.vocab.d.ts +16 -0
- package/dist/vocab/chat.vocab.js +22 -0
- package/dist/vocab/contact.vocab.d.ts +21 -0
- package/dist/vocab/contact.vocab.js +22 -0
- package/dist/vocab/index.d.ts +6 -0
- package/dist/vocab/index.js +6 -0
- package/dist/vocab/message.vocab.d.ts +20 -0
- package/dist/vocab/message.vocab.js +24 -0
- package/dist/vocab/sidecar.vocab.d.ts +46 -0
- package/dist/vocab/sidecar.vocab.js +47 -0
- package/dist/vocab/thread.vocab.d.ts +11 -0
- package/dist/vocab/thread.vocab.js +14 -0
- package/dist/vocab/workspace.vocab.d.ts +12 -0
- package/dist/vocab/workspace.vocab.js +13 -0
- package/dist/vocab.d.ts +1 -0
- package/dist/vocab.js +1 -0
- package/dist/workspace.repository.d.ts +45 -0
- package/dist/workspace.repository.js +8 -0
- package/dist/workspace.schema.d.ts +1 -0
- package/dist/workspace.schema.js +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { and, like, or } from '@undefineds.co/drizzle-solid';
|
|
2
|
+
export function resolveRowId(row) {
|
|
3
|
+
if (!row)
|
|
4
|
+
return null;
|
|
5
|
+
// Try @id first (standard RDF format)
|
|
6
|
+
const subject = row['@id'] ?? row.subject;
|
|
7
|
+
if (typeof subject === 'string' && subject.length > 0)
|
|
8
|
+
return subject;
|
|
9
|
+
// Try id field
|
|
10
|
+
const id = row.id;
|
|
11
|
+
if (typeof id === 'string' && id.length > 0)
|
|
12
|
+
return id;
|
|
13
|
+
// Handle drizzle-solid insert result format: {success: true, source: 'http://...'}
|
|
14
|
+
const source = row.source;
|
|
15
|
+
if (typeof source === 'string' && source.length > 0)
|
|
16
|
+
return source;
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
export function isIriLikeIdentifier(value) {
|
|
20
|
+
return /^(?:[a-z][a-z0-9+.-]*:|\/)/i.test(value) || value.startsWith('#');
|
|
21
|
+
}
|
|
22
|
+
export function stripEntityIdentifiers(data) {
|
|
23
|
+
if (!data)
|
|
24
|
+
return {};
|
|
25
|
+
const next = {};
|
|
26
|
+
for (const [key, value] of Object.entries(data)) {
|
|
27
|
+
if (key === 'id' || key === '@id' || key === 'subject' || key === 'source')
|
|
28
|
+
continue;
|
|
29
|
+
next[key] = value;
|
|
30
|
+
}
|
|
31
|
+
return next;
|
|
32
|
+
}
|
|
33
|
+
function resolveExactTarget(input) {
|
|
34
|
+
if (typeof input === 'string') {
|
|
35
|
+
return isIriLikeIdentifier(input) ? { iri: input } : { locator: { id: input } };
|
|
36
|
+
}
|
|
37
|
+
const iri = input['@id'] ?? input.subject;
|
|
38
|
+
if (typeof iri === 'string' && iri.length > 0) {
|
|
39
|
+
return { iri };
|
|
40
|
+
}
|
|
41
|
+
return { locator: input };
|
|
42
|
+
}
|
|
43
|
+
export async function findExactRecord(db, table, target) {
|
|
44
|
+
const exact = resolveExactTarget(target);
|
|
45
|
+
return 'iri' in exact
|
|
46
|
+
? await db.findByIri(table, exact.iri)
|
|
47
|
+
: await db.findByLocator(table, exact.locator);
|
|
48
|
+
}
|
|
49
|
+
export async function updateExactRecord(db, table, target, data) {
|
|
50
|
+
const exact = resolveExactTarget(target);
|
|
51
|
+
const payload = stripEntityIdentifiers(data);
|
|
52
|
+
return 'iri' in exact
|
|
53
|
+
? await db.updateByIri(table, exact.iri, payload)
|
|
54
|
+
: await db.updateByLocator(table, exact.locator, payload);
|
|
55
|
+
}
|
|
56
|
+
export async function deleteExactRecord(db, table, target) {
|
|
57
|
+
const exact = resolveExactTarget(target);
|
|
58
|
+
return 'iri' in exact
|
|
59
|
+
? await db.deleteByIri(table, exact.iri)
|
|
60
|
+
: await db.deleteByLocator(table, exact.locator);
|
|
61
|
+
}
|
|
62
|
+
export function createRepositoryDescriptor(options) {
|
|
63
|
+
const { namespace, table, searchableFields, defaultSort, cache, } = options;
|
|
64
|
+
const searchAccessor = options.searchAccessor ?? ((filters) => {
|
|
65
|
+
const value = filters ? filters.search : undefined;
|
|
66
|
+
return typeof value === 'string' ? value : undefined;
|
|
67
|
+
});
|
|
68
|
+
const transformRow = options.transform ?? ((row) => row);
|
|
69
|
+
const invalidations = {
|
|
70
|
+
create: options.invalidations?.create ?? ['list'],
|
|
71
|
+
update: options.invalidations?.update ?? ['list', 'detail'],
|
|
72
|
+
remove: options.invalidations?.remove ?? ['list', 'detail'],
|
|
73
|
+
};
|
|
74
|
+
const resolveColumn = (field) => {
|
|
75
|
+
const column = table[field];
|
|
76
|
+
if (column)
|
|
77
|
+
return column;
|
|
78
|
+
const tableName = table.config?.name;
|
|
79
|
+
return tableName ? `${tableName}.${field}` : field;
|
|
80
|
+
};
|
|
81
|
+
const buildWhereClause = (filters) => {
|
|
82
|
+
const clauses = [];
|
|
83
|
+
const term = searchAccessor(filters)?.trim();
|
|
84
|
+
if (term && searchableFields?.length) {
|
|
85
|
+
const pattern = `%${term}%`;
|
|
86
|
+
const searchClauses = searchableFields
|
|
87
|
+
.map((field) => like(resolveColumn(field), pattern));
|
|
88
|
+
if (searchClauses.length === 1) {
|
|
89
|
+
clauses.push(searchClauses[0]);
|
|
90
|
+
}
|
|
91
|
+
else if (searchClauses.length > 1) {
|
|
92
|
+
clauses.push(or(...searchClauses));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const customFilter = options.filter?.({ table, filters });
|
|
96
|
+
if (customFilter) {
|
|
97
|
+
clauses.push(customFilter);
|
|
98
|
+
}
|
|
99
|
+
if (clauses.length === 0)
|
|
100
|
+
return undefined;
|
|
101
|
+
return clauses.length === 1 ? clauses[0] : and(...clauses);
|
|
102
|
+
};
|
|
103
|
+
const list = async (db, filters) => {
|
|
104
|
+
let query = db.select().from(table);
|
|
105
|
+
const whereClause = buildWhereClause(filters);
|
|
106
|
+
if (whereClause) {
|
|
107
|
+
query = query.where(whereClause);
|
|
108
|
+
}
|
|
109
|
+
if (defaultSort) {
|
|
110
|
+
query = query.orderBy(resolveColumn(defaultSort.field), defaultSort.direction);
|
|
111
|
+
}
|
|
112
|
+
const rows = await query.execute();
|
|
113
|
+
return rows.map((row) => transformRow(row));
|
|
114
|
+
};
|
|
115
|
+
const detail = async (db, id) => {
|
|
116
|
+
const record = await findExactRecord(db, table, id);
|
|
117
|
+
return record ? transformRow(record) : null;
|
|
118
|
+
};
|
|
119
|
+
const create = options.disableMutations?.create
|
|
120
|
+
? undefined
|
|
121
|
+
: async (db, input) => {
|
|
122
|
+
// Generate an ID if not provided
|
|
123
|
+
const inputId = input.id;
|
|
124
|
+
const generatedId = typeof inputId === 'string' && inputId.length > 0
|
|
125
|
+
? inputId
|
|
126
|
+
: crypto.randomUUID();
|
|
127
|
+
const inputWithId = { ...input, id: generatedId };
|
|
128
|
+
const result = await db.insert(table).values(inputWithId).execute();
|
|
129
|
+
// drizzle-solid returns [{success, source}] or the created row
|
|
130
|
+
const firstResult = Array.isArray(result) ? result?.[0] : result;
|
|
131
|
+
// If result is actual row data (not drizzle-solid success format), return it
|
|
132
|
+
if (firstResult && typeof firstResult === 'object' && !('success' in firstResult)) {
|
|
133
|
+
return transformRow(firstResult);
|
|
134
|
+
}
|
|
135
|
+
// Handle drizzle-solid format: {success: true, source: "http://..."}
|
|
136
|
+
const sourceUrl = firstResult && typeof firstResult === 'object' && 'source' in firstResult
|
|
137
|
+
? firstResult.source
|
|
138
|
+
: null;
|
|
139
|
+
// Return synthetic row immediately for optimistic update
|
|
140
|
+
// The real data will be fetched via invalidateQueries
|
|
141
|
+
const baseUrl = sourceUrl ? sourceUrl.replace(/\/[^/]+\.ttl$/, '') : '';
|
|
142
|
+
const syntheticId = sourceUrl
|
|
143
|
+
? `${baseUrl}/${generatedId}.ttl`
|
|
144
|
+
: generatedId;
|
|
145
|
+
return {
|
|
146
|
+
...inputWithId,
|
|
147
|
+
id: generatedId,
|
|
148
|
+
'@id': syntheticId,
|
|
149
|
+
subject: syntheticId,
|
|
150
|
+
source: sourceUrl,
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
const update = options.disableMutations?.update
|
|
154
|
+
? undefined
|
|
155
|
+
: async (db, id, input) => {
|
|
156
|
+
await updateExactRecord(db, table, id, input);
|
|
157
|
+
const next = await detail(db, id);
|
|
158
|
+
if (!next) {
|
|
159
|
+
throw new Error(`Failed to load ${namespace} record after update`);
|
|
160
|
+
}
|
|
161
|
+
return next;
|
|
162
|
+
};
|
|
163
|
+
const remove = options.disableMutations?.remove
|
|
164
|
+
? undefined
|
|
165
|
+
: async (db, id) => {
|
|
166
|
+
await deleteExactRecord(db, table, id);
|
|
167
|
+
return { id };
|
|
168
|
+
};
|
|
169
|
+
const resourcePath = typeof table.getResourcePath === 'function'
|
|
170
|
+
? table.getResourcePath()
|
|
171
|
+
: (table.config?.base ?? '');
|
|
172
|
+
return {
|
|
173
|
+
namespace,
|
|
174
|
+
resourcePath,
|
|
175
|
+
searchableFields,
|
|
176
|
+
defaultSort,
|
|
177
|
+
cache,
|
|
178
|
+
invalidations,
|
|
179
|
+
list,
|
|
180
|
+
detail,
|
|
181
|
+
create,
|
|
182
|
+
update,
|
|
183
|
+
remove,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
export const definePodRepository = createRepositoryDescriptor;
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { linxSchema } from './core.js';
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { linxSchema } from './core.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { sessionSchema } from "./session.schema.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { sessionSchema } from "./session.schema.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { sessionSchema } from '../core.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { sessionSchema } from '../core.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './session/index.js';
|
package/dist/session.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './session/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { settingsTable, SETTING_KEYS, type SettingKey, type SettingsRow, type SettingsInsert, type SettingsUpdate } from "./settings.schema.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { settingsTable, SETTING_KEYS } from "./settings.schema.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { settingsTable, SETTING_KEYS, type SettingKey, type SettingsRow, type SettingsInsert, type SettingsUpdate, } from '../core.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { settingsTable, SETTING_KEYS, } from '../core.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './settings/index.js';
|
package/dist/settings.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './settings/index.js';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ApprovalInsert, ApprovalUpdate } from '../approval.schema.js';
|
|
2
|
+
import type { AuditInsert } from '../audit.schema.js';
|
|
3
|
+
import type { GrantInsert } from '../grant.schema.js';
|
|
4
|
+
import type { InboxNotificationInsert } from '../inbox-notification.schema.js';
|
|
5
|
+
import type { ToolCallEvent, InboxApprovalEvent, SessionStateEvent } from './sidecar-events.js';
|
|
6
|
+
export type ChatSessionProjection = {
|
|
7
|
+
chatId: string;
|
|
8
|
+
sessionStatus: 'active' | 'paused' | 'completed' | 'error';
|
|
9
|
+
policy?: string;
|
|
10
|
+
policyVersion?: string;
|
|
11
|
+
};
|
|
12
|
+
export type ApprovalProjectionInsert = Pick<ApprovalInsert, 'session' | 'toolCallId' | 'toolName' | 'target' | 'action' | 'risk' | 'status' | 'policyVersion'>;
|
|
13
|
+
export type ApprovalProjectionUpdate = Partial<Pick<ApprovalUpdate, 'status' | 'assignedTo' | 'decisionBy' | 'decisionRole' | 'onBehalfOf' | 'reason' | 'policyVersion' | 'resolvedAt'>>;
|
|
14
|
+
export type AuditProjectionInsert = Pick<AuditInsert, 'action' | 'actor' | 'actorRole' | 'onBehalfOf' | 'session' | 'toolCallId' | 'approval' | 'context' | 'policy' | 'policyVersion'>;
|
|
15
|
+
export type GrantProjectionInsert = Pick<GrantInsert, 'target' | 'action' | 'effect' | 'riskCeiling' | 'decisionBy' | 'decisionRole' | 'onBehalfOf'>;
|
|
16
|
+
export type InboxNotificationProjectionInsert = Pick<InboxNotificationInsert, 'actor' | 'object'>;
|
|
17
|
+
export declare const SidecarEventToPodMapping: {
|
|
18
|
+
readonly tool_call_waiting_approval: {
|
|
19
|
+
readonly approval: "insert";
|
|
20
|
+
readonly inboxNotification: "insert";
|
|
21
|
+
readonly audit: null;
|
|
22
|
+
readonly grant: null;
|
|
23
|
+
};
|
|
24
|
+
readonly tool_call_approved_or_rejected: {
|
|
25
|
+
readonly approval: "update";
|
|
26
|
+
readonly inboxNotification: "insert";
|
|
27
|
+
readonly audit: "insert";
|
|
28
|
+
readonly grant: null;
|
|
29
|
+
};
|
|
30
|
+
readonly inbox_approval_resolved: {
|
|
31
|
+
readonly approval: "update";
|
|
32
|
+
readonly inboxNotification: "insert";
|
|
33
|
+
readonly audit: null;
|
|
34
|
+
readonly grant: null;
|
|
35
|
+
};
|
|
36
|
+
readonly session_state_terminal: {
|
|
37
|
+
readonly chat: "update";
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export declare function hasPodScope(scope: {
|
|
41
|
+
target?: string;
|
|
42
|
+
action?: string;
|
|
43
|
+
}): scope is {
|
|
44
|
+
target: string;
|
|
45
|
+
action: string;
|
|
46
|
+
};
|
|
47
|
+
export type SidecarPersistenceRuleKey = keyof typeof SidecarEventToPodMapping;
|
|
48
|
+
export declare function isToolWaitingApproval(event: ToolCallEvent): boolean;
|
|
49
|
+
export declare function isToolDecisionEvent(event: ToolCallEvent): boolean;
|
|
50
|
+
export declare function isInboxResolved(event: InboxApprovalEvent): boolean;
|
|
51
|
+
export declare function isSessionTerminal(event: SessionStateEvent): boolean;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export const SidecarEventToPodMapping = {
|
|
2
|
+
// tool.call
|
|
3
|
+
tool_call_waiting_approval: {
|
|
4
|
+
approval: 'insert',
|
|
5
|
+
inboxNotification: 'insert',
|
|
6
|
+
audit: null,
|
|
7
|
+
grant: null,
|
|
8
|
+
},
|
|
9
|
+
tool_call_approved_or_rejected: {
|
|
10
|
+
approval: 'update',
|
|
11
|
+
inboxNotification: 'insert',
|
|
12
|
+
audit: 'insert',
|
|
13
|
+
grant: null,
|
|
14
|
+
},
|
|
15
|
+
// inbox.approval
|
|
16
|
+
inbox_approval_resolved: {
|
|
17
|
+
approval: 'update',
|
|
18
|
+
inboxNotification: 'insert',
|
|
19
|
+
audit: null,
|
|
20
|
+
grant: null,
|
|
21
|
+
},
|
|
22
|
+
// session.state
|
|
23
|
+
session_state_terminal: {
|
|
24
|
+
chat: 'update',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
// Projection helpers (pure, no DB calls)
|
|
28
|
+
// NOTE: CP0 scope is Pod-only. Only project events that provide a concrete ODRL target/action.
|
|
29
|
+
export function hasPodScope(scope) {
|
|
30
|
+
return typeof scope.target === 'string' && scope.target.length > 0 && typeof scope.action === 'string' && scope.action.length > 0;
|
|
31
|
+
}
|
|
32
|
+
// Optional helpers for downstream implementers (pure, no DB calls)
|
|
33
|
+
export function isToolWaitingApproval(event) {
|
|
34
|
+
return event.type === 'tool.call' && event.status === 'waiting_approval';
|
|
35
|
+
}
|
|
36
|
+
export function isToolDecisionEvent(event) {
|
|
37
|
+
return event.type === 'tool.call' && (event.status === 'approved' || event.status === 'rejected');
|
|
38
|
+
}
|
|
39
|
+
export function isInboxResolved(event) {
|
|
40
|
+
return event.type === 'inbox.approval' && event.status !== 'pending';
|
|
41
|
+
}
|
|
42
|
+
export function isSessionTerminal(event) {
|
|
43
|
+
return event.type === 'session.state' && (event.status === 'completed' || event.status === 'error');
|
|
44
|
+
}
|