instar 0.9.0 → 0.9.2

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.
Files changed (59) hide show
  1. package/dist/cli.js +0 -0
  2. package/dist/commands/server.d.ts.map +1 -1
  3. package/dist/commands/server.js +202 -71
  4. package/dist/commands/server.js.map +1 -1
  5. package/dist/commands/setup.d.ts.map +1 -1
  6. package/dist/commands/setup.js +38 -4
  7. package/dist/commands/setup.js.map +1 -1
  8. package/dist/core/AgentConnector.d.ts +76 -0
  9. package/dist/core/AgentConnector.d.ts.map +1 -0
  10. package/dist/core/AgentConnector.js +323 -0
  11. package/dist/core/AgentConnector.js.map +1 -0
  12. package/dist/core/AutoUpdater.d.ts +7 -0
  13. package/dist/core/AutoUpdater.d.ts.map +1 -1
  14. package/dist/core/AutoUpdater.js +31 -3
  15. package/dist/core/AutoUpdater.js.map +1 -1
  16. package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
  17. package/dist/core/PostUpdateMigrator.js +86 -5
  18. package/dist/core/PostUpdateMigrator.js.map +1 -1
  19. package/dist/core/StateWriteAuthority.d.ts +101 -0
  20. package/dist/core/StateWriteAuthority.d.ts.map +1 -0
  21. package/dist/core/StateWriteAuthority.js +167 -0
  22. package/dist/core/StateWriteAuthority.js.map +1 -0
  23. package/dist/core/types.d.ts +104 -0
  24. package/dist/core/types.d.ts.map +1 -1
  25. package/dist/index.d.ts +2 -1
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +1 -0
  28. package/dist/index.js.map +1 -1
  29. package/dist/memory/TopicMemory.d.ts +167 -0
  30. package/dist/memory/TopicMemory.d.ts.map +1 -0
  31. package/dist/memory/TopicMemory.js +494 -0
  32. package/dist/memory/TopicMemory.js.map +1 -0
  33. package/dist/memory/TopicSummarizer.d.ts +58 -0
  34. package/dist/memory/TopicSummarizer.d.ts.map +1 -0
  35. package/dist/memory/TopicSummarizer.js +140 -0
  36. package/dist/memory/TopicSummarizer.js.map +1 -0
  37. package/dist/messaging/TelegramAdapter.d.ts +35 -0
  38. package/dist/messaging/TelegramAdapter.d.ts.map +1 -1
  39. package/dist/messaging/TelegramAdapter.js +136 -2
  40. package/dist/messaging/TelegramAdapter.js.map +1 -1
  41. package/dist/server/AgentServer.d.ts +2 -0
  42. package/dist/server/AgentServer.d.ts.map +1 -1
  43. package/dist/server/AgentServer.js +1 -0
  44. package/dist/server/AgentServer.js.map +1 -1
  45. package/dist/server/routes.d.ts +2 -0
  46. package/dist/server/routes.d.ts.map +1 -1
  47. package/dist/server/routes.js +340 -1
  48. package/dist/server/routes.js.map +1 -1
  49. package/dist/users/UserManager.d.ts +21 -0
  50. package/dist/users/UserManager.d.ts.map +1 -1
  51. package/dist/users/UserManager.js +32 -0
  52. package/dist/users/UserManager.js.map +1 -1
  53. package/dist/users/UserOnboarding.d.ts +116 -0
  54. package/dist/users/UserOnboarding.d.ts.map +1 -0
  55. package/dist/users/UserOnboarding.js +365 -0
  56. package/dist/users/UserOnboarding.js.map +1 -0
  57. package/package.json +2 -1
  58. package/upgrades/0.8.23.md +106 -0
  59. package/upgrades/0.9.1.md +91 -0
