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.js
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
AINamespace: () => AINamespace,
|
|
24
|
+
AgentsNamespace: () => AgentsNamespace,
|
|
24
25
|
AuthenticationError: () => AuthenticationError,
|
|
25
26
|
Cencori: () => Cencori,
|
|
26
27
|
CencoriError: () => CencoriError,
|
|
@@ -28,8 +29,10 @@ __export(src_exports, {
|
|
|
28
29
|
MemoryClient: () => MemoryClient,
|
|
29
30
|
RateLimitError: () => RateLimitError,
|
|
30
31
|
SafetyError: () => SafetyError,
|
|
32
|
+
SessionsNamespace: () => SessionsNamespace,
|
|
31
33
|
StorageNamespace: () => StorageNamespace,
|
|
32
34
|
TelemetryClient: () => TelemetryClient,
|
|
35
|
+
VisionNamespace: () => VisionNamespace,
|
|
33
36
|
WorkflowNamespace: () => WorkflowNamespace,
|
|
34
37
|
cencori: () => cencori,
|
|
35
38
|
createCencori: () => createCencori,
|
|
@@ -589,6 +592,206 @@ var AINamespace = class {
|
|
|
589
592
|
}
|
|
590
593
|
};
|
|
591
594
|
|
|
595
|
+
// src/agents/index.ts
|
|
596
|
+
var AgentsNamespace = class {
|
|
597
|
+
constructor(config) {
|
|
598
|
+
this.config = config;
|
|
599
|
+
}
|
|
600
|
+
async request(method, path, body) {
|
|
601
|
+
const response = await fetch(`${this.config.baseUrl}${path}`, {
|
|
602
|
+
method,
|
|
603
|
+
headers: {
|
|
604
|
+
"CENCORI_API_KEY": this.config.apiKey,
|
|
605
|
+
"Content-Type": "application/json",
|
|
606
|
+
...this.config.headers
|
|
607
|
+
},
|
|
608
|
+
body: body ? JSON.stringify(body) : void 0
|
|
609
|
+
});
|
|
610
|
+
if (!response.ok) {
|
|
611
|
+
const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
612
|
+
throw new Error(`Cencori API error: ${errorData.error?.message || response.statusText}`);
|
|
613
|
+
}
|
|
614
|
+
if (response.status === 204) return void 0;
|
|
615
|
+
return response.json();
|
|
616
|
+
}
|
|
617
|
+
async create(params) {
|
|
618
|
+
return this.request("POST", "/v1/agents", params);
|
|
619
|
+
}
|
|
620
|
+
async list() {
|
|
621
|
+
return this.request("GET", "/v1/agents");
|
|
622
|
+
}
|
|
623
|
+
async get(agentId) {
|
|
624
|
+
return this.request("GET", `/v1/agents/${agentId}`);
|
|
625
|
+
}
|
|
626
|
+
async updateConfig(agentId, params) {
|
|
627
|
+
return this.request("PATCH", `/v1/agents/${agentId}`, params);
|
|
628
|
+
}
|
|
629
|
+
async delete(agentId) {
|
|
630
|
+
return this.request("DELETE", `/v1/agents/${agentId}`);
|
|
631
|
+
}
|
|
632
|
+
async createKey(agentId, params) {
|
|
633
|
+
return this.request("POST", `/v1/agents/${agentId}/keys`, params || {});
|
|
634
|
+
}
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
// src/vision/index.ts
|
|
638
|
+
function toBody(request) {
|
|
639
|
+
const body = {
|
|
640
|
+
prompt: request.prompt,
|
|
641
|
+
model: request.model,
|
|
642
|
+
max_tokens: request.maxTokens,
|
|
643
|
+
temperature: request.temperature,
|
|
644
|
+
response_format: request.responseFormat
|
|
645
|
+
};
|
|
646
|
+
if (request.image.url) {
|
|
647
|
+
body.image_url = request.image.url;
|
|
648
|
+
} else if (request.image.base64) {
|
|
649
|
+
body.image_base64 = request.image.base64;
|
|
650
|
+
body.mime_type = request.image.mimeType;
|
|
651
|
+
} else {
|
|
652
|
+
throw new Error("vision request requires image.url or image.base64");
|
|
653
|
+
}
|
|
654
|
+
return body;
|
|
655
|
+
}
|
|
656
|
+
var VisionNamespace = class {
|
|
657
|
+
constructor(config) {
|
|
658
|
+
this.config = config;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* General image analysis — provide your own prompt.
|
|
662
|
+
* Default prompt: "Describe this image in detail."
|
|
663
|
+
*/
|
|
664
|
+
async analyze(request) {
|
|
665
|
+
return this.post("/api/ai/vision", request);
|
|
666
|
+
}
|
|
667
|
+
/** Describe the image in rich detail. */
|
|
668
|
+
async describe(request) {
|
|
669
|
+
return this.post("/api/ai/vision/describe", request);
|
|
670
|
+
}
|
|
671
|
+
/** Extract all visible text from the image. */
|
|
672
|
+
async ocr(request) {
|
|
673
|
+
return this.post("/api/ai/vision/ocr", request);
|
|
674
|
+
}
|
|
675
|
+
/** Return structured tags, objects, and category classification. */
|
|
676
|
+
async classify(request) {
|
|
677
|
+
return this.post("/api/ai/vision/classify", request);
|
|
678
|
+
}
|
|
679
|
+
async post(path, request) {
|
|
680
|
+
const response = await fetch(`${this.config.baseUrl}${path}`, {
|
|
681
|
+
method: "POST",
|
|
682
|
+
headers: {
|
|
683
|
+
"CENCORI_API_KEY": this.config.apiKey,
|
|
684
|
+
"Content-Type": "application/json",
|
|
685
|
+
...this.config.headers
|
|
686
|
+
},
|
|
687
|
+
body: JSON.stringify(toBody(request))
|
|
688
|
+
});
|
|
689
|
+
const data = await response.json();
|
|
690
|
+
if (!response.ok) {
|
|
691
|
+
const message = data && typeof data === "object" && "message" in data && typeof data.message === "string" ? data.message : `Vision request failed with status ${response.status}`;
|
|
692
|
+
const code = data && typeof data === "object" && "error" in data && typeof data.error === "string" ? data.error : "request_failed";
|
|
693
|
+
const err = new Error(message);
|
|
694
|
+
err.code = code;
|
|
695
|
+
err.details = data;
|
|
696
|
+
throw err;
|
|
697
|
+
}
|
|
698
|
+
return data;
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
// src/sessions/index.ts
|
|
703
|
+
var SessionsNamespace = class {
|
|
704
|
+
constructor(config) {
|
|
705
|
+
this.config = config;
|
|
706
|
+
}
|
|
707
|
+
async request(method, path, body) {
|
|
708
|
+
const response = await fetch(`${this.config.baseUrl}${path}`, {
|
|
709
|
+
method,
|
|
710
|
+
headers: {
|
|
711
|
+
"CENCORI_API_KEY": this.config.apiKey,
|
|
712
|
+
"Content-Type": "application/json",
|
|
713
|
+
...this.config.headers
|
|
714
|
+
},
|
|
715
|
+
body: body ? JSON.stringify(body) : void 0
|
|
716
|
+
});
|
|
717
|
+
if (!response.ok) {
|
|
718
|
+
const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
719
|
+
throw new Error(`Cencori API error: ${errorData.error?.message || response.statusText}`);
|
|
720
|
+
}
|
|
721
|
+
if (response.status === 204) return void 0;
|
|
722
|
+
return response.json();
|
|
723
|
+
}
|
|
724
|
+
async create(params) {
|
|
725
|
+
return this.request("POST", "/v1/sessions", params || {});
|
|
726
|
+
}
|
|
727
|
+
async list(params) {
|
|
728
|
+
const searchParams = new URLSearchParams();
|
|
729
|
+
if (params?.page) searchParams.set("page", String(params.page));
|
|
730
|
+
if (params?.limit) searchParams.set("limit", String(params.limit));
|
|
731
|
+
if (params?.status) searchParams.set("status", params.status);
|
|
732
|
+
if (params?.agent_id) searchParams.set("agent_id", params.agent_id);
|
|
733
|
+
const qs = searchParams.toString();
|
|
734
|
+
return this.request("GET", `/v1/sessions${qs ? `?${qs}` : ""}`);
|
|
735
|
+
}
|
|
736
|
+
async get(sessionId) {
|
|
737
|
+
return this.request("GET", `/v1/sessions/${sessionId}`);
|
|
738
|
+
}
|
|
739
|
+
async delete(sessionId) {
|
|
740
|
+
return this.request("DELETE", `/v1/sessions/${sessionId}`);
|
|
741
|
+
}
|
|
742
|
+
async submitTurn(sessionId, params) {
|
|
743
|
+
const url = `${this.config.baseUrl}/v1/sessions/${sessionId}/turns`;
|
|
744
|
+
return fetch(url, {
|
|
745
|
+
method: "POST",
|
|
746
|
+
headers: {
|
|
747
|
+
"CENCORI_API_KEY": this.config.apiKey,
|
|
748
|
+
"Content-Type": "application/json",
|
|
749
|
+
...this.config.headers
|
|
750
|
+
},
|
|
751
|
+
body: JSON.stringify(params)
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
async submitTurnStream(sessionId, params) {
|
|
755
|
+
const response = await this.submitTurn(sessionId, params);
|
|
756
|
+
if (!response.ok) {
|
|
757
|
+
const err = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
758
|
+
throw new Error(`Cencori API error: ${err.error?.message || response.statusText}`);
|
|
759
|
+
}
|
|
760
|
+
return response.body;
|
|
761
|
+
}
|
|
762
|
+
async getEvents(sessionId, params) {
|
|
763
|
+
const searchParams = new URLSearchParams();
|
|
764
|
+
if (params?.page) searchParams.set("page", String(params.page));
|
|
765
|
+
if (params?.limit) searchParams.set("limit", String(params.limit));
|
|
766
|
+
if (params?.turn_number) searchParams.set("turn_number", String(params.turn_number));
|
|
767
|
+
const qs = searchParams.toString();
|
|
768
|
+
return this.request("GET", `/v1/sessions/${sessionId}/events${qs ? `?${qs}` : ""}`);
|
|
769
|
+
}
|
|
770
|
+
async approve(sessionId, params) {
|
|
771
|
+
const url = `${this.config.baseUrl}/v1/sessions/${sessionId}/approve`;
|
|
772
|
+
return fetch(url, {
|
|
773
|
+
method: "POST",
|
|
774
|
+
headers: {
|
|
775
|
+
"CENCORI_API_KEY": this.config.apiKey,
|
|
776
|
+
"Content-Type": "application/json",
|
|
777
|
+
...this.config.headers
|
|
778
|
+
},
|
|
779
|
+
body: JSON.stringify(params)
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
async approveStream(sessionId, params) {
|
|
783
|
+
const response = await this.approve(sessionId, params);
|
|
784
|
+
if (!response.ok) {
|
|
785
|
+
const err = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
786
|
+
throw new Error(`Cencori API error: ${err.error?.message || response.statusText}`);
|
|
787
|
+
}
|
|
788
|
+
return response.body;
|
|
789
|
+
}
|
|
790
|
+
async reject(sessionId, params) {
|
|
791
|
+
return this.request("POST", `/v1/sessions/${sessionId}/reject`, params);
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
|
|
592
795
|
// src/compute/index.ts
|
|
593
796
|
var ComputeNamespace = class {
|
|
594
797
|
/**
|
|
@@ -991,7 +1194,7 @@ var SafetyError = class _SafetyError extends CencoriError {
|
|
|
991
1194
|
};
|
|
992
1195
|
|
|
993
1196
|
// src/cencori.ts
|
|
994
|
-
var DEFAULT_BASE_URL = "https://cencori.com";
|
|
1197
|
+
var DEFAULT_BASE_URL = "https://api.cencori.com";
|
|
995
1198
|
var Cencori = class {
|
|
996
1199
|
/**
|
|
997
1200
|
* Create a new Cencori client
|
|
@@ -1019,10 +1222,13 @@ var Cencori = class {
|
|
|
1019
1222
|
headers: config.headers ?? {}
|
|
1020
1223
|
};
|
|
1021
1224
|
this.ai = new AINamespace(this.config);
|
|
1225
|
+
this.vision = new VisionNamespace(this.config);
|
|
1226
|
+
this.agents = new AgentsNamespace(this.config);
|
|
1022
1227
|
this.compute = new ComputeNamespace();
|
|
1023
1228
|
this.workflow = new WorkflowNamespace();
|
|
1024
1229
|
this.storage = new StorageNamespace();
|
|
1025
1230
|
this.memory = new MemoryClient(this.config);
|
|
1231
|
+
this.sessions = new SessionsNamespace(this.config);
|
|
1026
1232
|
this.telemetry = new TelemetryClient(this.config);
|
|
1027
1233
|
}
|
|
1028
1234
|
/**
|
|
@@ -1439,6 +1645,7 @@ cencori.chat = cencori;
|
|
|
1439
1645
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1440
1646
|
0 && (module.exports = {
|
|
1441
1647
|
AINamespace,
|
|
1648
|
+
AgentsNamespace,
|
|
1442
1649
|
AuthenticationError,
|
|
1443
1650
|
Cencori,
|
|
1444
1651
|
CencoriError,
|
|
@@ -1446,8 +1653,10 @@ cencori.chat = cencori;
|
|
|
1446
1653
|
MemoryClient,
|
|
1447
1654
|
RateLimitError,
|
|
1448
1655
|
SafetyError,
|
|
1656
|
+
SessionsNamespace,
|
|
1449
1657
|
StorageNamespace,
|
|
1450
1658
|
TelemetryClient,
|
|
1659
|
+
VisionNamespace,
|
|
1451
1660
|
WorkflowNamespace,
|
|
1452
1661
|
cencori,
|
|
1453
1662
|
createCencori,
|