@ricajs/contracts 0.0.0-stage → 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/LICENSE +661 -0
- package/README.md +153 -2
- package/action-review.d.ts +120 -0
- package/action-review.js +40 -0
- package/auto-review.d.ts +32 -0
- package/auto-review.js +14 -0
- package/commitments.d.ts +87 -0
- package/commitments.js +33 -0
- package/deployment-plugins.d.ts +7 -0
- package/deployment-plugins.js +2 -0
- package/health.d.ts +7 -0
- package/health.js +1 -0
- package/local-users.d.ts +17 -0
- package/local-users.js +6 -0
- package/management.d.ts +640 -0
- package/management.js +235 -0
- package/memory.d.ts +14 -0
- package/memory.js +1 -0
- package/model-provider.d.ts +40 -0
- package/model-provider.js +10 -0
- package/package.json +93 -3
- package/plans.d.ts +50 -0
- package/plans.js +20 -0
- package/platform-reader.d.ts +26 -0
- package/platform-reader.js +9 -0
- package/platform-reply-executor.d.ts +13 -0
- package/platform-reply-executor.js +3 -0
- package/plugin-status.d.ts +277 -0
- package/plugin-status.js +54 -0
- package/run-continuity.d.ts +84 -0
- package/run-continuity.js +1 -0
- package/schedules.d.ts +46 -0
- package/schedules.js +18 -0
- package/simulation-follow-up.d.ts +35 -0
- package/simulation-follow-up.js +29 -0
- package/simulation-observability.d.ts +223 -0
- package/simulation-observability.js +85 -0
- package/simulation-platform.d.ts +33 -0
- package/simulation-platform.js +7 -0
- package/source/action-review.ts +45 -0
- package/source/auto-review.ts +22 -0
- package/source/commitments.ts +39 -0
- package/source/deployment-plugins.ts +4 -0
- package/source/health.ts +4 -0
- package/source/local-users.ts +8 -0
- package/source/management.ts +246 -0
- package/source/memory.ts +15 -0
- package/source/model-provider.ts +29 -0
- package/source/package.json +43 -0
- package/source/plans.ts +22 -0
- package/source/platform-reader.ts +27 -0
- package/source/platform-reply-executor.ts +10 -0
- package/source/plugin-status.ts +67 -0
- package/source/run-continuity.ts +60 -0
- package/source/schedules.ts +22 -0
- package/source/simulation-follow-up.ts +35 -0
- package/source/simulation-observability.ts +94 -0
- package/source/simulation-platform.ts +39 -0
package/management.js
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { simulationPlatformId } from './simulation-platform.js';
|
|
2
|
+
import { z } from '@hono/zod-openapi';
|
|
3
|
+
export const resourceId = z.uuid().transform((value) => value.toLowerCase());
|
|
4
|
+
const slug = z.string().regex(/^[a-z0-9][a-z0-9-]{0,62}$/);
|
|
5
|
+
const text = z.string().trim().min(1).max(240).regex(/^[^\p{Cc}]+$/u);
|
|
6
|
+
const shortText = text.max(120);
|
|
7
|
+
export const reasonInput = z.strictObject({ reason: text });
|
|
8
|
+
const optionalReasonInput = reasonInput.partial();
|
|
9
|
+
export const maxAiDisclosureLength = 3000;
|
|
10
|
+
export const coreProfile = z.strictObject({
|
|
11
|
+
name: shortText.optional(),
|
|
12
|
+
aiDisclosure: z.string().trim().min(1).max(maxAiDisclosureLength)
|
|
13
|
+
.refine((value) => !/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/u.test(value)),
|
|
14
|
+
dailyModelBudget: z.number().int().min(1024).max(100_000_000).optional(),
|
|
15
|
+
fictionalBackground: text.optional(),
|
|
16
|
+
values: z.array(shortText).max(16).optional(),
|
|
17
|
+
privacyRules: z.array(text).max(16).optional(),
|
|
18
|
+
});
|
|
19
|
+
const timezone = z.string().min(1).max(80).refine((timeZone) => {
|
|
20
|
+
try {
|
|
21
|
+
new Intl.DateTimeFormat('en', { timeZone });
|
|
22
|
+
return !/^[+-]/.test(timeZone);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const stateDeltas = z.array(z.number().min(-0.15).max(0.15)).length(7);
|
|
29
|
+
const stateRule = z.strictObject({
|
|
30
|
+
motivationHalfLifeHours: z.number().min(1).max(168),
|
|
31
|
+
affectHalfLifeHours: z.number().min(1).max(168),
|
|
32
|
+
deltas: z.strictObject({ POST: stateDeltas, MENTION: stateDeltas, REPLY: stateDeltas }),
|
|
33
|
+
});
|
|
34
|
+
const energyLevel = z.enum(['LOW', 'NORMAL', 'HIGH']);
|
|
35
|
+
export const dailyEnergyInput = reasonInput.extend({ utcDay: z.iso.date(), energy: energyLevel });
|
|
36
|
+
export const dailyEnergyView = z.object({
|
|
37
|
+
id: resourceId, utcDay: z.iso.date(), energy: energyLevel,
|
|
38
|
+
approvedAt: z.iso.datetime({ offset: true }),
|
|
39
|
+
});
|
|
40
|
+
export const maxIdentityWritingPromptLength = 4000;
|
|
41
|
+
export const identityProfile = z.strictObject({
|
|
42
|
+
displayName: shortText.optional(),
|
|
43
|
+
timezone: timezone.optional(),
|
|
44
|
+
stateRule: stateRule.optional(),
|
|
45
|
+
duplicateReview: z.strictObject({
|
|
46
|
+
similarityPercent: z.number().int().min(65).max(100),
|
|
47
|
+
windowHours: z.number().int().min(1).max(168),
|
|
48
|
+
}).optional(),
|
|
49
|
+
autonomousGoal: z.strictObject({
|
|
50
|
+
topic: z.literal('REVIEW_INTERACTIONS'),
|
|
51
|
+
maxDays: z.number().int().min(1).max(7),
|
|
52
|
+
budget: z.number().int().min(1).max(100),
|
|
53
|
+
}).optional(),
|
|
54
|
+
writingStyle: z.enum(['neutral', 'formal', 'casual', 'concise']).optional(),
|
|
55
|
+
draftModelProfile: z.union([resourceId, z.literal('simulated')]).optional(),
|
|
56
|
+
writingPrompt: z.string().trim().min(1).max(maxIdentityWritingPromptLength)
|
|
57
|
+
.refine((value) => !/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/u.test(value)).optional(),
|
|
58
|
+
});
|
|
59
|
+
export const characterInput = z.strictObject({
|
|
60
|
+
slug,
|
|
61
|
+
timezone,
|
|
62
|
+
coreProfile,
|
|
63
|
+
});
|
|
64
|
+
export const coreInput = optionalReasonInput.extend({ coreProfile });
|
|
65
|
+
export const identityInput = z.strictObject({ slug, roleProfile: identityProfile });
|
|
66
|
+
export const identityUpdate = optionalReasonInput.extend({ roleProfile: identityProfile });
|
|
67
|
+
export const simulationAccountRegistration = z.strictObject({
|
|
68
|
+
platform: simulationPlatformId,
|
|
69
|
+
instanceKey: shortText,
|
|
70
|
+
remoteAccountId: text,
|
|
71
|
+
});
|
|
72
|
+
export const accountInput = simulationAccountRegistration.extend({ identityId: resourceId });
|
|
73
|
+
export const accountBindingInput = z.strictObject({ registrationId: resourceId, identityId: resourceId });
|
|
74
|
+
export const accountRegistrationView = z.strictObject({
|
|
75
|
+
id: resourceId, platform: z.string(),
|
|
76
|
+
instanceKey: z.string(), remoteAccountId: z.string(),
|
|
77
|
+
});
|
|
78
|
+
export const automationEligibilityView = z.object({
|
|
79
|
+
accountId: resourceId, identityId: resourceId, bindingVersion: z.number().int(),
|
|
80
|
+
eligible: z.literal(false),
|
|
81
|
+
reasons: z.array(z.enum(['BINDING_INACTIVE', 'SIMULATION_ONLY', 'UNSUPPORTED_ADAPTER', 'EXTERNAL_AUTO_DISABLED'])),
|
|
82
|
+
});
|
|
83
|
+
export const controlInput = optionalReasonInput.extend({
|
|
84
|
+
scope: z.enum(['CHARACTER', 'IDENTITY', 'ACCOUNT']),
|
|
85
|
+
scopeId: resourceId,
|
|
86
|
+
operation: z.enum(['PAUSE', 'RESUME', 'REVOKE_ACCOUNT']),
|
|
87
|
+
});
|
|
88
|
+
export const membershipInput = reasonInput.extend({
|
|
89
|
+
subject: z.string().min(1).max(512).regex(/^[^\p{Cc}]+$/u),
|
|
90
|
+
action: z.enum(['GRANT', 'REVOKE']),
|
|
91
|
+
}).strict();
|
|
92
|
+
export const identityReflectionView = z.object({
|
|
93
|
+
identityId: resourceId, utcDay: z.iso.date(), coreVersion: z.number().int(), identityVersion: z.number().int(),
|
|
94
|
+
createdAt: z.iso.datetime({ offset: true }), candidateBeliefId: resourceId.nullable(),
|
|
95
|
+
fictionalProfile: z.object({ kind: z.literal('FICTIONAL_PROFILE'), present: z.boolean() }),
|
|
96
|
+
observedActivity: z.object({ kind: z.literal('OBSERVED_ACTIVITY'), simulatedReceipts: z.number().int().nonnegative() }),
|
|
97
|
+
unverifiedExternal: z.object({ kind: z.literal('UNVERIFIED_EXTERNAL'), inboundMessages: z.number().int().nonnegative() }),
|
|
98
|
+
});
|
|
99
|
+
const beliefKind = z.enum(['OPINION', 'PREFERENCE']);
|
|
100
|
+
const beliefEvidence = z.object({
|
|
101
|
+
memoryId: resourceId, memoryRevision: z.number().int().min(1).max(2_147_483_647),
|
|
102
|
+
direction: z.enum(['SUPPORT', 'OPPOSE']), weight: z.number().min(0).max(1),
|
|
103
|
+
});
|
|
104
|
+
export const beliefInput = reasonInput.extend({
|
|
105
|
+
kind: beliefKind, statement: z.string().trim().min(1).max(1000), evidence: z.array(beliefEvidence).min(1).max(16),
|
|
106
|
+
});
|
|
107
|
+
export const beliefRestoreInput = reasonInput.extend({ restoreVersion: z.number().int().min(1).max(2_147_483_647) });
|
|
108
|
+
export const beliefView = z.object({
|
|
109
|
+
id: resourceId, identityId: resourceId, version: z.number().int(), kind: beliefKind,
|
|
110
|
+
status: z.enum(['PENDING', 'ACTIVE', 'DISPUTED', 'INVALIDATED']),
|
|
111
|
+
statement: z.string().nullable(), confidence: z.number().nullable(), reason: z.string().nullable(),
|
|
112
|
+
restoredFrom: z.number().int().nullable(), createdAt: z.iso.datetime({ offset: true }),
|
|
113
|
+
evidence: z.array(beliefEvidence.extend({ sourceId: resourceId })),
|
|
114
|
+
remainingEvidence: z.object({
|
|
115
|
+
supportingSources: z.number().int().nonnegative(), opposingSources: z.number().int().nonnegative(),
|
|
116
|
+
confidence: z.number().min(0).max(1),
|
|
117
|
+
}).nullable(),
|
|
118
|
+
});
|
|
119
|
+
const goalStatus = z.enum(['DRAFT', 'ACTIVE', 'PAUSED', 'DONE', 'CANCELED', 'EXPIRED']);
|
|
120
|
+
export const manualGoalInput = reasonInput.extend({
|
|
121
|
+
title: text, status: z.enum(['DRAFT', 'ACTIVE', 'PAUSED', 'DONE', 'CANCELED']),
|
|
122
|
+
priority: z.number().int().min(0).max(100), budget: z.number().int().min(1).max(100),
|
|
123
|
+
dueAt: z.iso.datetime(), nextStep: text.optional(),
|
|
124
|
+
});
|
|
125
|
+
export const manualGoalView = z.object({
|
|
126
|
+
id: resourceId, identityId: resourceId, version: z.number().int(), origin: z.enum(['ADMIN', 'SELF']),
|
|
127
|
+
topic: z.literal('REVIEW_INTERACTIONS').nullable(), reflectionDay: z.iso.date().nullable(),
|
|
128
|
+
title: z.string(), status: goalStatus, priority: z.number().int(), budget: z.number().int(),
|
|
129
|
+
dueAt: z.iso.datetime({ offset: true }), nextStep: z.string().nullable(), createdAt: z.iso.datetime({ offset: true }),
|
|
130
|
+
});
|
|
131
|
+
export const contactBoundaryInput = reasonInput.extend({ blocked: z.boolean() });
|
|
132
|
+
export const contactBoundaryView = z.object({
|
|
133
|
+
id: resourceId, accountId: resourceId, version: z.number().int(), blocked: z.boolean(),
|
|
134
|
+
changedAt: z.iso.datetime({ offset: true }).nullable(), reason: z.string().nullable(),
|
|
135
|
+
});
|
|
136
|
+
export const memoryCorrectionInput = reasonInput.extend({
|
|
137
|
+
content: z.string().trim().min(1).max(1500).refine((content) => !content.includes('\0')),
|
|
138
|
+
});
|
|
139
|
+
export const memoryProvenanceView = z.object({
|
|
140
|
+
id: resourceId, revision: z.number().int(), status: z.enum(['ACTIVE', 'REVOKED']),
|
|
141
|
+
parentMemoryId: resourceId.nullable(),
|
|
142
|
+
sources: z.array(z.object({
|
|
143
|
+
id: resourceId, kind: z.string(), classification: z.enum(['PUBLIC', 'PERSONAL', 'CONFIDENTIAL', 'RESTRICTED']),
|
|
144
|
+
revokedAt: z.iso.datetime({ offset: true }).nullable(),
|
|
145
|
+
})),
|
|
146
|
+
corrections: z.array(z.object({
|
|
147
|
+
revision: z.number().int(), actorId: z.string(), reason: z.string(), createdAt: z.iso.datetime({ offset: true }),
|
|
148
|
+
})),
|
|
149
|
+
});
|
|
150
|
+
export const memoryGrantInput = reasonInput.extend({
|
|
151
|
+
memoryId: resourceId,
|
|
152
|
+
recipientIdentityId: resourceId,
|
|
153
|
+
recipientAccountId: resourceId.optional(),
|
|
154
|
+
recipientConversationId: resourceId.optional(),
|
|
155
|
+
recipientContactId: resourceId.optional(),
|
|
156
|
+
purpose: z.enum(['INTERNAL_CONTEXT', 'DECISION_SUPPORT', 'PUBLIC_REFERENCE', 'PRIVATE_REPLY']),
|
|
157
|
+
audience: resourceId.optional(),
|
|
158
|
+
validFrom: z.iso.datetime(),
|
|
159
|
+
validUntil: z.iso.datetime(),
|
|
160
|
+
});
|
|
161
|
+
export const listQuery = z.object({
|
|
162
|
+
limit: z.string().regex(/^(?:[1-9][0-9]?|100)$/).optional(),
|
|
163
|
+
cursor: resourceId.optional(),
|
|
164
|
+
});
|
|
165
|
+
export const memoryListQuery = listQuery.extend({
|
|
166
|
+
identityId: resourceId.optional(),
|
|
167
|
+
scope: z.enum(['CORE', 'IDENTITY', 'ACCOUNT', 'CONVERSATION']).optional(),
|
|
168
|
+
status: z.enum(['ACTIVE', 'REVOKED']).optional(),
|
|
169
|
+
});
|
|
170
|
+
export const grantListQuery = listQuery.extend({ memoryId: resourceId.optional() });
|
|
171
|
+
export const memberListQuery = listQuery.omit({ cursor: true }).extend({ after: membershipInput.shape.subject.optional() });
|
|
172
|
+
export const memberPage = z.object({
|
|
173
|
+
items: z.array(z.object({ subject: membershipInput.shape.subject })),
|
|
174
|
+
nextCursor: membershipInput.shape.subject.nullable(),
|
|
175
|
+
});
|
|
176
|
+
export const conversationListQuery = listQuery.extend({
|
|
177
|
+
accountId: resourceId,
|
|
178
|
+
channel: z.enum(['PUBLIC', 'PRIVATE']).optional(),
|
|
179
|
+
});
|
|
180
|
+
export const conversationOption = z.object({
|
|
181
|
+
id: resourceId, channel: z.enum(['PUBLIC', 'PRIVATE']), privateContactId: resourceId.nullable(),
|
|
182
|
+
contactLabel: z.string().nullable(),
|
|
183
|
+
});
|
|
184
|
+
export const beliefSummary = beliefView.pick({ id: true, version: true, kind: true });
|
|
185
|
+
export const contactSummary = contactBoundaryView.pick({ id: true, accountId: true, version: true, blocked: true })
|
|
186
|
+
.extend({ label: z.string().nullable() });
|
|
187
|
+
export const auditQuery = listQuery.extend({ runId: resourceId.optional(), targetId: resourceId.optional(), order: z.enum(['asc', 'desc']).optional() });
|
|
188
|
+
export const idempotencyHeader = z.object({
|
|
189
|
+
'idempotency-key': z.string().regex(/^[a-zA-Z0-9._:-]{1,128}$/),
|
|
190
|
+
});
|
|
191
|
+
export const versionHeader = z.object({ 'if-match': z.string() });
|
|
192
|
+
export const errorResponse = z.object({
|
|
193
|
+
error: z.object({ code: z.string(), message: z.string(), requestId: z.uuid() }),
|
|
194
|
+
});
|
|
195
|
+
export const commandResponse = z.object({
|
|
196
|
+
id: z.uuid(),
|
|
197
|
+
requestId: z.uuid(),
|
|
198
|
+
version: z.number().int().optional(),
|
|
199
|
+
status: z.string().optional(),
|
|
200
|
+
authEpoch: z.number().int().optional(),
|
|
201
|
+
});
|
|
202
|
+
export const characterView = z.object({
|
|
203
|
+
id: z.uuid(), slug: z.string(), timezone: z.string(), status: z.string(),
|
|
204
|
+
version: z.number().int().nullable(), profile: coreProfile.nullable(),
|
|
205
|
+
});
|
|
206
|
+
export const characterWorkspaceView = characterView.extend({
|
|
207
|
+
simulationPlatforms: z.array(accountInput.shape.platform),
|
|
208
|
+
});
|
|
209
|
+
export const identityView = z.object({
|
|
210
|
+
id: z.uuid(), slug: z.string(), status: z.string(),
|
|
211
|
+
version: z.number().int().nullable(), profile: identityProfile.nullable(),
|
|
212
|
+
});
|
|
213
|
+
export const accountView = z.object({
|
|
214
|
+
id: z.uuid(), identityId: z.uuid(), platform: z.string(), instanceKey: z.string(),
|
|
215
|
+
status: z.string(), version: z.number().int(),
|
|
216
|
+
});
|
|
217
|
+
export const memoryView = z.object({
|
|
218
|
+
id: z.uuid(), identityId: z.uuid().nullable(), accountId: z.uuid().nullable(),
|
|
219
|
+
conversationId: z.uuid().nullable(), scope: z.string(), visibility: z.string(),
|
|
220
|
+
status: z.string(), createdAt: z.iso.datetime(), expiresAt: z.iso.datetime().nullable(),
|
|
221
|
+
});
|
|
222
|
+
export const memoryDetailView = z.object({ memory: memoryView, provenance: memoryProvenanceView });
|
|
223
|
+
export const grantView = z.object({
|
|
224
|
+
id: z.uuid(), memoryId: z.uuid(), recipientIdentityId: z.uuid(),
|
|
225
|
+
recipientAccountId: z.uuid().nullable(), recipientConversationId: z.uuid().nullable(),
|
|
226
|
+
recipientContactId: z.uuid().nullable(), purpose: z.string(), audience: z.string().nullable(),
|
|
227
|
+
validFrom: z.iso.datetime(), validUntil: z.iso.datetime(), revokedAt: z.iso.datetime().nullable(),
|
|
228
|
+
});
|
|
229
|
+
export const auditView = z.object({
|
|
230
|
+
id: z.uuid(), operation: z.string(), actorId: z.string(), targetId: z.uuid(),
|
|
231
|
+
requestId: z.uuid(), digest: z.string(), createdAt: z.iso.datetime(),
|
|
232
|
+
});
|
|
233
|
+
export function pageView(item) {
|
|
234
|
+
return z.object({ items: z.array(item), nextCursor: z.string().nullable() });
|
|
235
|
+
}
|
package/memory.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type MemoryCandidate = {
|
|
2
|
+
id: string;
|
|
3
|
+
content: string;
|
|
4
|
+
revision: number;
|
|
5
|
+
importance: number;
|
|
6
|
+
confidence: number;
|
|
7
|
+
createdAt: Date;
|
|
8
|
+
scope: 'CORE' | 'IDENTITY' | 'ACCOUNT' | 'CONVERSATION';
|
|
9
|
+
sameConversation: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type RankedMemory = MemoryCandidate & {
|
|
12
|
+
score: number;
|
|
13
|
+
estimatedTokens: number;
|
|
14
|
+
};
|
package/memory.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { RunContinuity, RunTime } from './run-continuity.js';
|
|
2
|
+
import type { PublicReplyReview } from './auto-review.js';
|
|
3
|
+
export declare const maxSimulatedTextLength = 4000;
|
|
4
|
+
export declare class ModelProviderError extends Error {
|
|
5
|
+
readonly code: 'HTTP_ERROR' | 'REQUEST_FAILED' | 'INVALID_OUTPUT';
|
|
6
|
+
readonly status?: number | undefined;
|
|
7
|
+
constructor(code: 'HTTP_ERROR' | 'REQUEST_FAILED' | 'INVALID_OUTPUT', status?: number | undefined);
|
|
8
|
+
}
|
|
9
|
+
export type ModelEvidence = Readonly<{
|
|
10
|
+
id: string;
|
|
11
|
+
revision: number;
|
|
12
|
+
content: string;
|
|
13
|
+
}>;
|
|
14
|
+
type ModelInput = Readonly<{
|
|
15
|
+
text: string;
|
|
16
|
+
evidence: readonly ModelEvidence[];
|
|
17
|
+
}>;
|
|
18
|
+
export type WritingStyle = 'neutral' | 'formal' | 'casual' | 'concise';
|
|
19
|
+
export type ModelAttribution = Readonly<{
|
|
20
|
+
characterId: string;
|
|
21
|
+
identityId: string;
|
|
22
|
+
platform: string;
|
|
23
|
+
}>;
|
|
24
|
+
export type ModelProvider = Readonly<{
|
|
25
|
+
hostedProvider?: string;
|
|
26
|
+
hostedModel?: string;
|
|
27
|
+
review?(prompt: string, reply: PublicReplyReview, signal: AbortSignal, attribution?: ModelAttribution): Promise<unknown>;
|
|
28
|
+
decide(input: ModelInput & Readonly<{
|
|
29
|
+
context: RunContinuity;
|
|
30
|
+
}>, signal: AbortSignal): Promise<unknown>;
|
|
31
|
+
write(input: ModelInput & Readonly<{
|
|
32
|
+
style: WritingStyle;
|
|
33
|
+
time: RunTime;
|
|
34
|
+
corePrompt?: string;
|
|
35
|
+
identityPrompt?: string;
|
|
36
|
+
suggestFollowUp?: boolean;
|
|
37
|
+
attribution?: ModelAttribution;
|
|
38
|
+
}>, signal: AbortSignal): Promise<unknown>;
|
|
39
|
+
}>;
|
|
40
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,96 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ricajs/contracts",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@hono/zod-openapi": "^1.6.3",
|
|
7
|
+
"@ricajs/plugin-host": "0.1.0"
|
|
8
|
+
},
|
|
9
|
+
"license": "AGPL-3.0-only",
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": "^22.12.0 || ^24.0.0 || ^26.0.0"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/ifrvn/rica.git",
|
|
16
|
+
"directory": "packages/contracts"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public",
|
|
20
|
+
"registry": "https://registry.npmjs.org/"
|
|
21
|
+
},
|
|
22
|
+
"exports": {
|
|
23
|
+
"./model-provider": {
|
|
24
|
+
"types": "./model-provider.d.ts",
|
|
25
|
+
"default": "./model-provider.js"
|
|
26
|
+
},
|
|
27
|
+
"./run-continuity": {
|
|
28
|
+
"types": "./run-continuity.d.ts",
|
|
29
|
+
"default": "./run-continuity.js"
|
|
30
|
+
},
|
|
31
|
+
"./simulation-platform": {
|
|
32
|
+
"types": "./simulation-platform.d.ts",
|
|
33
|
+
"default": "./simulation-platform.js"
|
|
34
|
+
},
|
|
35
|
+
"./platform-reader": {
|
|
36
|
+
"types": "./platform-reader.d.ts",
|
|
37
|
+
"default": "./platform-reader.js"
|
|
38
|
+
},
|
|
39
|
+
"./platform-reply-executor": {
|
|
40
|
+
"types": "./platform-reply-executor.d.ts",
|
|
41
|
+
"default": "./platform-reply-executor.js"
|
|
42
|
+
},
|
|
43
|
+
"./management": {
|
|
44
|
+
"types": "./management.d.ts",
|
|
45
|
+
"default": "./management.js"
|
|
46
|
+
},
|
|
47
|
+
"./deployment-plugins": {
|
|
48
|
+
"types": "./deployment-plugins.d.ts",
|
|
49
|
+
"default": "./deployment-plugins.js"
|
|
50
|
+
},
|
|
51
|
+
"./health": {
|
|
52
|
+
"types": "./health.d.ts",
|
|
53
|
+
"default": "./health.js"
|
|
54
|
+
},
|
|
55
|
+
"./action-review": {
|
|
56
|
+
"types": "./action-review.d.ts",
|
|
57
|
+
"default": "./action-review.js"
|
|
58
|
+
},
|
|
59
|
+
"./local-users": {
|
|
60
|
+
"types": "./local-users.d.ts",
|
|
61
|
+
"default": "./local-users.js"
|
|
62
|
+
},
|
|
63
|
+
"./plugin-status": {
|
|
64
|
+
"types": "./plugin-status.d.ts",
|
|
65
|
+
"default": "./plugin-status.js"
|
|
66
|
+
},
|
|
67
|
+
"./simulation-observability": {
|
|
68
|
+
"types": "./simulation-observability.d.ts",
|
|
69
|
+
"default": "./simulation-observability.js"
|
|
70
|
+
},
|
|
71
|
+
"./plans": {
|
|
72
|
+
"types": "./plans.d.ts",
|
|
73
|
+
"default": "./plans.js"
|
|
74
|
+
},
|
|
75
|
+
"./commitments": {
|
|
76
|
+
"types": "./commitments.d.ts",
|
|
77
|
+
"default": "./commitments.js"
|
|
78
|
+
},
|
|
79
|
+
"./schedules": {
|
|
80
|
+
"types": "./schedules.d.ts",
|
|
81
|
+
"default": "./schedules.js"
|
|
82
|
+
},
|
|
83
|
+
"./auto-review": {
|
|
84
|
+
"types": "./auto-review.d.ts",
|
|
85
|
+
"default": "./auto-review.js"
|
|
86
|
+
},
|
|
87
|
+
"./simulation-follow-up": {
|
|
88
|
+
"types": "./simulation-follow-up.d.ts",
|
|
89
|
+
"default": "./simulation-follow-up.js"
|
|
90
|
+
},
|
|
91
|
+
"./memory": {
|
|
92
|
+
"types": "./memory.d.ts",
|
|
93
|
+
"default": "./memory.js"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
6
96
|
}
|
package/plans.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from '@hono/zod-openapi';
|
|
2
|
+
export declare const planningTask: z.ZodString;
|
|
3
|
+
export declare const planInput: z.ZodObject<{
|
|
4
|
+
zone: z.ZodString;
|
|
5
|
+
enabled: z.ZodBoolean;
|
|
6
|
+
rule: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
7
|
+
kind: z.ZodLiteral<"DAILY">;
|
|
8
|
+
localTime: z.ZodString;
|
|
9
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
10
|
+
kind: z.ZodLiteral<"REMINDER">;
|
|
11
|
+
dueAt: z.ZodISODateTime;
|
|
12
|
+
}, z.core.$strict>], "kind">;
|
|
13
|
+
title: z.ZodString;
|
|
14
|
+
participants: z.ZodArray<z.ZodObject<{
|
|
15
|
+
identityId: z.ZodPipe<z.ZodUUID, z.ZodTransform<string, string>>;
|
|
16
|
+
accountId: z.ZodPipe<z.ZodUUID, z.ZodTransform<string, string>>;
|
|
17
|
+
task: z.ZodString;
|
|
18
|
+
}, z.core.$strict>>;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
export declare const planStateInput: z.ZodObject<{
|
|
21
|
+
enabled: z.ZodBoolean;
|
|
22
|
+
}, z.core.$strict>;
|
|
23
|
+
export declare const planView: z.ZodObject<{
|
|
24
|
+
zone: z.ZodString;
|
|
25
|
+
enabled: z.ZodBoolean;
|
|
26
|
+
rule: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
27
|
+
kind: z.ZodLiteral<"DAILY">;
|
|
28
|
+
localTime: z.ZodString;
|
|
29
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
30
|
+
kind: z.ZodLiteral<"REMINDER">;
|
|
31
|
+
dueAt: z.ZodISODateTime;
|
|
32
|
+
}, z.core.$strict>], "kind">;
|
|
33
|
+
title: z.ZodString;
|
|
34
|
+
id: z.ZodPipe<z.ZodUUID, z.ZodTransform<string, string>>;
|
|
35
|
+
version: z.ZodNumber;
|
|
36
|
+
source: z.ZodEnum<{
|
|
37
|
+
MANUAL: "MANUAL";
|
|
38
|
+
AI: "AI";
|
|
39
|
+
}>;
|
|
40
|
+
humanEdited: z.ZodBoolean;
|
|
41
|
+
participants: z.ZodArray<z.ZodObject<{
|
|
42
|
+
identityId: z.ZodPipe<z.ZodUUID, z.ZodTransform<string, string>>;
|
|
43
|
+
accountId: z.ZodPipe<z.ZodUUID, z.ZodTransform<string, string>>;
|
|
44
|
+
task: z.ZodString;
|
|
45
|
+
platform: z.ZodString;
|
|
46
|
+
accountStatus: z.ZodString;
|
|
47
|
+
nextAt: z.ZodNullable<z.ZodISODateTime>;
|
|
48
|
+
lastRunId: z.ZodNullable<z.ZodPipe<z.ZodUUID, z.ZodTransform<string, string>>>;
|
|
49
|
+
}, z.core.$strict>>;
|
|
50
|
+
}, z.core.$strict>;
|
package/plans.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from '@hono/zod-openapi';
|
|
2
|
+
import { resourceId } from './management.js';
|
|
3
|
+
import { scheduleUpdate } from './schedules.js';
|
|
4
|
+
export const planningTask = z.string().trim().min(1).max(300).refine((value) => !value.includes('\0'));
|
|
5
|
+
const participantInput = z.strictObject({ identityId: resourceId, accountId: resourceId, task: planningTask });
|
|
6
|
+
export const planInput = scheduleUpdate.extend({
|
|
7
|
+
title: z.string().trim().min(1).max(72).regex(/^[^\p{Cc}]+$/u),
|
|
8
|
+
participants: z.array(participantInput).min(1).max(20).refine((items) => new Set(items.map(({ identityId }) => identityId)).size === items.length, 'Select each identity once'),
|
|
9
|
+
});
|
|
10
|
+
export const planStateInput = z.strictObject({ enabled: z.boolean() });
|
|
11
|
+
export const planView = planInput.extend({
|
|
12
|
+
id: resourceId,
|
|
13
|
+
version: z.number().int().positive(),
|
|
14
|
+
source: z.enum(['MANUAL', 'AI']),
|
|
15
|
+
humanEdited: z.boolean(),
|
|
16
|
+
participants: z.array(participantInput.extend({
|
|
17
|
+
platform: z.string(), accountStatus: z.string(), nextAt: z.iso.datetime().nullable(),
|
|
18
|
+
lastRunId: resourceId.nullable(),
|
|
19
|
+
})),
|
|
20
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type PlatformEventPage = Readonly<{
|
|
2
|
+
items: readonly Readonly<{
|
|
3
|
+
seq: string;
|
|
4
|
+
type: 'POST_REPLIED' | 'COMMENT_REPLIED' | 'AGENT_MENTIONED';
|
|
5
|
+
postId: string;
|
|
6
|
+
commentId: string | null;
|
|
7
|
+
createdAt: string;
|
|
8
|
+
}>[];
|
|
9
|
+
nextCursor: string;
|
|
10
|
+
hasMore: boolean;
|
|
11
|
+
historyLost: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
export type PlatformEventReader = Readonly<{
|
|
14
|
+
endpoint: string;
|
|
15
|
+
verify(): Promise<{
|
|
16
|
+
id: string;
|
|
17
|
+
pollIntervalSeconds: number;
|
|
18
|
+
}>;
|
|
19
|
+
readEvents(cursor: string | null): Promise<PlatformEventPage>;
|
|
20
|
+
}>;
|
|
21
|
+
export type PlatformReadFailure = 'CREDENTIAL_INVALID' | 'ACCESS_DENIED' | 'RATE_LIMITED' | 'SERVICE_UNAVAILABLE' | 'COMMUNITY_CLOSED';
|
|
22
|
+
export declare class PlatformReadError<Reason extends string = PlatformReadFailure> extends Error {
|
|
23
|
+
readonly reason: Reason;
|
|
24
|
+
readonly retrySeconds: number;
|
|
25
|
+
constructor(reason: Reason, retrySeconds?: number);
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PlatformReadError, type PlatformReadFailure } from './platform-reader.js';
|
|
2
|
+
export type PlatformReplyExecutor = Readonly<{
|
|
3
|
+
endpoint: string;
|
|
4
|
+
verify(): Promise<{
|
|
5
|
+
id: string;
|
|
6
|
+
}>;
|
|
7
|
+
readTarget(postId: string): Promise<{
|
|
8
|
+
isLocked: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
sendReply(postId: string, idempotencyKey: string, content: string): Promise<string>;
|
|
11
|
+
}>;
|
|
12
|
+
export declare class PlatformReplyError extends PlatformReadError<PlatformReadFailure | 'POST_LOCKED'> {
|
|
13
|
+
}
|