@@ -0,0 +1,116 @@
1
+ /**
2
+ * User Onboarding — handles new user registration and verification flows.
3
+ *
4
+ * Implements the Multi-User Setup Wizard spec (Rev 7):
5
+ * - New user joining an existing agent
6
+ * - Existing user on a new machine (verification)
7
+ * - On-the-fly Telegram registration
8
+ * - Consent collection before data collection
9
+ * - Agent contextual assessment for join requests
10
+ */
11
+ import type { UserProfile, AgentAutonomyConfig, ConsentRecord, DataCollectedManifest, VerificationCode, JoinRequest } from '../core/types.js';
12
+ /**
13
+ * Generate a random numeric verification code.
14
+ */
15
+ export declare function generateVerificationCode(digits?: number): string;
16
+ /**
17
+ * Generate a cryptographically random alphanumeric connect code
18
+ * using unambiguous characters (no 0/O, 1/l/I).
19
+ */
20
+ export declare function generateConnectCode(length?: number): string;
21
+ /**
22
+ * Hash a verification code for storage (we never store plaintext codes).
23
+ */
24
+ export declare function hashCode(code: string): string;
25
+ /**
26
+ * Generate a recovery key (32 bytes, displayed as hex).
27
+ */
28
+ export declare function generateRecoveryKey(): string;
29
+ /**
30
+ * Hash a recovery key with bcrypt-compatible SHA-256 (for config storage).
31
+ */
32
+ export declare function hashRecoveryKey(key: string): string;
33
+ /**
34
+ * Build the consent disclosure text for a given agent name.
35
+ */
36
+ export declare function buildConsentDisclosure(agentName: string): string;
37
+ /**
38
+ * Build a condensed consent disclosure for on-the-fly Telegram registration.
39
+ */
40
+ export declare function buildCondensedConsentDisclosure(agentName: string): string;
41
+ /**
42
+ * Create a consent record.
43
+ */
44
+ export declare function createConsentRecord(version?: string): ConsentRecord;
45
+ /**
46
+ * Create a default data collected manifest.
47
+ */
48
+ export declare function createDataManifest(options?: Partial<DataCollectedManifest>): DataCollectedManifest;
49
+ /**
50
+ * Manages verification codes with expiry and attempt limits.
51
+ */
52
+ export declare class VerificationManager {
53
+ private codes;
54
+ private lockouts;
55
+ /**
56
+ * Create a new verification code for a target.
57
+ * Returns the plaintext code (display to user) and stores the hash.
58
+ */
59
+ createCode(targetId: string, type: VerificationCode['type']): {
60
+ code: string;
61
+ expiresAt: Date;
62
+ };
63
+ /**
64
+ * Verify a code attempt. Returns true if valid.
65
+ * Handles attempt counting, expiry, and lockout.
66
+ */
67
+ verifyCode(targetId: string, attempt: string): {
68
+ valid: boolean;
69
+ error?: string;
70
+ };
71
+ }
72
+ /**
73
+ * Manages join requests for admin-only registration.
74
+ */
75
+ export declare class JoinRequestManager {
76
+ private requests;
77
+ private requestsFile;
78
+ constructor(stateDir: string);
79
+ /**
80
+ * Create a new join request.
81
+ */
82
+ createRequest(name: string, telegramUserId: number, agentAssessment: string | null): JoinRequest;
83
+ /**
84
+ * Resolve a join request (approve or deny).
85
+ */
86
+ resolveRequest(approvalCode: string, action: 'approved' | 'denied', resolvedBy: string): JoinRequest | null;
87
+ /**
88
+ * Get pending requests.
89
+ */
90
+ getPendingRequests(): JoinRequest[];
91
+ /**
92
+ * Get a request by Telegram user ID.
93
+ */
94
+ getRequestByTelegramUser(telegramUserId: number): JoinRequest | null;
95
+ private loadRequests;
96
+ private persistRequests;
97
+ }
98
+ /**
99
+ * Build a new user profile from onboarding data.
100
+ */
101
+ export declare function buildUserProfile(opts: {
102
+ name: string;
103
+ userId?: string;
104
+ telegramTopicId?: string;
105
+ telegramUserId?: number;
106
+ email?: string;
107
+ permissions?: string[];
108
+ style?: string;
109
+ autonomyLevel?: 'full' | 'confirm-destructive' | 'confirm-all';
110
+ consent?: ConsentRecord;
111
+ }): UserProfile;
112
+ /**
113
+ * Get the default autonomy config for a given level.
114
+ */
115
+ export declare function getDefaultAutonomyConfig(level: AgentAutonomyConfig['level']): AgentAutonomyConfig;
116
+ //# sourceMappingURL=UserOnboarding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserOnboarding.d.ts","sourceRoot":"","sources":["../../src/users/UserOnboarding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EACV,WAAW,EAEX,mBAAmB,EAEnB,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAsB1B;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,GAAE,MAAqC,GAAG,MAAM,CAK9F;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,GAAE,MAAqC,GAAG,MAAM,CAOzF;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEnD;AAID;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAYhE;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,SAAS,EAAE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B,CAAC,IAAI,EAAE;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,GAAG,qBAAqB,GAAG,aAAa,CAAC;IAC/D,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB,GAAG,WAAW,CAgCd;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,GAAG,mBAAmB,CAuCjG"}
@@ -0,0 +1,365 @@
1
+ /**
2
+ * User Onboarding — handles new user registration and verification flows.
3
+ *
4
+ * Implements the Multi-User Setup Wizard spec (Rev 7):
5
+ * - New user joining an existing agent
6
+ * - Existing user on a new machine (verification)
7
+ * - On-the-fly Telegram registration
8
+ * - Consent collection before data collection
9
+ * - Agent contextual assessment for join requests
10
+ */
11
+ import crypto from 'node:crypto';
12
+ import fs from 'node:fs';
13
+ import path from 'node:path';
14
+ // ── Constants ────────────────────────────────────────────────────────
15
+ const VERIFICATION_DEFAULTS = {
16
+ digits: 6,
17
+ expiryMinutes: 10,
18
+ maxAttempts: 5,
19
+ lockoutMinutes: 30,
20
+ };
21
+ const CONNECT_CODE_DEFAULTS = {
22
+ length: 8,
23
+ expiryMinutes: 15,
24
+ };
25
+ // Unambiguous character set (no 0/O, 1/l/I)
26
+ const UNAMBIGUOUS_CHARS = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789';
27
+ // ── Code Generation ──────────────────────────────────────────────────
28
+ /**
29
+ * Generate a random numeric verification code.
30
+ */
31
+ export function generateVerificationCode(digits = VERIFICATION_DEFAULTS.digits) {
32
+ const max = Math.pow(10, digits);
33
+ const min = Math.pow(10, digits - 1);
34
+ const num = crypto.randomInt(min, max);
35
+ return num.toString();
36
+ }
37
+ /**
38
+ * Generate a cryptographically random alphanumeric connect code
39
+ * using unambiguous characters (no 0/O, 1/l/I).
40
+ */
41
+ export function generateConnectCode(length = CONNECT_CODE_DEFAULTS.length) {
42
+ const bytes = crypto.randomBytes(length);
43
+ let code = '';
44
+ for (let i = 0; i < length; i++) {
45
+ code += UNAMBIGUOUS_CHARS[bytes[i] % UNAMBIGUOUS_CHARS.length];
46
+ }
47
+ return code;
48
+ }
49
+ /**
50
+ * Hash a verification code for storage (we never store plaintext codes).
51
+ */
52
+ export function hashCode(code) {
53
+ return crypto.createHash('sha256').update(code).digest('hex');
54
+ }
55
+ /**
56
+ * Generate a recovery key (32 bytes, displayed as hex).
57
+ */
58
+ export function generateRecoveryKey() {
59
+ return crypto.randomBytes(32).toString('hex');
60
+ }
61
+ /**
62
+ * Hash a recovery key with bcrypt-compatible SHA-256 (for config storage).
63
+ */
64
+ export function hashRecoveryKey(key) {
65
+ return crypto.createHash('sha256').update(key).digest('hex');
66
+ }
67
+ // ── Consent ──────────────────────────────────────────────────────────
68
+ /**
69
+ * Build the consent disclosure text for a given agent name.
70
+ */
71
+ export function buildConsentDisclosure(agentName) {
72
+ return [
73
+ `Before we get started, here's what ${agentName} stores about you:`,
74
+ `- Your name and communication preferences`,
75
+ `- Your Telegram user ID (for identity verification)`,
76
+ `- Conversation history within your personal topic`,
77
+ `- Memory entries created during your sessions (tagged with your user ID)`,
78
+ ``,
79
+ `You can request deletion of your data at any time by asking the agent`,
80
+ `or contacting the admin. Your data is stored locally on the machines`,
81
+ `running this agent and in the git-backed state repository (if enabled).`,
82
+ ].join('\n');
83
+ }
84
+ /**
85
+ * Build a condensed consent disclosure for on-the-fly Telegram registration.
86
+ */
87
+ export function buildCondensedConsentDisclosure(agentName) {
88
+ return `${agentName} will store your name, Telegram ID, and conversation history. You can request deletion anytime. Reply "OK" to continue or "No thanks" to stop.`;
89
+ }
90
+ /**
91
+ * Create a consent record.
92
+ */
93
+ export function createConsentRecord(version) {
94
+ return {
95
+ consentGiven: true,
96
+ consentDate: new Date().toISOString(),
97
+ consentNoticeVersion: version,
98
+ };
99
+ }
100
+ /**
101
+ * Create a default data collected manifest.
102
+ */
103
+ export function createDataManifest(options) {
104
+ return {
105
+ name: true,
106
+ telegramId: false,
107
+ communicationPreferences: true,
108
+ conversationHistory: false,
109
+ memoryEntries: false,
110
+ machineIdentities: false,
111
+ ...options,
112
+ };
113
+ }
114
+ // ── Verification ─────────────────────────────────────────────────────
115
+ /**
116
+ * Manages verification codes with expiry and attempt limits.
117
+ */
118
+ export class VerificationManager {
119
+ codes = new Map();
120
+ lockouts = new Map(); // userId -> lockout expiry timestamp
121
+ /**
122
+ * Create a new verification code for a target.
123
+ * Returns the plaintext code (display to user) and stores the hash.
124
+ */
125
+ createCode(targetId, type) {
126
+ // Check lockout
127
+ const lockoutExpiry = this.lockouts.get(targetId);
128
+ if (lockoutExpiry && Date.now() < lockoutExpiry) {
129
+ const remainingMinutes = Math.ceil((lockoutExpiry - Date.now()) / 60000);
130
+ throw new Error(`Too many failed attempts. Please wait ${remainingMinutes} minutes.`);
131
+ }
132
+ const code = type === 'pairing-code'
133
+ ? generateConnectCode()
134
+ : generateVerificationCode();
135
+ const expiryMinutes = type === 'pairing-code'
136
+ ? CONNECT_CODE_DEFAULTS.expiryMinutes
137
+ : VERIFICATION_DEFAULTS.expiryMinutes;
138
+ const verificationCode = {
139
+ codeHash: hashCode(code),
140
+ createdAt: new Date().toISOString(),
141
+ expiryMinutes,
142
+ maxAttempts: VERIFICATION_DEFAULTS.maxAttempts,
143
+ attempts: 0,
144
+ used: false,
145
+ targetId,
146
+ type,
147
+ };
148
+ this.codes.set(targetId, verificationCode);
149
+ const expiresAt = new Date(Date.now() + expiryMinutes * 60000);
150
+ return { code, expiresAt };
151
+ }
152
+ /**
153
+ * Verify a code attempt. Returns true if valid.
154
+ * Handles attempt counting, expiry, and lockout.
155
+ */
156
+ verifyCode(targetId, attempt) {
157
+ const stored = this.codes.get(targetId);
158
+ if (!stored) {
159
+ return { valid: false, error: 'No verification code found. Please request a new one.' };
160
+ }
161
+ // Check expiry
162
+ const expiryTime = new Date(stored.createdAt).getTime() + stored.expiryMinutes * 60000;
163
+ if (Date.now() > expiryTime) {
164
+ this.codes.delete(targetId);
165
+ return { valid: false, error: 'Code has expired. Please request a new one.' };
166
+ }
167
+ // Check if already used
168
+ if (stored.used) {
169
+ return { valid: false, error: 'Code has already been used. Please request a new one.' };
170
+ }
171
+ // Increment attempts
172
+ stored.attempts++;
173
+ // Check attempt limit
174
+ if (stored.attempts > stored.maxAttempts) {
175
+ this.codes.delete(targetId);
176
+ // Set lockout
177
+ this.lockouts.set(targetId, Date.now() + VERIFICATION_DEFAULTS.lockoutMinutes * 60000);
178
+ return {
179
+ valid: false,
180
+ error: `Too many incorrect attempts. Please wait ${VERIFICATION_DEFAULTS.lockoutMinutes} minutes before requesting a new code.`,
181
+ };
182
+ }
183
+ // Verify
184
+ if (hashCode(attempt) === stored.codeHash) {
185
+ stored.used = true;
186
+ this.codes.delete(targetId);
187
+ return { valid: true };
188
+ }
189
+ const remaining = stored.maxAttempts - stored.attempts;
190
+ return {
191
+ valid: false,
192
+ error: `Incorrect code. ${remaining} attempt${remaining === 1 ? '' : 's'} remaining.`,
193
+ };
194
+ }
195
+ }
196
+ // ── Join Request Management ──────────────────────────────────────────
197
+ /**
198
+ * Manages join requests for admin-only registration.
199
+ */
200
+ export class JoinRequestManager {
201
+ requests = new Map();
202
+ requestsFile;
203
+ constructor(stateDir) {
204
+ this.requestsFile = path.join(stateDir, 'join-requests.json');
205
+ this.loadRequests();
206
+ }
207
+ /**
208
+ * Create a new join request.
209
+ */
210
+ createRequest(name, telegramUserId, agentAssessment) {
211
+ const requestId = crypto.randomBytes(8).toString('hex');
212
+ const approvalCode = crypto.randomBytes(3).toString('hex'); // 6-char hex
213
+ const request = {
214
+ requestId,
215
+ name,
216
+ telegramUserId,
217
+ agentAssessment,
218
+ approvalCode,
219
+ requestedAt: new Date().toISOString(),
220
+ status: 'pending',
221
+ };
222
+ this.requests.set(requestId, request);
223
+ this.persistRequests();
224
+ return request;
225
+ }
226
+ /**
227
+ * Resolve a join request (approve or deny).
228
+ */
229
+ resolveRequest(approvalCode, action, resolvedBy) {
230
+ for (const request of this.requests.values()) {
231
+ if (request.approvalCode === approvalCode && request.status === 'pending') {
232
+ request.status = action;
233
+ request.resolvedBy = resolvedBy;
234
+ request.resolvedAt = new Date().toISOString();
235
+ this.persistRequests();
236
+ return request;
237
+ }
238
+ }
239
+ return null;
240
+ }
241
+ /**
242
+ * Get pending requests.
243
+ */
244
+ getPendingRequests() {
245
+ return Array.from(this.requests.values()).filter(r => r.status === 'pending');
246
+ }
247
+ /**
248
+ * Get a request by Telegram user ID.
249
+ */
250
+ getRequestByTelegramUser(telegramUserId) {
251
+ for (const request of this.requests.values()) {
252
+ if (request.telegramUserId === telegramUserId && request.status === 'pending') {
253
+ return request;
254
+ }
255
+ }
256
+ return null;
257
+ }
258
+ loadRequests() {
259
+ if (fs.existsSync(this.requestsFile)) {
260
+ try {
261
+ const data = JSON.parse(fs.readFileSync(this.requestsFile, 'utf-8'));
262
+ for (const req of data) {
263
+ this.requests.set(req.requestId, req);
264
+ }
265
+ }
266
+ catch {
267
+ // Start fresh on corruption
268
+ }
269
+ }
270
+ }
271
+ persistRequests() {
272
+ const dir = path.dirname(this.requestsFile);
273
+ fs.mkdirSync(dir, { recursive: true });
274
+ const tmpPath = `${this.requestsFile}.${process.pid}.tmp`;
275
+ try {
276
+ fs.writeFileSync(tmpPath, JSON.stringify(Array.from(this.requests.values()), null, 2));
277
+ fs.renameSync(tmpPath, this.requestsFile);
278
+ }
279
+ catch (err) {
280
+ try {
281
+ fs.unlinkSync(tmpPath);
282
+ }
283
+ catch { /* ignore */ }
284
+ throw err;
285
+ }
286
+ }
287
+ }
288
+ // ── Onboarding Flow ──────────────────────────────────────────────────
289
+ /**
290
+ * Build a new user profile from onboarding data.
291
+ */
292
+ export function buildUserProfile(opts) {
293
+ // Generate a URL-safe user ID from the name if not provided
294
+ const userId = opts.userId || opts.name.toLowerCase().replace(/[^a-z0-9]/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '').slice(0, 32) || `user-${crypto.randomBytes(4).toString('hex')}`;
295
+ const channels = [];
296
+ if (opts.telegramTopicId) {
297
+ channels.push({ type: 'telegram', identifier: opts.telegramTopicId });
298
+ }
299
+ if (opts.email) {
300
+ channels.push({ type: 'email', identifier: opts.email });
301
+ }
302
+ const profile = {
303
+ id: userId,
304
+ name: opts.name,
305
+ channels,
306
+ permissions: opts.permissions || ['user'],
307
+ preferences: {
308
+ style: opts.style,
309
+ autonomyLevel: opts.autonomyLevel || 'confirm-destructive',
310
+ },
311
+ consent: opts.consent,
312
+ dataCollected: createDataManifest({
313
+ telegramId: !!opts.telegramTopicId || !!opts.telegramUserId,
314
+ conversationHistory: !!opts.telegramTopicId,
315
+ }),
316
+ pendingTelegramTopic: false,
317
+ createdAt: new Date().toISOString(),
318
+ telegramUserId: opts.telegramUserId,
319
+ };
320
+ return profile;
321
+ }
322
+ /**
323
+ * Get the default autonomy config for a given level.
324
+ */
325
+ export function getDefaultAutonomyConfig(level) {
326
+ switch (level) {
327
+ case 'supervised':
328
+ return {
329
+ level: 'supervised',
330
+ capabilities: {
331
+ assessJoinRequests: false,
332
+ proposeConflictResolution: false,
333
+ recommendConfigChanges: false,
334
+ autoEnableVerifiedJobs: false,
335
+ proactiveStatusAlerts: false,
336
+ autoApproveKnownContacts: false,
337
+ },
338
+ };
339
+ case 'collaborative':
340
+ return {
341
+ level: 'collaborative',
342
+ capabilities: {
343
+ assessJoinRequests: true,
344
+ proposeConflictResolution: true,
345
+ recommendConfigChanges: true,
346
+ autoEnableVerifiedJobs: false,
347
+ proactiveStatusAlerts: true,
348
+ autoApproveKnownContacts: false,
349
+ },
350
+ };
351
+ case 'autonomous':
352
+ return {
353
+ level: 'autonomous',
354
+ capabilities: {
355
+ assessJoinRequests: true,
356
+ proposeConflictResolution: true,
357
+ recommendConfigChanges: true,
358
+ autoEnableVerifiedJobs: true,
359
+ proactiveStatusAlerts: true,
360
+ autoApproveKnownContacts: true,
361
+ },
362
+ };
363
+ }
364
+ }
365
+ //# sourceMappingURL=UserOnboarding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserOnboarding.js","sourceRoot":"","sources":["../../src/users/UserOnboarding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAa7B,wEAAwE;AAExE,MAAM,qBAAqB,GAAG;IAC5B,MAAM,EAAE,CAAC;IACT,aAAa,EAAE,EAAE;IACjB,WAAW,EAAE,CAAC;IACd,cAAc,EAAE,EAAE;CACV,CAAC;AAEX,MAAM,qBAAqB,GAAG;IAC5B,MAAM,EAAE,CAAC;IACT,aAAa,EAAE,EAAE;CACT,CAAC;AAEX,4CAA4C;AAC5C,MAAM,iBAAiB,GAAG,yDAAyD,CAAC;AAEpF,wEAAwE;AAExE;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,SAAiB,qBAAqB,CAAC,MAAM;IACpF,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACvC,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAiB,qBAAqB,CAAC,MAAM;IAC/E,MAAM,KAAK,GAAG,MA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oBAC/B,sBAAsB,EAAE,IAAI;oBAC5B,sBAAsB,EAAE,IAAI;oBAC5B,qBAAqB,EAAE,IAAI;oBAC3B,wBAAwB,EAAE,IAAI;iBAC/B;aACF,CAAC;IACN,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instar",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Persistent autonomy infrastructure for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -24,6 +24,7 @@
24
24
  "test:all": "vitest run && vitest run --config vitest.integration.config.ts && vitest run --config vitest.e2e.config.ts",
