@uuaid/agent-commons 0.0.0 → 0.2.0-alpha.4
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/CONFORMANCE.md +26 -0
- package/LICENSE +201 -0
- package/NOTICE +22 -0
- package/PROVENANCE.json +24 -0
- package/README.md +404 -5
- package/bin/agent-commons.mjs +76 -0
- package/examples/Dockerfile +12 -0
- package/examples/agent.mjs +17 -0
- package/examples/global-policy.json +9 -0
- package/examples/run-cohort.mjs +68 -0
- package/package.json +31 -8
- package/profiles/agentnet.chat.json +11 -0
- package/profiles/local.json +11 -0
- package/profiles/zilligon.com.json +11 -0
- package/profiles/zilligons.com.json +11 -0
- package/src/carrier.mjs +84 -0
- package/src/channels.d.mts +75 -0
- package/src/channels.mjs +158 -0
- package/src/cohort.mjs +61 -0
- package/src/collaboration.mjs +875 -0
- package/src/config.mjs +40 -0
- package/src/continuity.d.mts +24 -0
- package/src/continuity.mjs +601 -0
- package/src/governance-scope.d.mts +46 -0
- package/src/governance-scope.mjs +139 -0
- package/src/governance.mjs +355 -0
- package/src/index.d.ts +111 -0
- package/src/index.mjs +15 -0
- package/src/loop.mjs +71 -0
- package/src/offline.d.mts +7 -0
- package/src/offline.mjs +29 -0
- package/src/pillar.mjs +59 -0
- package/src/profiles.d.mts +12 -0
- package/src/profiles.mjs +92 -0
- package/src/relay/auth.mjs +294 -0
- package/src/relay/board.mjs +223 -0
- package/src/relay/claims.mjs +25 -0
- package/src/relay/cli.mjs +49 -0
- package/src/relay/client.mjs +437 -0
- package/src/relay/docs/reconnect-v1.md +27 -0
- package/src/relay/docs/working-rules-v1.md +42 -0
- package/src/relay/enroll.mjs +232 -0
- package/src/relay/export-cli.mjs +47 -0
- package/src/relay/governance.mjs +1328 -0
- package/src/relay/mailbox.mjs +103 -0
- package/src/relay/records.mjs +146 -0
- package/src/relay/render.mjs +38 -0
- package/src/relay/roster.mjs +134 -0
- package/src/relay/routes.mjs +87 -0
- package/src/relay/schema.mjs +1081 -0
- package/src/relay/seed.mjs +89 -0
- package/src/relay/serve.mjs +116 -0
- package/src/relay/server.mjs +633 -0
- package/src/relay/signing.mjs +693 -0
- package/src/relay/test-mode.mjs +73 -0
- package/src/runtime.mjs +359 -0
- package/src/spaces/manifest.mjs +245 -0
- package/src/spaces/pillar-group.mjs +12 -0
- package/src/spaces/policy.mjs +229 -0
- package/src/spaces/store.mjs +325 -0
- package/src/store.mjs +73 -0
- package/src/transport.d.mts +76 -0
- package/src/transport.mjs +267 -0
- package/src/trust.mjs +104 -0
- package/src/uuaid-namespace.d.mts +6 -0
- package/src/uuaid-namespace.mjs +48 -0
- package/src/vendor/pillar/blob/blob.mjs +508 -0
- package/src/vendor/pillar/crypto/e2e.mjs +97 -0
- package/src/vendor/pillar/groups-v2.mjs +1108 -0
- package/src/vendor/pillar/groups.mjs +175 -0
- package/src/vendor/pillar/identity/jcs.mjs +34 -0
- package/src/vendor/pillar/identity/keychain.mjs +241 -0
- package/src/vendor/pillar/identity/tier.mjs +130 -0
- package/src/vendor/pillar/net/carrier-client.mjs +219 -0
- package/src/vendor/pillar/net/delegation.mjs +209 -0
- package/src/vendor/pillar/net/envelope.mjs +258 -0
- package/src/vendor/pillar/net/refusals.mjs +129 -0
- package/src/vendor/pillar/net/seed-tier.mjs +185 -0
package/src/config.mjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, writeFileSync, existsSync, chmodSync } from "node:fs";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { randomBytes } from "node:crypto";
|
|
5
|
+
import { Keychain } from "./pillar.mjs";
|
|
6
|
+
import { createProfile } from "./profiles.mjs";
|
|
7
|
+
import { CommonsStore } from "./store.mjs";
|
|
8
|
+
import { AgentCommons } from "./runtime.mjs";
|
|
9
|
+
import { mintNamespace, RUNTIME_UUAID_NAMESPACE } from "./uuaid-namespace.mjs";
|
|
10
|
+
|
|
11
|
+
export const CAPABILITIES=["commons:message","commons:relay","commons:evolve","commons:contribute","commons:recover"];
|
|
12
|
+
export function homePath(path){return resolve(path??join(homedir(),".agent-commons"))}
|
|
13
|
+
export function saveConfig(home,config){writeFileSync(join(home,"config.json"),JSON.stringify(config,null,2),{mode:0o600});chmodSync(join(home,"config.json"),0o600)}
|
|
14
|
+
export function initialize({home,target="local",name="Agent Commons"}={}){
|
|
15
|
+
home=homePath(home);mkdirSync(home,{recursive:true,mode:0o700});
|
|
16
|
+
if(existsSync(join(home,"config.json"))||existsSync(join(home,"identity.json")))throw new Error("Home already initialized or contains an identity; existing identity was not overwritten");
|
|
17
|
+
// Preserve old prerelease invocations, but all new target configuration uses
|
|
18
|
+
// the production-domain spelling confirmed by the owner.
|
|
19
|
+
if(target==="zilligons.com")target="zilligon.com";
|
|
20
|
+
if(!["local","agentnet.chat","zilligon.com"].includes(target))throw new Error("Supported deployment targets: local, agentnet.chat, zilligon.com");
|
|
21
|
+
const passphrase=process.env.AGENT_COMMONS_PASSPHRASE??randomBytes(32).toString("base64url");
|
|
22
|
+
if(!process.env.AGENT_COMMONS_PASSPHRASE)writeFileSync(join(home,"local-secret"),passphrase,{mode:0o600});
|
|
23
|
+
const keychain=new Keychain(join(home,"identity.json"));keychain.save(Keychain.generate({uuaidNamespace:mintNamespace(RUNTIME_UUAID_NAMESPACE)}),{passphrase});
|
|
24
|
+
const identity=keychain.publicView();
|
|
25
|
+
const config={version:1,name,target,role:"host",carriers:[],policy:{mode:"local",offline:true,registryUrl:"https://api.uuaid.org",authorityUrl:"https://authority.iaaso.org",standardPins:{},blocked:[],agents:{[identity.uuaid]:{kind:"agent",publicKey:identity.publicKeyHex,capabilities:CAPABILITIES}}}};
|
|
26
|
+
saveConfig(home,config);
|
|
27
|
+
const store=new CommonsStore(join(home,"commons.db"));
|
|
28
|
+
const template=JSON.parse(readFileSync(new URL(`../profiles/${target==="local"?"local":target}.json`,import.meta.url),"utf8"));
|
|
29
|
+
const profile=createProfile(template);
|
|
30
|
+
const runtime=new AgentCommons({keychain,store,policy:config.policy});runtime.addProfile(profile);store.close();
|
|
31
|
+
return {home,identity,target,profileId:profile.id,registryRegistration:"not-performed",certified:false,keyProtection:process.env.AGENT_COMMONS_PASSPHRASE?"environment-passphrase":"file-permissions-with-colocated-local-secret"};
|
|
32
|
+
}
|
|
33
|
+
export function loadRuntime(home){
|
|
34
|
+
home=homePath(home);
|
|
35
|
+
const config=JSON.parse(readFileSync(join(home,"config.json"),"utf8"));
|
|
36
|
+
const passphrase=process.env.AGENT_COMMONS_PASSPHRASE??readFileSync(join(home,"local-secret"),"utf8");
|
|
37
|
+
const keychain=new Keychain(join(home,"identity.json"));keychain.load({passphrase});
|
|
38
|
+
const store=new CommonsStore(join(home,"commons.db"));
|
|
39
|
+
return {home,config,keychain,store,runtime:new AgentCommons({keychain,store,policy:config.policy,carriers:config.carriers})};
|
|
40
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type ProvenanceSource = "self"|"peer"|"operator"|"tool";
|
|
2
|
+
export interface ContinuityStore {get(key:string,fallback?:unknown):any;set(key:string,value:unknown):void;transaction?<T>(fn:()=>T):T}
|
|
3
|
+
export interface MemoryKeychain {_identity:{uuaid:string;publicKeyHex:string};sign(bytes:Buffer):Buffer}
|
|
4
|
+
export interface MemoryClient {saveMemory(agent:string,slot:string,text:string,key:string):Promise<any>;loadMemory(agent:string,slot:string,key:string):Promise<string>}
|
|
5
|
+
export interface ContinuityEntry {id:string;seq:number;kind:string;content:any;hash:string;signature:string;at:string;provenance:any}
|
|
6
|
+
export interface ContinuityOptions {keychain:MemoryKeychain;store?:ContinuityStore;client?:MemoryClient|null;vaultKey?:string|null;slot?:string;limits?:{maxEntries?:number;maxBytes?:number;maxEntryBytes?:number;retentionMs?:number};now?:()=>number}
|
|
7
|
+
export declare class ContinuityMemory {
|
|
8
|
+
constructor(options:ContinuityOptions);
|
|
9
|
+
readonly uuaid:string;readonly publicKey:string;
|
|
10
|
+
remember(kind:string,content:unknown,provenance?:{source?:ProvenanceSource;actor?:string;origin?:string|null;evidence?:string|null;pin?:boolean}):ContinuityEntry;
|
|
11
|
+
recall(filter?:{kind?:string;since?:string;source?:ProvenanceSource;limit?:number}):ContinuityEntry[];
|
|
12
|
+
verify():boolean;head():string;status():any;
|
|
13
|
+
snapshot():any;
|
|
14
|
+
reload():any;compact():any;expired():any;
|
|
15
|
+
push():Promise<any>;pull():Promise<any>;sync():Promise<any>;
|
|
16
|
+
static storeKey(uuaid:string):string;
|
|
17
|
+
static quarantine(store:ContinuityStore,uuaid:string):string|null;
|
|
18
|
+
}
|
|
19
|
+
export declare class ContinuityError extends Error {code:string}
|
|
20
|
+
export declare class MemoryContinuityStore implements ContinuityStore {get(key:string,fallback?:unknown):any;set(key:string,value:unknown):void;transaction<T>(fn:()=>T):T}
|
|
21
|
+
export declare const CONTINUITY_PROTOCOL:string;
|
|
22
|
+
export declare const PROVENANCE_SOURCES:readonly ProvenanceSource[];
|
|
23
|
+
export declare function validateSlot(slot:string):string;
|
|
24
|
+
export declare function verifyContinuity(state:unknown,owner:unknown,options?:any):any;
|