cencori 1.2.1 → 1.3.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/dist/index.d.mts +206 -2
- package/dist/index.d.ts +206 -2
- package/dist/index.js +210 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +207 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +52 -0
- package/dist/react/index.d.ts +52 -0
- package/dist/react/index.js +395 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/index.mjs +367 -0
- package/dist/react/index.mjs.map +1 -0
- package/dist/vision/index.d.mts +99 -0
- package/dist/vision/index.d.ts +99 -0
- package/dist/vision/index.js +93 -0
- package/dist/vision/index.js.map +1 -0
- package/dist/vision/index.mjs +68 -0
- package/dist/vision/index.mjs.map +1 -0
- package/package.json +20 -2
package/dist/index.mjs
CHANGED
|
@@ -549,6 +549,206 @@ var AINamespace = class {
|
|
|
549
549
|
}
|
|
550
550
|
};
|
|
551
551
|
|
|
552
|
+
// src/agents/index.ts
|
|
553
|
+
var AgentsNamespace = class {
|
|
554
|
+
constructor(config) {
|
|
555
|
+
this.config = config;
|
|
556
|
+
}
|
|
557
|
+
async request(method, path, body) {
|
|
558
|
+
const response = await fetch(`${this.config.baseUrl}${path}`, {
|
|
559
|
+
method,
|
|
560
|
+
headers: {
|
|
561
|
+
"CENCORI_API_KEY": this.config.apiKey,
|
|
562
|
+
"Content-Type": "application/json",
|
|
563
|
+
...this.config.headers
|
|
564
|
+
},
|
|
565
|
+
body: body ? JSON.stringify(body) : void 0
|
|
566
|
+
});
|
|
567
|
+
if (!response.ok) {
|
|
568
|
+
const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
569
|
+
throw new Error(`Cencori API error: ${errorData.error?.message || response.statusText}`);
|
|
570
|
+
}
|
|
571
|
+
if (response.status === 204) return void 0;
|
|
572
|
+
return response.json();
|
|
573
|
+
}
|
|
574
|
+
async create(params) {
|
|
575
|
+
return this.request("POST", "/v1/agents", params);
|
|
576
|
+
}
|
|
577
|
+
async list() {
|
|
578
|
+
return this.request("GET", "/v1/agents");
|
|
579
|
+
}
|
|
580
|
+
async get(agentId) {
|
|
581
|
+
return this.request("GET", `/v1/agents/${agentId}`);
|
|
582
|
+
}
|
|
583
|
+
async updateConfig(agentId, params) {
|
|
584
|
+
return this.request("PATCH", `/v1/agents/${agentId}`, params);
|
|
585
|
+
}
|
|
586
|
+
async delete(agentId) {
|
|
587
|
+
return this.request("DELETE", `/v1/agents/${agentId}`);
|
|
588
|
+
}
|
|
589
|
+
async createKey(agentId, params) {
|
|
590
|
+
return this.request("POST", `/v1/agents/${agentId}/keys`, params || {});
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
// src/vision/index.ts
|
|
595
|
+
function toBody(request) {
|
|
596
|
+
const body = {
|
|
597
|
+
prompt: request.prompt,
|
|
598
|
+
model: request.model,
|
|
599
|
+
max_tokens: request.maxTokens,
|
|
600
|
+
temperature: request.temperature,
|
|
601
|
+
response_format: request.responseFormat
|
|
602
|
+
};
|
|
603
|
+
if (request.image.url) {
|
|
604
|
+
body.image_url = request.image.url;
|
|
605
|
+
} else if (request.image.base64) {
|
|
606
|
+
body.image_base64 = request.image.base64;
|
|
607
|
+
body.mime_type = request.image.mimeType;
|
|
608
|
+
} else {
|
|
609
|
+
throw new Error("vision request requires image.url or image.base64");
|
|
610
|
+
}
|
|
611
|
+
return body;
|
|
612
|
+
}
|
|
613
|
+
var VisionNamespace = class {
|
|
614
|
+
constructor(config) {
|
|
615
|
+
this.config = config;
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* General image analysis — provide your own prompt.
|
|
619
|
+
* Default prompt: "Describe this image in detail."
|
|
620
|
+
*/
|
|
621
|
+
async analyze(request) {
|
|
622
|
+
return this.post("/api/ai/vision", request);
|
|
623
|
+
}
|
|
624
|
+
/** Describe the image in rich detail. */
|
|
625
|
+
async describe(request) {
|
|
626
|
+
return this.post("/api/ai/vision/describe", request);
|
|
627
|
+
}
|
|
628
|
+
/** Extract all visible text from the image. */
|
|
629
|
+
async ocr(request) {
|
|
630
|
+
return this.post("/api/ai/vision/ocr", request);
|
|
631
|
+
}
|
|
632
|
+
/** Return structured tags, objects, and category classification. */
|
|
633
|
+
async classify(request) {
|
|
634
|
+
return this.post("/api/ai/vision/classify", request);
|
|
635
|
+
}
|
|
636
|
+
async post(path, request) {
|
|
637
|
+
const response = await fetch(`${this.config.baseUrl}${path}`, {
|
|
638
|
+
method: "POST",
|
|
639
|
+
headers: {
|
|
640
|
+
"CENCORI_API_KEY": this.config.apiKey,
|
|
641
|
+
"Content-Type": "application/json",
|
|
642
|
+
...this.config.headers
|
|
643
|
+
},
|
|
644
|
+
body: JSON.stringify(toBody(request))
|
|
645
|
+
});
|
|
646
|
+
const data = await response.json();
|
|
647
|
+
if (!response.ok) {
|
|
648
|
+
const message = data && typeof data === "object" && "message" in data && typeof data.message === "string" ? data.message : `Vision request failed with status ${response.status}`;
|
|
649
|
+
const code = data && typeof data === "object" && "error" in data && typeof data.error === "string" ? data.error : "request_failed";
|
|
650
|
+
const err = new Error(message);
|
|
651
|
+
err.code = code;
|
|
652
|
+
err.details = data;
|
|
653
|
+
throw err;
|
|
654
|
+
}
|
|
655
|
+
return data;
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
// src/sessions/index.ts
|
|
660
|
+
var SessionsNamespace = class {
|
|
661
|
+
constructor(config) {
|
|
662
|
+
this.config = config;
|
|
663
|
+
}
|
|
664
|
+
async request(method, path, body) {
|
|
665
|
+
const response = await fetch(`${this.config.baseUrl}${path}`, {
|
|
666
|
+
method,
|
|
667
|
+
headers: {
|
|
668
|
+
"CENCORI_API_KEY": this.config.apiKey,
|
|
669
|
+
"Content-Type": "application/json",
|
|
670
|
+
...this.config.headers
|
|
671
|
+
},
|
|
672
|
+
body: body ? JSON.stringify(body) : void 0
|
|
673
|
+
});
|
|
674
|
+
if (!response.ok) {
|
|
675
|
+
const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
676
|
+
throw new Error(`Cencori API error: ${errorData.error?.message || response.statusText}`);
|
|
677
|
+
}
|
|
678
|
+
if (response.status === 204) return void 0;
|
|
679
|
+
return response.json();
|
|
680
|
+
}
|
|
681
|
+
async create(params) {
|
|
682
|
+
return this.request("POST", "/v1/sessions", params || {});
|
|
683
|
+
}
|
|
684
|
+
async list(params) {
|
|
685
|
+
const searchParams = new URLSearchParams();
|
|
686
|
+
if (params?.page) searchParams.set("page", String(params.page));
|
|
687
|
+
if (params?.limit) searchParams.set("limit", String(params.limit));
|
|
688
|
+
if (params?.status) searchParams.set("status", params.status);
|
|
689
|
+
if (params?.agent_id) searchParams.set("agent_id", params.agent_id);
|
|
690
|
+
const qs = searchParams.toString();
|
|
691
|
+
return this.request("GET", `/v1/sessions${qs ? `?${qs}` : ""}`);
|
|
692
|
+
}
|
|
693
|
+
async get(sessionId) {
|
|
694
|
+
return this.request("GET", `/v1/sessions/${sessionId}`);
|
|
695
|
+
}
|
|
696
|
+
async delete(sessionId) {
|
|
697
|
+
return this.request("DELETE", `/v1/sessions/${sessionId}`);
|
|
698
|
+
}
|
|
699
|
+
async submitTurn(sessionId, params) {
|
|
700
|
+
const url = `${this.config.baseUrl}/v1/sessions/${sessionId}/turns`;
|
|
701
|
+
return fetch(url, {
|
|
702
|
+
method: "POST",
|
|
703
|
+
headers: {
|
|
704
|
+
"CENCORI_API_KEY": this.config.apiKey,
|
|
705
|
+
"Content-Type": "application/json",
|
|
706
|
+
...this.config.headers
|
|
707
|
+
},
|
|
708
|
+
body: JSON.stringify(params)
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
async submitTurnStream(sessionId, params) {
|
|
712
|
+
const response = await this.submitTurn(sessionId, params);
|
|
713
|
+
if (!response.ok) {
|
|
714
|
+
const err = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
715
|
+
throw new Error(`Cencori API error: ${err.error?.message || response.statusText}`);
|
|
716
|
+
}
|
|
717
|
+
return response.body;
|
|
718
|
+
}
|
|
719
|
+
async getEvents(sessionId, params) {
|
|
720
|
+
const searchParams = new URLSearchParams();
|
|
721
|
+
if (params?.page) searchParams.set("page", String(params.page));
|
|
722
|
+
if (params?.limit) searchParams.set("limit", String(params.limit));
|
|
723
|
+
if (params?.turn_number) searchParams.set("turn_number", String(params.turn_number));
|
|
724
|
+
const qs = searchParams.toString();
|
|
725
|
+
return this.request("GET", `/v1/sessions/${sessionId}/events${qs ? `?${qs}` : ""}`);
|
|
726
|
+
}
|
|
727
|
+
async approve(sessionId, params) {
|
|
728
|
+
const url = `${this.config.baseUrl}/v1/sessions/${sessionId}/approve`;
|
|
729
|
+
return fetch(url, {
|
|
730
|
+
method: "POST",
|
|
731
|
+
headers: {
|
|
732
|
+
"CENCORI_API_KEY": this.config.apiKey,
|
|
733
|
+
"Content-Type": "application/json",
|
|
734
|
+
...this.config.headers
|
|
735
|
+
},
|
|
736
|
+
body: JSON.stringify(params)
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
async approveStream(sessionId, params) {
|
|
740
|
+
const response = await this.approve(sessionId, params);
|
|
741
|
+
if (!response.ok) {
|
|
742
|
+
const err = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
743
|
+
throw new Error(`Cencori API error: ${err.error?.message || response.statusText}`);
|
|
744
|
+
}
|
|
745
|
+
return response.body;
|
|
746
|
+
}
|
|
747
|
+
async reject(sessionId, params) {
|
|
748
|
+
return this.request("POST", `/v1/sessions/${sessionId}/reject`, params);
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
|
|
552
752
|
// src/compute/index.ts
|
|
553
753
|
var ComputeNamespace = class {
|
|
554
754
|
/**
|
|
@@ -951,7 +1151,7 @@ var SafetyError = class _SafetyError extends CencoriError {
|
|
|
951
1151
|
};
|
|
952
1152
|
|
|
953
1153
|
// src/cencori.ts
|
|
954
|
-
var DEFAULT_BASE_URL = "https://cencori.com";
|
|
1154
|
+
var DEFAULT_BASE_URL = "https://api.cencori.com";
|
|
955
1155
|
var Cencori = class {
|
|
956
1156
|
/**
|
|
957
1157
|
* Create a new Cencori client
|
|
@@ -979,10 +1179,13 @@ var Cencori = class {
|
|
|
979
1179
|
headers: config.headers ?? {}
|
|
980
1180
|
};
|
|
981
1181
|
this.ai = new AINamespace(this.config);
|
|
1182
|
+
this.vision = new VisionNamespace(this.config);
|
|
1183
|
+
this.agents = new AgentsNamespace(this.config);
|
|
982
1184
|
this.compute = new ComputeNamespace();
|
|
983
1185
|
this.workflow = new WorkflowNamespace();
|
|
984
1186
|
this.storage = new StorageNamespace();
|
|
985
1187
|
this.memory = new MemoryClient(this.config);
|
|
1188
|
+
this.sessions = new SessionsNamespace(this.config);
|
|
986
1189
|
this.telemetry = new TelemetryClient(this.config);
|
|
987
1190
|
}
|
|
988
1191
|
/**
|
|
@@ -1398,6 +1601,7 @@ var cencori = function(modelId, settings) {
|
|
|
1398
1601
|
cencori.chat = cencori;
|
|
1399
1602
|
export {
|
|
1400
1603
|
AINamespace,
|
|
1604
|
+
AgentsNamespace,
|
|
1401
1605
|
AuthenticationError,
|
|
1402
1606
|
Cencori,
|
|
1403
1607
|
CencoriError,
|
|
@@ -1405,8 +1609,10 @@ export {
|
|
|
1405
1609
|
MemoryClient,
|
|
1406
1610
|
RateLimitError,
|
|
1407
1611
|
SafetyError,
|
|
1612
|
+
SessionsNamespace,
|
|
1408
1613
|
StorageNamespace,
|
|
1409
1614
|
TelemetryClient,
|
|
1615
|
+
VisionNamespace,
|
|
1410
1616
|
WorkflowNamespace,
|
|
1411
1617
|
cencori,
|
|
1412
1618
|
createCencori,
|