25
25
  "lint": "tsc --noEmit",
26
26
  "clean": "rm -rf dist",
27
+ "check:upgrade-guide": "node scripts/check-upgrade-guide.js",
27
28
  "prepublishOnly": "npm run build"
28
29
  },
29
30
  "keywords": [
@@ -0,0 +1,106 @@
1
+ # Upgrade Guide: Instar 0.8.23
2
+
3
+ > This guide covers new capabilities introduced in v0.8.23 through v0.8.26.
4
+
5
+ ## What Changed
6
+
7
+ ### Standalone Agents — Agents Without a Project Directory
8
+ Previously, Instar required a project directory (a git repo) to house `.instar/`. This meant agents couldn't exist independently of a codebase.
9
+
10
+ Now you can create **standalone agents** — agents that live in `~/.instar/agents/<name>/` with no associated project. These are ideal for general-purpose assistants, personal agents, or agents that work across multiple projects.
11
+
12
+ ```bash
13
+ # Create a standalone agent
14
+ instar init --standalone my-agent
15
+
16
+ # Start it
17
+ instar server start --dir ~/.instar/agents/my-agent
18
+ ```
19
+
20
+ ### Global Agent Registry
21
+ All agents (project-based and standalone) are now tracked in a global registry at `~/.instar/registry.json`. This enables:
22
+ - Listing all agents across your machine
23
+ - Coordinating between agents
24
+ - Health monitoring across your agent fleet
25
+
26
+ ### Backup & Restore — Protect Agent State
27
+ A new backup system lets you snapshot and restore your agent's state.
28
+
29
+ ```bash
30
+ instar backup create # Snapshot current state
31
+ instar backup list # See all snapshots
32
+ instar backup restore <id> # Restore from snapshot
33
+ ```
34
+
35
+ Backups capture everything: AGENT.md, MEMORY.md, config, job state, relationships.
36
+
37
+ ### Git-Backed State for Standalone Agents
38
+ Standalone agents can sync their state via git. Useful for multi-machine setups.
39
+
40
+ ```bash
41
+ instar git init # Initialize git tracking
42
+ instar git status # See uncommitted changes
43
+ instar git sync # Commit and push state
44
+ ```
45
+
46
+ ### Memory Search — Find What You've Remembered
47
+ Your MEMORY.md is searchable now. Full-text search across all memory files.
48
+
49
+ ```bash
50
+ instar memory search "project goals" # Search memory
51
+ instar memory index # Re-index for faster search
52
+ instar memory stats # See memory statistics
53
+ ```
54
+
55
+ **What you should do:**
56
+ 1. If you manage multiple agents or want a personal agent, explore `instar init --standalone`.
57
+ 2. Consider setting up `instar backup create` as a regular habit (or add it to a scheduled job).
58
+ 3. Try `instar memory search` to surface things from your MEMORY.md you may have forgotten.
59
+
60
+ ### Multi-Machine Coordination Infrastructure
61
+ Under the hood, significant infrastructure was added for coordinating agents across machines. This powers future capabilities for syncing agent state and coordinating work between machines. No user-facing action needed now.
62
+
63
+ ---
64
+
65
+ ## What Changed: Conversational Notification Tone
66
+ Agent notifications have been tuned to sound more like a colleague than a system alert. Expect updates and status messages to use natural language rather than technical jargon.
67
+
68
+ **What you should do:** Nothing. Just notice that your messages to your user sound more natural. If you have custom notification templates in your jobs, consider whether they match this tone.
69
+
70
+ ---
71
+
72
+ ## What Changed: Telegram Photo Viewing
73
+ When your user sends a photo in Telegram, it's now delivered as `[image:path]` in your message input — a path you can pass directly to Claude for viewing. Previously photos were dropped or passed as raw file references that Claude couldn't process.
74
+
75
+ **What you should do:** If you have photo-handling logic that worked around the old behavior, you may be able to simplify it. Now when you receive `[image:path]`, treat it as a viewable image.
76
+
77
+ ---
78
+
79
+ ## What Changed: Health Check Stability
80
+ The server's health check now uses hysteresis — a brief failure doesn't immediately mark the server as unhealthy. This prevents false-positive health failures during brief transient issues.
81
+
82
+ Also: `ANTHROPIC_API_KEY` is now trimmed of whitespace on startup. Keys with trailing newlines (a common copy-paste artifact) were previously silently failing.
83
+
84
+ **What you should do:** If you experienced flapping health states or mysterious API key errors, this is fixed.
85
+
86
+ ---
87
+
88
+ ## Summary of New Capabilities
89
+
90
+ | Capability | How to Use |
91
+ |-----------|-----------|
92
+ | Standalone agents | `instar init --standalone <name>` |
93
+ | Global registry | `~/.instar/registry.json` — all agents tracked |
94
+ | Backup/restore | `instar backup create/list/restore` |
95
+ | Git-backed state | `instar git init/status/sync` |
96
+ | Memory search | `instar memory search "<query>"` |
97
+ | Photo messages | Receive `[image:path]` — viewable by Claude directly |
98
+ | Health hysteresis | Fewer false-positive health failures |
99
+
100
+ ## What to Tell Your User
101
+
102
+ Pick what's relevant to your context:
103
+ - **Standalone agents**: "Instar can now run agents that aren't tied to a specific project. You could create a dedicated personal assistant this way."
104
+ - **Backup**: "I can now snapshot my own state. Want me to set up regular backups so your preferences and my memory are protected?"
105
+ - **Photo messages**: "I can now see photos you send me in Telegram — just attach them like normal."
106
+ - **Cleaner notifications**: "My messages should sound a bit more natural now — less system-speak."