a tool to help your Letta AI agents navigate bluesky

Merge pull request #4 from taurean/refactor-lexicon-use

Add @voyager/autonomy-lexicon dependency, refactor to remove local le…

authored by taurean.bryant.land and committed by GitHub 94860443 13671142

Changed files
+35 -138
scripts
utils
+2 -1
deno.json
··· 12 12 "@js-temporal/polyfill": "npm:@js-temporal/polyfill", 13 13 "@atproto/api": "npm:@atproto/api", 14 14 "@atproto/lexicon": "npm:@atproto/lexicon", 15 - "@letta-ai/letta-client": "npm:@letta-ai/letta-client" 15 + "@letta-ai/letta-client": "npm:@letta-ai/letta-client", 16 + "@voyager/autonomy-lexicon": "jsr:@voyager/autonomy-lexicon@^0.1.1" 16 17 } 17 18 }
+5
deno.lock
··· 4 4 "jsr:@std/assert@1": "1.0.15", 5 5 "jsr:@std/datetime@*": "0.225.5", 6 6 "jsr:@std/internal@^1.0.12": "1.0.12", 7 + "jsr:@voyager/autonomy-lexicon@~0.1.1": "0.1.1", 7 8 "npm:@atproto/api@*": "0.17.2", 8 9 "npm:@atproto/lexicon@*": "0.5.1", 9 10 "npm:@js-temporal/polyfill@*": "0.5.1", ··· 21 22 }, 22 23 "@std/internal@1.0.12": { 23 24 "integrity": "972a634fd5bc34b242024402972cd5143eac68d8dffaca5eaa4dba30ce17b027" 25 + }, 26 + "@voyager/autonomy-lexicon@0.1.1": { 27 + "integrity": "8513c44206ff22ab03c82207cbb5720683f9d4fc76e41d64c4815194fd93f48b" 24 28 } 25 29 }, 26 30 "npm": { ··· 357 361 "dependencies": [ 358 362 "jsr:@std/assert@1", 359 363 "jsr:@std/datetime@*", 364 + "jsr:@voyager/autonomy-lexicon@~0.1.1", 360 365 "npm:@atproto/api@*", 361 366 "npm:@atproto/lexicon@*", 362 367 "npm:@js-temporal/polyfill@*",
+3 -3
scripts/publishSchema.ts
··· 22 22 */ 23 23 24 24 import { AtpAgent } from "@atproto/api"; 25 - import { AUTONOMY_DECLARATION_LEXICON } from "../utils/declaration.ts"; 25 + import { AUTONOMY_DECLARATION_LEXICON } from "@voyager/autonomy-lexicon"; 26 26 27 27 const publishSchema = async () => { 28 28 console.log("🔧 Publishing studio.voyager.account.autonomy schema...\n"); ··· 111 111 }); 112 112 113 113 console.log(`✅ Schema ${existingSchema ? "updated" : "published"} successfully!\n`); 114 - console.log(`📍 AT-URI: ${result.uri}`); 115 - console.log(`🔗 CID: ${result.cid}\n`); 114 + console.log(`📍 AT-URI: ${result.data.uri}`); 115 + console.log(`🔗 CID: ${result.data.cid}\n`); 116 116 117 117 // Verify DNS setup 118 118 console.log("🔍 Next steps:");
+16 -102
utils/declaration.ts
··· 1 1 import { bsky } from "../utils/bsky.ts"; 2 - import type { AutonomyDeclarationRecord } from "./types.ts"; 2 + import type { AutonomyDeclaration } from "@voyager/autonomy-lexicon"; 3 + import { AUTONOMY_DECLARATION_LEXICON } from "@voyager/autonomy-lexicon"; 3 4 import { Lexicons } from "@atproto/lexicon"; 4 5 import { agentContext } from "./agentContext.ts"; 5 6 6 7 /** 7 - * Autonomy Declaration Lexicon Schema 8 + * AT Protocol record type that includes the $type property 9 + * Includes index signature for compatibility with AT Protocol API 10 + */ 11 + type AutonomyDeclarationRecord = AutonomyDeclaration & { 12 + $type: "studio.voyager.account.autonomy"; 13 + [key: string]: unknown; 14 + }; 15 + 16 + /** 17 + * Autonomy Declaration Lexicon 8 18 * 9 - * This defines the canonical schema for AI agent autonomy declarations 10 - * in AT Protocol. The schema is published at voyager.studio and is 11 - * used by all Cloudseeding template instances. 19 + * The schema is imported from @voyager/autonomy-lexicon package and 20 + * is published at voyager.studio for use by all Cloudseeding instances. 12 21 * 13 22 * Schema vs. Records: 14 23 * - The SCHEMA is published once by voyager.studio (domain owner) ··· 19 28 * create their own autonomy declaration record (done automatically 20 29 * by submitAutonomyDeclarationRecord below). 21 30 * 22 - * See SCHEMA.md for full documentation. 31 + * Canonical source: jsr:@voyager/autonomy-lexicon 23 32 */ 24 - export const AUTONOMY_DECLARATION_LEXICON = { 25 - "lexicon": 1, 26 - "id": "studio.voyager.account.autonomy", 27 - "defs": { 28 - "main": { 29 - "type": "record", 30 - "key": "literal:self", 31 - "record": { 32 - "type": "object", 33 - "properties": { 34 - "automationLevel": { 35 - "type": "string", 36 - "knownValues": [ 37 - "human", 38 - "assisted", 39 - "collaborative", 40 - "automated", 41 - ], 42 - "description": 43 - "Level of automation in account management and content creation", 44 - }, 45 - "usesGenerativeAI": { 46 - "type": "boolean", 47 - "description": 48 - "Whether this account uses generative AI (LLMs, image generation, etc.) to create content", 49 - }, 50 - "description": { 51 - "type": "string", 52 - "maxGraphemes": 300, 53 - "description": 54 - "Plain language explanation of how this account is automated and what it does", 55 - }, 56 - "responsibleParty": { 57 - "type": "object", 58 - "properties": { 59 - "type": { 60 - "type": "string", 61 - "knownValues": [ 62 - "person", 63 - "organization", 64 - ], 65 - "description": 66 - "Whether the responsible party is a person or organization", 67 - }, 68 - "name": { 69 - "type": "string", 70 - "maxGraphemes": 100, 71 - "description": "Name of the person or organization responsible", 72 - }, 73 - "contact": { 74 - "type": "string", 75 - "maxLength": 300, 76 - "description": 77 - "Contact information (email, URL, handle, or DID)", 78 - }, 79 - "did": { 80 - "type": "string", 81 - "format": "did", 82 - "description": 83 - "DID of the responsible party if they have an ATProto identity", 84 - }, 85 - }, 86 - "description": 87 - "Information about who is accountable for this account's automated behavior", 88 - }, 89 - "disclosureUrl": { 90 - "type": "string", 91 - "format": "uri", 92 - "description": 93 - "URL with additional information about this account's automation", 94 - }, 95 - "externalServices": { 96 - "type": "array", 97 - "items": { 98 - "type": "string", 99 - "maxLength": 200, 100 - }, 101 - "maxLength": 20, 102 - "description": 103 - "External tools and services this agent relies on outside of Bluesky (e.g., 'Letta', 'Railway', 'Google Gemini 2.5-pro')", 104 - }, 105 - "createdAt": { 106 - "type": "string", 107 - "format": "datetime", 108 - "description": "Timestamp when this declaration was created", 109 - }, 110 - }, 111 - "required": [ 112 - "createdAt", 113 - ], 114 - }, 115 - "description": 116 - "Declaration of automation and AI usage for transparency and accountability", 117 - }, 118 - }, 119 - }; 33 + export { AUTONOMY_DECLARATION_LEXICON }; 120 34 121 35 export const createAutonomyDeclarationRecord = async () => { 122 36 const automationLevel = Deno.env.get("AUTOMATION_LEVEL")?.toLowerCase();
+9 -32
utils/types.ts
··· 6 6 validAutomationLevels, 7 7 validNotifTypes, 8 8 } from "./const.ts"; 9 + import type { 10 + AutomationLevel, 11 + ResponsiblePartyType, 12 + AutonomyDeclaration, 13 + ResponsibleParty, 14 + } from "@voyager/autonomy-lexicon"; 15 + 9 16 export type Notification = AppBskyNotificationListNotifications.Notification; 10 17 11 - export type AutomationLevel = typeof validAutomationLevels[number]; 12 - export type ResponsiblePartyType = "person" | "organization"; 18 + // Re-export types from autonomy-lexicon package 19 + export type { AutomationLevel, ResponsiblePartyType, AutonomyDeclaration, ResponsibleParty }; 13 20 14 21 export type notifType = typeof validNotifTypes[number]; 15 22 ··· 65 72 disclosureUrl?: string; // url to a ToS/Privacy Policy style page 66 73 responsiblePartyBsky?: string; // handle w/o @ or DID of responsible party 67 74 externalServices?: string[]; // external tools/services this agent relies on 68 - }; 69 - 70 - export type AutonomyDeclarationRecord = { 71 - $type: "studio.voyager.account.autonomy"; 72 - 73 - // How automated is this account? 74 - automationLevel?: "human" | "assisted" | "collaborative" | "automated"; 75 - 76 - // Is AI involved in content creation? 77 - usesGenerativeAI?: boolean; 78 - 79 - // Plain language explanation 80 - description?: string; // maxGraphemes: 300 81 - 82 - // Who is accountable for this account? 83 - responsibleParty?: { 84 - type?: "person" | "organization"; 85 - name?: string; 86 - contact?: string; // email, URL, handle, or DID 87 - did?: string; // ATProto DID 88 - }; 89 - 90 - // Where can someone learn more? 91 - disclosureUrl?: string; // URI format 92 - 93 - // What external tools/services does this agent rely on? 94 - externalServices?: string[]; // e.g., ["Letta", "Railway", "Google Gemini 2.5-pro"] 95 - 96 - // When was this declaration created? 97 - createdAt: string; // ISO datetime (required) 98 75 }; 99 76 100 77 export type memoryBlock = {