rscapexai 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/README.md +41 -0
- package/index.d.ts +25 -0
- package/index.js +32 -0
- package/package.json +13 -0
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @rsc/rms
|
|
2
|
+
|
|
3
|
+
Official dependency-free TypeScript/JavaScript client for the RMS public API.
|
|
4
|
+
|
|
5
|
+
The SDK is a protocol client. It does not implement relational memory, reconstruction, OBS, persistence, or cognition.
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import {RMS} from "@rsc/rms";
|
|
9
|
+
|
|
10
|
+
const rms=new RMS({
|
|
11
|
+
apiKey:process.env.RMS_API_KEY,
|
|
12
|
+
baseUrl:process.env.RMS_BASE_URL,
|
|
13
|
+
organizationId:process.env.RMS_ORGANIZATION_ID,
|
|
14
|
+
projectId:process.env.RMS_PROJECT_ID,
|
|
15
|
+
environmentId:process.env.RMS_ENVIRONMENT_ID,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const participant=await rms.createParticipant();
|
|
19
|
+
const relationship=await rms.createRelationship({humanParticipantId:participant.participant.id});
|
|
20
|
+
|
|
21
|
+
const before=await rms.getContext(relationship.relationship.id);
|
|
22
|
+
await rms.addContribution(relationship.relationship.id,{content:"The deployment review happens on Friday."});
|
|
23
|
+
const after=await rms.getContext(relationship.relationship.id);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Initial surfaces
|
|
27
|
+
|
|
28
|
+
- Participants: create, get.
|
|
29
|
+
- Relationships: create, get, context, history.
|
|
30
|
+
- Contributions: add to a relationship.
|
|
31
|
+
- Artifacts: upload relationship-bound images with an idempotency key.
|
|
32
|
+
- Migrations: validate, stage, commit, get.
|
|
33
|
+
- Verification: list current public verification state or read one test/property.
|
|
34
|
+
|
|
35
|
+
Participants, relationships, contributions and verification use the versioned `/v1` RMS API. Artifact and migration methods currently call their existing supported public `/api/apex` routes; the SDK does not invent unavailable `/v1` endpoints.
|
|
36
|
+
|
|
37
|
+
## Boundary
|
|
38
|
+
|
|
39
|
+
`@rsc/rms` owns HTTP concerns: authentication headers, API version headers, tenant-scope serialization, multipart construction, idempotency headers, response parsing and structured errors.
|
|
40
|
+
|
|
41
|
+
RMS behavior remains server-side.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type TenantScope={organizationId:string;projectId:string;environmentId:string};
|
|
2
|
+
export type RMSOptions=TenantScope&{apiKey:string;baseUrl:string;apiVersion?:string;fetch?:typeof globalThis.fetch};
|
|
3
|
+
export type ContributionInput={content:string;episodeId?:string};
|
|
4
|
+
export type RelationshipInput={humanParticipantId:string;aiParticipantId?:string};
|
|
5
|
+
export type MigrationInput={sourceSystem:string;records:unknown[]};
|
|
6
|
+
export type ImageArtifactInput={file:File;accountId:string;humanParticipantId:string;relationshipId:string;aiParticipantId?:string;episodeId?:string;idempotencyKey:string};
|
|
7
|
+
export declare class RMSError extends Error{status:number;body:unknown;constructor(message:string,status:number,body:unknown);}
|
|
8
|
+
export declare class RMS{
|
|
9
|
+
constructor(options:RMSOptions);
|
|
10
|
+
request<T=unknown>(path:string,options?:{method?:string;body?:unknown;headers?:Record<string,string>;rawBody?:BodyInit}):Promise<T>;
|
|
11
|
+
createParticipant<T=unknown>():Promise<T>;
|
|
12
|
+
getParticipant<T=unknown>(id:string):Promise<T>;
|
|
13
|
+
createRelationship<T=unknown>(input:RelationshipInput):Promise<T>;
|
|
14
|
+
getRelationship<T=unknown>(id:string):Promise<T>;
|
|
15
|
+
addContribution<T=unknown>(relationshipId:string,input:ContributionInput):Promise<T>;
|
|
16
|
+
getContext<T=unknown>(relationshipId:string):Promise<T>;
|
|
17
|
+
getHistory<T=unknown>(relationshipId:string):Promise<T>;
|
|
18
|
+
uploadImageArtifact<T=unknown>(input:ImageArtifactInput):Promise<T>;
|
|
19
|
+
validateMigration<T=unknown>(input:MigrationInput):Promise<T>;
|
|
20
|
+
stageMigration<T=unknown>(input:MigrationInput&{idempotencyKey:string}):Promise<T>;
|
|
21
|
+
commitMigration<T=unknown>(input:{migrationId:string;idempotencyKey:string}):Promise<T>;
|
|
22
|
+
getMigration<T=unknown>(migrationId:string):Promise<T>;
|
|
23
|
+
listVerification<T=unknown>():Promise<T>;
|
|
24
|
+
getVerification<T=unknown>(testId:string):Promise<T>;
|
|
25
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export class RMSError extends Error {
|
|
2
|
+
constructor(message,status,body){super(message);this.name="RMSError";this.status=status;this.body=body;}
|
|
3
|
+
}
|
|
4
|
+
function query(scope,extra={}){return new URLSearchParams({...scope,...extra}).toString();}
|
|
5
|
+
export class RMS {
|
|
6
|
+
constructor({apiKey,baseUrl,organizationId,projectId,environmentId,apiVersion="2026-09-21",fetch:fetchImpl=globalThis.fetch}){
|
|
7
|
+
if(!apiKey)throw new Error("apiKey is required.");if(!baseUrl)throw new Error("baseUrl is required.");if(!organizationId||!projectId||!environmentId)throw new Error("organizationId, projectId, and environmentId are required.");if(!fetchImpl)throw new Error("A fetch implementation is required.");
|
|
8
|
+
this.apiKey=apiKey;this.baseUrl=baseUrl.replace(/\/$/,"");this.scope={organizationId,projectId,environmentId};this.apiVersion=apiVersion;this.fetch=fetchImpl;
|
|
9
|
+
}
|
|
10
|
+
async request(path,{method="GET",body,headers={},rawBody}={}){
|
|
11
|
+
const response=await this.fetch(`${this.baseUrl}${path}`,{method,headers:{authorization:`Bearer ${this.apiKey}`,"RSC-APEX-Version":this.apiVersion,...(body===undefined&&rawBody===undefined?{}:rawBody!==undefined?{}:{"content-type":"application/json"}),...headers},...(rawBody!==undefined?{body:rawBody}:body===undefined?{}:{body:JSON.stringify(body)})});
|
|
12
|
+
const text=await response.text();let payload=null;try{payload=text?JSON.parse(text):null;}catch{payload=text;}
|
|
13
|
+
if(!response.ok)throw new RMSError(payload?.error?.message||payload?.reason||`RMS request failed with HTTP ${response.status}.`,response.status,payload);return payload;
|
|
14
|
+
}
|
|
15
|
+
createParticipant(){return this.request("/v1/participants",{method:"POST",body:this.scope});}
|
|
16
|
+
getParticipant(id){return this.request(`/v1/participants/${encodeURIComponent(id)}?${query(this.scope)}`);}
|
|
17
|
+
createRelationship({humanParticipantId,aiParticipantId}){return this.request("/v1/relationships",{method:"POST",body:{...this.scope,humanParticipantId,...(aiParticipantId?{aiParticipantId}:{})}});}
|
|
18
|
+
getRelationship(id){return this.request(`/v1/relationships/${encodeURIComponent(id)}?${query(this.scope)}`);}
|
|
19
|
+
addContribution(relationshipId,{content,episodeId}){return this.request(`/v1/relationships/${encodeURIComponent(relationshipId)}/contributions`,{method:"POST",body:{...this.scope,content,...(episodeId?{episodeId}:{})}});}
|
|
20
|
+
getContext(relationshipId){return this.request(`/v1/relationships/${encodeURIComponent(relationshipId)}/context?${query(this.scope)}`);}
|
|
21
|
+
getHistory(relationshipId){return this.request(`/v1/relationships/${encodeURIComponent(relationshipId)}/history?${query(this.scope)}`);}
|
|
22
|
+
uploadImageArtifact({file,accountId,humanParticipantId,relationshipId,aiParticipantId="ai-apex",episodeId,idempotencyKey}){
|
|
23
|
+
if(!idempotencyKey)throw new Error("idempotencyKey is required.");const form=new FormData();for(const[k,v]of Object.entries({...this.scope,accountId,humanParticipantId,relationshipId,aiParticipantId,...(episodeId?{episodeId}:{})}))form.set(k,v);form.set("file",file);
|
|
24
|
+
return this.request("/api/apex/artifacts/image",{method:"POST",rawBody:form,headers:{"idempotency-key":idempotencyKey}});
|
|
25
|
+
}
|
|
26
|
+
validateMigration({sourceSystem,records}){return this.request("/api/apex/migrations",{method:"POST",body:{...this.scope,sourceSystem,records,dryRun:true}});}
|
|
27
|
+
stageMigration({sourceSystem,records,idempotencyKey}){if(!idempotencyKey)throw new Error("idempotencyKey is required.");return this.request("/api/apex/migrations",{method:"POST",body:{...this.scope,sourceSystem,records,dryRun:false},headers:{"idempotency-key":idempotencyKey}});}
|
|
28
|
+
commitMigration({migrationId,idempotencyKey}){if(!idempotencyKey)throw new Error("idempotencyKey is required.");return this.request("/api/apex/migrations",{method:"PATCH",body:{...this.scope,migrationId,action:"commit"},headers:{"idempotency-key":idempotencyKey}});}
|
|
29
|
+
getMigration(migrationId){return this.request(`/api/apex/migrations?${query(this.scope,{migrationId})}`);}
|
|
30
|
+
listVerification(){return this.request("/v1/verification");}
|
|
31
|
+
getVerification(testId){return this.request(`/v1/verification?testId=${encodeURIComponent(testId)}`);}
|
|
32
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rscapexai",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "APEXAI relational memory SDK with the RSCAPEX cognition bridge.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./index.js",
|
|
7
|
+
"types": "./index.d.ts",
|
|
8
|
+
"exports": { ".": { "types": "./index.d.ts", "import": "./index.js", "default": "./index.js" } },
|
|
9
|
+
"engines": { "node": ">=18" },
|
|
10
|
+
"files": ["index.js", "index.d.ts", "README.md"],
|
|
11
|
+
"dependencies": { "rscapex": "^0.1.0" },
|
|
12
|
+
"license": "UNLICENSED"
|
|
13
|
+
}
|