@undefineds.co/models 0.2.26 → 0.2.28
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 +12 -0
- package/dist/approval.schema.js +2 -1
- package/dist/audit.schema.js +2 -1
- package/dist/bin/udfs.d.ts +2 -0
- package/dist/bin/udfs.js +430 -0
- package/dist/chat.repository.d.ts +8 -0
- package/dist/chat.schema.d.ts +10 -0
- package/dist/chat.schema.js +9 -2
- package/dist/chat.utils.js +24 -9
- package/dist/index.d.ts +7 -3
- package/dist/index.js +7 -3
- package/dist/message.repository.d.ts +29 -9
- package/dist/message.schema.d.ts +29 -6
- package/dist/message.schema.js +26 -10
- package/dist/namespaces.js +23 -0
- package/dist/pod-storage-descriptor.d.ts +189 -0
- package/dist/pod-storage-descriptor.js +283 -0
- package/dist/repository.d.ts +2 -0
- package/dist/repository.js +3 -0
- package/dist/resource-id-defaults.d.ts +18 -0
- package/dist/resource-id-defaults.js +84 -0
- package/dist/run.schema.d.ts +112 -0
- package/dist/run.schema.js +89 -0
- package/dist/schema.d.ts +132 -8
- package/dist/schema.js +8 -0
- package/dist/session/session.schema.js +2 -1
- package/dist/sidecar/sidecar-events.d.ts +36 -36
- package/dist/task.schema.d.ts +62 -0
- package/dist/task.schema.js +49 -0
- package/dist/thread.repository.d.ts +15 -3
- package/dist/thread.schema.d.ts +14 -2
- package/dist/thread.schema.js +13 -5
- package/package.json +25 -3
- package/skills/README.md +41 -0
- package/skills/solid-modeling/SKILL.md +185 -0
- package/skills/solid-modeling/agents/openai.yaml +6 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { XPOD_CREDENTIAL } from './namespaces.js';
|
|
2
|
+
export const credentialDescriptor = {
|
|
3
|
+
uri: XPOD_CREDENTIAL.Credential,
|
|
4
|
+
version: '1.0.0',
|
|
5
|
+
source: 'official',
|
|
6
|
+
trustLevel: 'high',
|
|
7
|
+
namespace: XPOD_CREDENTIAL.NAMESPACE,
|
|
8
|
+
class: XPOD_CREDENTIAL.Credential,
|
|
9
|
+
resourceKind: 'credential',
|
|
10
|
+
description: 'Generic credential material required by runtimes, tools, MCP servers, and providers.',
|
|
11
|
+
storage: {
|
|
12
|
+
base: '/settings/credentials.ttl',
|
|
13
|
+
resourceIdPattern: '#{id}',
|
|
14
|
+
subjectTemplate: '#{id}',
|
|
15
|
+
},
|
|
16
|
+
fields: {
|
|
17
|
+
id: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
predicate: XPOD_CREDENTIAL.term('id'),
|
|
20
|
+
required: true,
|
|
21
|
+
description: 'Local credential id.',
|
|
22
|
+
},
|
|
23
|
+
service: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
predicate: XPOD_CREDENTIAL.service,
|
|
26
|
+
required: true,
|
|
27
|
+
description: 'Credential service grouping, for example ai or infra.',
|
|
28
|
+
},
|
|
29
|
+
providerId: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
predicate: XPOD_CREDENTIAL.provider,
|
|
32
|
+
required: true,
|
|
33
|
+
description: 'Provider identifier such as openai or cloudflare.',
|
|
34
|
+
},
|
|
35
|
+
secretType: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
predicate: XPOD_CREDENTIAL.term('secretType'),
|
|
38
|
+
required: true,
|
|
39
|
+
description: 'Provider-specific secret kind such as api-key or tunnel-token.',
|
|
40
|
+
},
|
|
41
|
+
label: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
predicate: XPOD_CREDENTIAL.label,
|
|
44
|
+
description: 'User-facing credential label.',
|
|
45
|
+
},
|
|
46
|
+
apiKey: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
predicate: XPOD_CREDENTIAL.apiKey,
|
|
49
|
+
secret: true,
|
|
50
|
+
description: 'Secret token or API key material.',
|
|
51
|
+
},
|
|
52
|
+
status: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
predicate: XPOD_CREDENTIAL.status,
|
|
55
|
+
description: 'Credential health status.',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
uniqueBy: ['service', 'providerId', 'secretType'],
|
|
59
|
+
writableFields: ['label', 'apiKey', 'status'],
|
|
60
|
+
mergePolicy: 'upsert',
|
|
61
|
+
examples: [
|
|
62
|
+
{
|
|
63
|
+
request: '保存 Cloudflare tunnel token',
|
|
64
|
+
match: {
|
|
65
|
+
service: 'infra',
|
|
66
|
+
providerId: 'cloudflare',
|
|
67
|
+
secretType: 'tunnel-token',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
request: '保存 OpenAI API key',
|
|
72
|
+
match: {
|
|
73
|
+
service: 'ai',
|
|
74
|
+
providerId: 'openai',
|
|
75
|
+
secretType: 'api-key',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
};
|
|
80
|
+
export const officialPodModelDescriptors = [credentialDescriptor];
|
|
81
|
+
export function createPodModelDescriptorRegistry(descriptors = officialPodModelDescriptors) {
|
|
82
|
+
const byUri = new Map(descriptors.map((descriptor) => [descriptor.uri, descriptor]));
|
|
83
|
+
return {
|
|
84
|
+
list(filter = {}) {
|
|
85
|
+
return descriptors.filter((descriptor) => {
|
|
86
|
+
if (filter.source && descriptor.source !== filter.source)
|
|
87
|
+
return false;
|
|
88
|
+
if (filter.resourceKind && descriptor.resourceKind !== filter.resourceKind)
|
|
89
|
+
return false;
|
|
90
|
+
return true;
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
describe(uri) {
|
|
94
|
+
return byUri.get(uri) ?? null;
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export const podSchema = createPodSchema();
|
|
99
|
+
export function createPodSchema(registry = createPodModelDescriptorRegistry()) {
|
|
100
|
+
const resolveDescriptors = (input = {}) => {
|
|
101
|
+
const uri = input.uri ?? input.schemaUri;
|
|
102
|
+
if (!uri)
|
|
103
|
+
return registry.list();
|
|
104
|
+
const descriptor = registry.describe(uri);
|
|
105
|
+
return descriptor ? [descriptor] : [];
|
|
106
|
+
};
|
|
107
|
+
return {
|
|
108
|
+
list: registry.list,
|
|
109
|
+
describe(uriOrInput) {
|
|
110
|
+
const uri = typeof uriOrInput === 'string'
|
|
111
|
+
? uriOrInput
|
|
112
|
+
: 'uri' in uriOrInput
|
|
113
|
+
? uriOrInput.uri
|
|
114
|
+
: uriOrInput.schemaUri;
|
|
115
|
+
return registry.describe(uri);
|
|
116
|
+
},
|
|
117
|
+
classes(input = {}) {
|
|
118
|
+
return resolveDescriptors(input).map((descriptor) => ({
|
|
119
|
+
schemaUri: descriptor.uri,
|
|
120
|
+
resourceKind: descriptor.resourceKind,
|
|
121
|
+
class: descriptor.class,
|
|
122
|
+
namespace: descriptor.namespace,
|
|
123
|
+
source: descriptor.source,
|
|
124
|
+
trustLevel: descriptor.trustLevel,
|
|
125
|
+
description: descriptor.description,
|
|
126
|
+
}));
|
|
127
|
+
},
|
|
128
|
+
search(input) {
|
|
129
|
+
const terms = normalizeSearchTerms(input.query);
|
|
130
|
+
if (terms.length === 0)
|
|
131
|
+
return [];
|
|
132
|
+
return registry.list({
|
|
133
|
+
source: input.source,
|
|
134
|
+
resourceKind: input.resourceKind,
|
|
135
|
+
})
|
|
136
|
+
.map((descriptor) => scoreDescriptorSearch(descriptor, terms))
|
|
137
|
+
.filter((entry) => entry !== null)
|
|
138
|
+
.sort((a, b) => b.score - a.score || a.uri.localeCompare(b.uri))
|
|
139
|
+
.slice(0, Math.max(1, input.limit ?? 10));
|
|
140
|
+
},
|
|
141
|
+
predicates(input = {}) {
|
|
142
|
+
return resolveDescriptors(input).flatMap((descriptor) => (Object.entries(descriptor.fields)
|
|
143
|
+
.filter(([field]) => !input.field || field === input.field)
|
|
144
|
+
.map(([field, descriptorField]) => ({
|
|
145
|
+
schemaUri: descriptor.uri,
|
|
146
|
+
field,
|
|
147
|
+
predicate: descriptorField.predicate,
|
|
148
|
+
type: descriptorField.type,
|
|
149
|
+
required: Boolean(descriptorField.required),
|
|
150
|
+
secret: Boolean(descriptorField.secret),
|
|
151
|
+
array: Boolean(descriptorField.array),
|
|
152
|
+
description: descriptorField.description,
|
|
153
|
+
}))));
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
export function createPodStorage(registry = createPodModelDescriptorRegistry(), store = new Map()) {
|
|
158
|
+
const plans = new Map();
|
|
159
|
+
return {
|
|
160
|
+
validate(input) {
|
|
161
|
+
const schemaUri = input.schemaUri;
|
|
162
|
+
if (!schemaUri)
|
|
163
|
+
return invalid('schema_uri_required', 'Missing schemaUri');
|
|
164
|
+
const descriptor = registry.describe(schemaUri);
|
|
165
|
+
if (!descriptor)
|
|
166
|
+
return invalid('descriptor_not_found', `Descriptor not found: ${schemaUri}`);
|
|
167
|
+
if (input.operation !== 'upsert')
|
|
168
|
+
return invalid('unsupported_operation', `Unsupported operation: ${input.operation}`);
|
|
169
|
+
const missingKeys = descriptor.uniqueBy.filter((field) => !input.match[field]);
|
|
170
|
+
if (missingKeys.length > 0) {
|
|
171
|
+
return invalid('missing_match_fields', `Missing match fields: ${missingKeys.join(', ')}`);
|
|
172
|
+
}
|
|
173
|
+
const set = input.set ?? {};
|
|
174
|
+
const invalidSetFields = Object.keys(set).filter((field) => !descriptor.writableFields.includes(field));
|
|
175
|
+
if (invalidSetFields.length > 0) {
|
|
176
|
+
return invalid('invalid_set_fields', `Fields are not writable: ${invalidSetFields.join(', ')}`);
|
|
177
|
+
}
|
|
178
|
+
const resourceId = buildResourceId(descriptor, input.match);
|
|
179
|
+
const plan = {
|
|
180
|
+
id: `plan_${resourceId.replace(/[^a-zA-Z0-9_.-]+/g, '-')}`,
|
|
181
|
+
schemaUri: descriptor.uri,
|
|
182
|
+
operation: input.operation,
|
|
183
|
+
resourceId,
|
|
184
|
+
resourceUri: buildResourceUri(descriptor, resourceId),
|
|
185
|
+
match: input.match,
|
|
186
|
+
set,
|
|
187
|
+
summary: `Upsert ${descriptor.resourceKind} for ${descriptor.uniqueBy.map((field) => input.match[field]).join('/')}`,
|
|
188
|
+
};
|
|
189
|
+
plans.set(plan.id, plan);
|
|
190
|
+
return { ok: true, plan };
|
|
191
|
+
},
|
|
192
|
+
commit(input) {
|
|
193
|
+
const plan = plans.get(input.planId);
|
|
194
|
+
if (!plan)
|
|
195
|
+
return invalid('plan_not_found', `Plan not found: ${input.planId}`);
|
|
196
|
+
const existing = store.get(plan.resourceUri) ?? {};
|
|
197
|
+
const resource = {
|
|
198
|
+
...existing,
|
|
199
|
+
...plan.match,
|
|
200
|
+
...plan.set,
|
|
201
|
+
schemaUri: plan.schemaUri,
|
|
202
|
+
resourceId: plan.resourceId,
|
|
203
|
+
resourceUri: plan.resourceUri,
|
|
204
|
+
};
|
|
205
|
+
store.set(plan.resourceUri, resource);
|
|
206
|
+
return { ok: true, resource };
|
|
207
|
+
},
|
|
208
|
+
read(input) {
|
|
209
|
+
const resource = store.get(input.resourceUri);
|
|
210
|
+
if (!resource)
|
|
211
|
+
return invalid('resource_not_found', `Resource not found: ${input.resourceUri}`);
|
|
212
|
+
return { ok: true, resource };
|
|
213
|
+
},
|
|
214
|
+
store,
|
|
215
|
+
plans,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
function invalid(code, message) {
|
|
219
|
+
return {
|
|
220
|
+
ok: false,
|
|
221
|
+
error: { code, message },
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function buildResourceId(descriptor, match) {
|
|
225
|
+
const raw = descriptor.uniqueBy.map((field) => String(match[field])).join('-');
|
|
226
|
+
const localId = raw.replace(/[^a-zA-Z0-9_.-]+/g, '-');
|
|
227
|
+
return descriptor.storage.resourceIdPattern.replace('{id}', localId);
|
|
228
|
+
}
|
|
229
|
+
function buildResourceUri(descriptor, resourceId) {
|
|
230
|
+
return `${descriptor.storage.base}${resourceId}`;
|
|
231
|
+
}
|
|
232
|
+
function normalizeSearchTerms(query) {
|
|
233
|
+
return query
|
|
234
|
+
.toLowerCase()
|
|
235
|
+
.split(/[\s,;:/#._-]+/u)
|
|
236
|
+
.map((term) => term.trim())
|
|
237
|
+
.filter(Boolean);
|
|
238
|
+
}
|
|
239
|
+
function scoreDescriptorSearch(descriptor, terms) {
|
|
240
|
+
const matchedFields = new Set();
|
|
241
|
+
let score = 0;
|
|
242
|
+
const match = (field, value, weight) => {
|
|
243
|
+
if (!value)
|
|
244
|
+
return;
|
|
245
|
+
const normalized = value.toLowerCase();
|
|
246
|
+
for (const term of terms) {
|
|
247
|
+
if (!normalized.includes(term))
|
|
248
|
+
continue;
|
|
249
|
+
matchedFields.add(field);
|
|
250
|
+
score += weight;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
match('uri', descriptor.uri, 10);
|
|
254
|
+
match('class', descriptor.class, 10);
|
|
255
|
+
match('namespace', descriptor.namespace, 4);
|
|
256
|
+
match('resourceKind', descriptor.resourceKind, 8);
|
|
257
|
+
match('description', descriptor.description, 4);
|
|
258
|
+
match('storage', `${descriptor.storage.base}${descriptor.storage.resourceIdPattern}`, 3);
|
|
259
|
+
for (const [fieldName, field] of Object.entries(descriptor.fields)) {
|
|
260
|
+
match(`field:${fieldName}`, fieldName, 6);
|
|
261
|
+
match(`predicate:${fieldName}`, field.predicate, 6);
|
|
262
|
+
match(`description:${fieldName}`, field.description, 3);
|
|
263
|
+
}
|
|
264
|
+
for (const example of descriptor.examples) {
|
|
265
|
+
match('example', example.request, 3);
|
|
266
|
+
for (const [fieldName, value] of Object.entries(example.match)) {
|
|
267
|
+
match(`example:${fieldName}`, String(value), 3);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (score <= 0)
|
|
271
|
+
return null;
|
|
272
|
+
return {
|
|
273
|
+
uri: descriptor.uri,
|
|
274
|
+
resourceKind: descriptor.resourceKind,
|
|
275
|
+
class: descriptor.class,
|
|
276
|
+
namespace: descriptor.namespace,
|
|
277
|
+
source: descriptor.source,
|
|
278
|
+
trustLevel: descriptor.trustLevel,
|
|
279
|
+
description: descriptor.description,
|
|
280
|
+
score,
|
|
281
|
+
matchedFields: [...matchedFields].sort(),
|
|
282
|
+
};
|
|
283
|
+
}
|
package/dist/repository.d.ts
CHANGED
|
@@ -4,3 +4,5 @@ export { initSolidTables };
|
|
|
4
4
|
export type { AnyPodTable };
|
|
5
5
|
export declare const initSolidResources: typeof initSolidTables;
|
|
6
6
|
export type AnyPodResource = AnyPodTable;
|
|
7
|
+
type PodResourceTemplateTarget = Parameters<typeof import('@undefineds.co/drizzle-solid').extractPodResourceTemplateValue>[0];
|
|
8
|
+
export declare function asPodResourceTemplateTarget(resource: AnyPodResource): PodResourceTemplateTarget;
|
package/dist/repository.js
CHANGED
|
@@ -4,3 +4,6 @@ export { initSolidTables };
|
|
|
4
4
|
// Resource-first aliases for shared Solid model call sites. The underlying
|
|
5
5
|
// drizzle-solid API still uses table-shaped arguments for compatibility.
|
|
6
6
|
export const initSolidResources = initSolidTables;
|
|
7
|
+
export function asPodResourceTemplateTarget(resource) {
|
|
8
|
+
return resource;
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type CommandKind = 'chat' | 'task';
|
|
2
|
+
export type DateInput = Date | string | number | null | undefined;
|
|
3
|
+
export interface DateParts {
|
|
4
|
+
yyyy: string;
|
|
5
|
+
MM: string;
|
|
6
|
+
dd: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function dateParts(value?: DateInput): DateParts;
|
|
9
|
+
export declare function resourceKey(key: string | undefined, prefix: string): string;
|
|
10
|
+
export declare function parentDir(id: string | null | undefined): string | null;
|
|
11
|
+
export declare function surfaceIdFromCommandResourceId(id: string | null | undefined): string | null;
|
|
12
|
+
export declare function commandKindFromResourceId(id: string | null | undefined): CommandKind | null;
|
|
13
|
+
export declare function chatResourceId(key?: string): string;
|
|
14
|
+
export declare function taskResourceId(key?: string): string;
|
|
15
|
+
export declare function threadResourceId(key: string | undefined, row?: Record<string, unknown>): string;
|
|
16
|
+
export declare function messageResourceId(key: string | undefined, row?: Record<string, unknown>): string;
|
|
17
|
+
export declare function runResourceId(key: string | undefined, row?: Record<string, unknown>): string;
|
|
18
|
+
export declare function runStepResourceId(key: string | undefined, row?: Record<string, unknown>): string;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export function dateParts(value) {
|
|
2
|
+
const date = value instanceof Date
|
|
3
|
+
? value
|
|
4
|
+
: typeof value === 'string' || typeof value === 'number'
|
|
5
|
+
? new Date(typeof value === 'number' && Math.abs(value) < 100000000000 ? value * 1000 : value)
|
|
6
|
+
: new Date();
|
|
7
|
+
const safeDate = Number.isFinite(date.getTime()) ? date : new Date();
|
|
8
|
+
return {
|
|
9
|
+
yyyy: String(safeDate.getUTCFullYear()),
|
|
10
|
+
MM: String(safeDate.getUTCMonth() + 1).padStart(2, '0'),
|
|
11
|
+
dd: String(safeDate.getUTCDate()).padStart(2, '0'),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export function resourceKey(key, prefix) {
|
|
15
|
+
return key && key.length > 0
|
|
16
|
+
? key
|
|
17
|
+
: `${prefix}_${Math.random().toString(36).slice(2, 12)}`;
|
|
18
|
+
}
|
|
19
|
+
export function parentDir(id) {
|
|
20
|
+
if (!id)
|
|
21
|
+
return null;
|
|
22
|
+
const hashless = id.split('#')[0] ?? id;
|
|
23
|
+
const parts = hashless.split('/').filter(Boolean);
|
|
24
|
+
if (parts.length <= 1)
|
|
25
|
+
return null;
|
|
26
|
+
return parts.slice(0, -1).join('/');
|
|
27
|
+
}
|
|
28
|
+
export function surfaceIdFromCommandResourceId(id) {
|
|
29
|
+
if (!id)
|
|
30
|
+
return null;
|
|
31
|
+
const match = id.match(/^(chat|task)\/([^/]+)\//);
|
|
32
|
+
return match ? decodeURIComponent(match[2]) : null;
|
|
33
|
+
}
|
|
34
|
+
export function commandKindFromResourceId(id) {
|
|
35
|
+
if (!id)
|
|
36
|
+
return null;
|
|
37
|
+
const match = id.match(/^(chat|task)\//);
|
|
38
|
+
return match?.[1] === 'task' ? 'task' : match?.[1] === 'chat' ? 'chat' : null;
|
|
39
|
+
}
|
|
40
|
+
export function chatResourceId(key) {
|
|
41
|
+
return `${resourceKey(key, 'chat')}/index.ttl#this`;
|
|
42
|
+
}
|
|
43
|
+
export function taskResourceId(key) {
|
|
44
|
+
return `index.ttl#${resourceKey(key, 'task')}`;
|
|
45
|
+
}
|
|
46
|
+
export function threadResourceId(key, row) {
|
|
47
|
+
const localKey = resourceKey(key, 'thread');
|
|
48
|
+
const commandKind = row?.commandKind === 'task' ? 'task' : 'chat';
|
|
49
|
+
const surfaceId = typeof row?.surfaceId === 'string' && row.surfaceId.length > 0
|
|
50
|
+
? row.surfaceId
|
|
51
|
+
: surfaceIdFromCommandResourceId(typeof row?.id === 'string' ? row.id : undefined) ?? 'default';
|
|
52
|
+
return `${commandKind}/${surfaceId}/index.ttl#${localKey}`;
|
|
53
|
+
}
|
|
54
|
+
export function messageResourceId(key, row) {
|
|
55
|
+
const localKey = resourceKey(key, 'msg');
|
|
56
|
+
const commandKind = row?.commandKind === 'task' ? 'task' : 'chat';
|
|
57
|
+
const surfaceId = typeof row?.surfaceId === 'string' && row.surfaceId.length > 0
|
|
58
|
+
? row.surfaceId
|
|
59
|
+
: surfaceIdFromCommandResourceId(typeof row?.thread === 'string' ? row.thread : undefined) ?? 'default';
|
|
60
|
+
const { yyyy, MM, dd } = dateParts(row?.createdAt);
|
|
61
|
+
return `${commandKind}/${surfaceId}/${yyyy}/${MM}/${dd}/messages.ttl#${localKey}`;
|
|
62
|
+
}
|
|
63
|
+
export function runResourceId(key, row) {
|
|
64
|
+
const localKey = resourceKey(key, 'run');
|
|
65
|
+
const commandKind = row?.commandKind === 'task' ? 'task' : 'chat';
|
|
66
|
+
const surfaceId = typeof row?.surfaceId === 'string' && row.surfaceId.length > 0
|
|
67
|
+
? row.surfaceId
|
|
68
|
+
: surfaceIdFromCommandResourceId(typeof row?.thread === 'string' ? row.thread : undefined) ?? 'default';
|
|
69
|
+
const { yyyy, MM, dd } = dateParts(row?.createdAt);
|
|
70
|
+
return `${commandKind}/${surfaceId}/${yyyy}/${MM}/${dd}/runs.ttl#${localKey}`;
|
|
71
|
+
}
|
|
72
|
+
export function runStepResourceId(key, row) {
|
|
73
|
+
const localKey = resourceKey(key, 'run-step');
|
|
74
|
+
const runId = typeof row?.runId === 'string' ? row.runId : undefined;
|
|
75
|
+
if (runId && /^(chat|task)\/[^/]+\/\d{4}\/\d{2}\/\d{2}\/runs\.ttl#[^#/]+$/.test(runId)) {
|
|
76
|
+
return `${runId.slice(0, runId.lastIndexOf('#') + 1)}${localKey}`;
|
|
77
|
+
}
|
|
78
|
+
const commandKind = row?.commandKind === 'task' ? 'task' : 'chat';
|
|
79
|
+
const surfaceId = typeof row?.surfaceId === 'string' && row.surfaceId.length > 0
|
|
80
|
+
? row.surfaceId
|
|
81
|
+
: 'default';
|
|
82
|
+
const { yyyy, MM, dd } = dateParts(row?.createdAt);
|
|
83
|
+
return `${commandKind}/${surfaceId}/${yyyy}/${MM}/${dd}/runs.ttl#${localKey}`;
|
|
84
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
export type RunStatusType = 'queued' | 'running' | 'waiting_input' | 'waiting_runner' | 'completed' | 'failed' | 'cancelled';
|
|
2
|
+
export declare const RunStatus: {
|
|
3
|
+
readonly QUEUED: "queued";
|
|
4
|
+
readonly RUNNING: "running";
|
|
5
|
+
readonly WAITING_INPUT: "waiting_input";
|
|
6
|
+
readonly WAITING_RUNNER: "waiting_runner";
|
|
7
|
+
readonly COMPLETED: "completed";
|
|
8
|
+
readonly FAILED: "failed";
|
|
9
|
+
readonly CANCELLED: "cancelled";
|
|
10
|
+
};
|
|
11
|
+
export declare const RunStepType: {
|
|
12
|
+
readonly CREATED: "run.created";
|
|
13
|
+
readonly STARTED: "run.started";
|
|
14
|
+
readonly TEXT_DELTA: "runtime.text_delta";
|
|
15
|
+
readonly AUTH_REQUIRED: "runtime.auth_required";
|
|
16
|
+
readonly TOOL_CALL: "runtime.tool_call";
|
|
17
|
+
readonly WAITING_INPUT: "runtime.waiting_input";
|
|
18
|
+
readonly WAITING_RUNNER: "runtime.waiting_runner";
|
|
19
|
+
readonly CANCEL_REQUESTED: "run.cancel_requested";
|
|
20
|
+
readonly CANCELLED: "run.cancelled";
|
|
21
|
+
readonly ERROR: "runtime.error";
|
|
22
|
+
readonly COMPLETED: "run.completed";
|
|
23
|
+
readonly FAILED: "run.failed";
|
|
24
|
+
readonly CLIENT_TOOL_OUTPUT: "runtime.client_tool_output";
|
|
25
|
+
readonly CONTINUE_REQUESTED: "run.continue_requested";
|
|
26
|
+
};
|
|
27
|
+
export type RunStepTypeValue = (typeof RunStepType)[keyof typeof RunStepType];
|
|
28
|
+
/**
|
|
29
|
+
* Run resource.
|
|
30
|
+
*
|
|
31
|
+
* Run is the durable execution fact for an Agent Runtime attempt. Chat and
|
|
32
|
+
* Task describe command shape; Run describes the concrete runtime execution.
|
|
33
|
+
*/
|
|
34
|
+
export declare const runResource: import("@undefineds.co/drizzle-solid/dist/core/schema").PodTableWithColumns<import("@undefineds.co/drizzle-solid/dist/core/schema").ResolvedColumns<{
|
|
35
|
+
id: import("@undefineds.co/drizzle-solid/dist/core/schema").PodStringColumn<false, false>;
|
|
36
|
+
commandKind: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, true>;
|
|
37
|
+
surfaceId: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, true>;
|
|
38
|
+
task: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
39
|
+
thread: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, true, false>;
|
|
40
|
+
workspace: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, true, false>;
|
|
41
|
+
status: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, true>;
|
|
42
|
+
runner: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, false>;
|
|
43
|
+
prompt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
44
|
+
externalRunId: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
45
|
+
leaseOwner: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
46
|
+
leaseExpiresAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, false, false>;
|
|
47
|
+
heartbeatAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, false, false>;
|
|
48
|
+
cancelRequestedAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, false, false>;
|
|
49
|
+
error: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
50
|
+
metadata: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"object", null, false, false>;
|
|
51
|
+
createdAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, true, true>;
|
|
52
|
+
startedAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, false, false>;
|
|
53
|
+
completedAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, false, false>;
|
|
54
|
+
updatedAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, true, true>;
|
|
55
|
+
}>>;
|
|
56
|
+
/**
|
|
57
|
+
* RunStep resource.
|
|
58
|
+
*
|
|
59
|
+
* Append-only execution facts emitted while a Run executes. `runId` is a
|
|
60
|
+
* denormalized base-relative id for fast lookup; `run` is the semantic RDF
|
|
61
|
+
* relation to the Run.
|
|
62
|
+
*/
|
|
63
|
+
export declare const runStepResource: import("@undefineds.co/drizzle-solid/dist/core/schema").PodTableWithColumns<import("@undefineds.co/drizzle-solid/dist/core/schema").ResolvedColumns<{
|
|
64
|
+
id: import("@undefineds.co/drizzle-solid/dist/core/schema").PodStringColumn<false, false>;
|
|
65
|
+
commandKind: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, true>;
|
|
66
|
+
surfaceId: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, true>;
|
|
67
|
+
runId: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, false>;
|
|
68
|
+
run: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, true, false>;
|
|
69
|
+
type: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, false>;
|
|
70
|
+
message: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
71
|
+
data: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"object", null, false, false>;
|
|
72
|
+
createdAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, true, true>;
|
|
73
|
+
}>>;
|
|
74
|
+
export declare const runTable: import("@undefineds.co/drizzle-solid/dist/core/schema").PodTableWithColumns<import("@undefineds.co/drizzle-solid/dist/core/schema").ResolvedColumns<{
|
|
75
|
+
id: import("@undefineds.co/drizzle-solid/dist/core/schema").PodStringColumn<false, false>;
|
|
76
|
+
commandKind: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, true>;
|
|
77
|
+
surfaceId: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, true>;
|
|
78
|
+
task: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, false, false>;
|
|
79
|
+
thread: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, true, false>;
|
|
80
|
+
workspace: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, true, false>;
|
|
81
|
+
status: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, true>;
|
|
82
|
+
runner: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, false>;
|
|
83
|
+
prompt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
84
|
+
externalRunId: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
85
|
+
leaseOwner: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
86
|
+
leaseExpiresAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, false, false>;
|
|
87
|
+
heartbeatAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, false, false>;
|
|
88
|
+
cancelRequestedAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, false, false>;
|
|
89
|
+
error: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
90
|
+
metadata: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"object", null, false, false>;
|
|
91
|
+
createdAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, true, true>;
|
|
92
|
+
startedAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, false, false>;
|
|
93
|
+
completedAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, false, false>;
|
|
94
|
+
updatedAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, true, true>;
|
|
95
|
+
}>>;
|
|
96
|
+
export declare const runStepTable: import("@undefineds.co/drizzle-solid/dist/core/schema").PodTableWithColumns<import("@undefineds.co/drizzle-solid/dist/core/schema").ResolvedColumns<{
|
|
97
|
+
id: import("@undefineds.co/drizzle-solid/dist/core/schema").PodStringColumn<false, false>;
|
|
98
|
+
commandKind: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, true>;
|
|
99
|
+
surfaceId: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, true>;
|
|
100
|
+
runId: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, false>;
|
|
101
|
+
run: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"uri", null, true, false>;
|
|
102
|
+
type: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, true, false>;
|
|
103
|
+
message: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"string", null, false, false>;
|
|
104
|
+
data: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"object", null, false, false>;
|
|
105
|
+
createdAt: import("@undefineds.co/drizzle-solid/dist/core/schema").ColumnBuilder<"datetime", null, true, true>;
|
|
106
|
+
}>>;
|
|
107
|
+
export type RunRow = typeof runResource.$inferSelect;
|
|
108
|
+
export type RunInsert = typeof runResource.$inferInsert;
|
|
109
|
+
export type RunUpdate = typeof runResource.$inferUpdate;
|
|
110
|
+
export type RunStepRow = typeof runStepResource.$inferSelect;
|
|
111
|
+
export type RunStepInsert = typeof runStepResource.$inferInsert;
|
|
112
|
+
export type RunStepUpdate = typeof runStepResource.$inferUpdate;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { id, object, podTable, string, timestamp, uri } from '@undefineds.co/drizzle-solid';
|
|
2
|
+
import { DCTerms, UDFS } from './namespaces.js';
|
|
3
|
+
import { taskResource } from './task.schema.js';
|
|
4
|
+
import { threadResource } from './thread.schema.js';
|
|
5
|
+
import { runResourceId, runStepResourceId } from './resource-id-defaults.js';
|
|
6
|
+
export const RunStatus = {
|
|
7
|
+
QUEUED: 'queued',
|
|
8
|
+
RUNNING: 'running',
|
|
9
|
+
WAITING_INPUT: 'waiting_input',
|
|
10
|
+
WAITING_RUNNER: 'waiting_runner',
|
|
11
|
+
COMPLETED: 'completed',
|
|
12
|
+
FAILED: 'failed',
|
|
13
|
+
CANCELLED: 'cancelled',
|
|
14
|
+
};
|
|
15
|
+
export const RunStepType = {
|
|
16
|
+
CREATED: 'run.created',
|
|
17
|
+
STARTED: 'run.started',
|
|
18
|
+
TEXT_DELTA: 'runtime.text_delta',
|
|
19
|
+
AUTH_REQUIRED: 'runtime.auth_required',
|
|
20
|
+
TOOL_CALL: 'runtime.tool_call',
|
|
21
|
+
WAITING_INPUT: 'runtime.waiting_input',
|
|
22
|
+
WAITING_RUNNER: 'runtime.waiting_runner',
|
|
23
|
+
CANCEL_REQUESTED: 'run.cancel_requested',
|
|
24
|
+
CANCELLED: 'run.cancelled',
|
|
25
|
+
ERROR: 'runtime.error',
|
|
26
|
+
COMPLETED: 'run.completed',
|
|
27
|
+
FAILED: 'run.failed',
|
|
28
|
+
CLIENT_TOOL_OUTPUT: 'runtime.client_tool_output',
|
|
29
|
+
CONTINUE_REQUESTED: 'run.continue_requested',
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Run resource.
|
|
33
|
+
*
|
|
34
|
+
* Run is the durable execution fact for an Agent Runtime attempt. Chat and
|
|
35
|
+
* Task describe command shape; Run describes the concrete runtime execution.
|
|
36
|
+
*/
|
|
37
|
+
export const runResource = podTable('run', {
|
|
38
|
+
id: id('id').default(runResourceId),
|
|
39
|
+
commandKind: string('commandKind').predicate(UDFS.commandKind).notNull().default('chat'),
|
|
40
|
+
surfaceId: string('surfaceId').predicate(UDFS.surfaceId).notNull().default('default'),
|
|
41
|
+
task: uri('task').predicate(UDFS.task).link(taskResource),
|
|
42
|
+
thread: uri('thread').predicate(UDFS.inThread).notNull().link(threadResource),
|
|
43
|
+
workspace: uri('workspace').predicate(UDFS.workspace).notNull(),
|
|
44
|
+
status: string('status').predicate(UDFS.status).notNull().default(RunStatus.QUEUED),
|
|
45
|
+
runner: string('runner').predicate(UDFS.runner).notNull(),
|
|
46
|
+
prompt: string('prompt').predicate(UDFS.prompt),
|
|
47
|
+
externalRunId: string('externalRunId').predicate(UDFS.externalRunId),
|
|
48
|
+
leaseOwner: string('leaseOwner').predicate(UDFS.leaseOwner),
|
|
49
|
+
leaseExpiresAt: timestamp('leaseExpiresAt').predicate(UDFS.leaseExpiresAt),
|
|
50
|
+
heartbeatAt: timestamp('heartbeatAt').predicate(UDFS.heartbeatAt),
|
|
51
|
+
cancelRequestedAt: timestamp('cancelRequestedAt').predicate(UDFS.cancelRequestedAt),
|
|
52
|
+
error: string('error').predicate(UDFS.error),
|
|
53
|
+
metadata: object('metadata').predicate(UDFS.metadata),
|
|
54
|
+
createdAt: timestamp('createdAt').predicate(DCTerms.created).notNull().defaultNow(),
|
|
55
|
+
startedAt: timestamp('startedAt').predicate(UDFS.startedAt),
|
|
56
|
+
completedAt: timestamp('completedAt').predicate(UDFS.completedAt),
|
|
57
|
+
updatedAt: timestamp('updatedAt').predicate(DCTerms.modified).notNull().defaultNow(),
|
|
58
|
+
}, {
|
|
59
|
+
base: '/.data/',
|
|
60
|
+
sparqlEndpoint: '/.data/-/sparql',
|
|
61
|
+
type: UDFS.Run,
|
|
62
|
+
namespace: UDFS,
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* RunStep resource.
|
|
66
|
+
*
|
|
67
|
+
* Append-only execution facts emitted while a Run executes. `runId` is a
|
|
68
|
+
* denormalized base-relative id for fast lookup; `run` is the semantic RDF
|
|
69
|
+
* relation to the Run.
|
|
70
|
+
*/
|
|
71
|
+
export const runStepResource = podTable('run_step', {
|
|
72
|
+
id: id('id').default(runStepResourceId),
|
|
73
|
+
commandKind: string('commandKind').predicate(UDFS.commandKind).notNull().default('chat'),
|
|
74
|
+
surfaceId: string('surfaceId').predicate(UDFS.surfaceId).notNull().default('default'),
|
|
75
|
+
runId: string('runId').predicate(UDFS.runId).notNull(),
|
|
76
|
+
run: uri('run').predicate(UDFS.run).notNull().link(runResource),
|
|
77
|
+
type: string('type').predicate(UDFS.status).notNull(),
|
|
78
|
+
message: string('message').predicate(DCTerms.description),
|
|
79
|
+
data: object('data').predicate(UDFS.metadata),
|
|
80
|
+
createdAt: timestamp('createdAt').predicate(DCTerms.created).notNull().defaultNow(),
|
|
81
|
+
}, {
|
|
82
|
+
base: '/.data/',
|
|
83
|
+
sparqlEndpoint: '/.data/-/sparql',
|
|
84
|
+
type: UDFS.RunStep,
|
|
85
|
+
namespace: UDFS,
|
|
86
|
+
});
|
|
87
|
+
// Compatibility aliases. New model code should prefer Resource names.
|
|
88
|
+
export const runTable = runResource;
|
|
89
|
+
export const runStepTable = runStepResource;
|