cencori 1.11.1 → 1.12.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/agents/index.d.mts +20 -0
- package/dist/agents/index.d.ts +20 -0
- package/dist/agents/index.js +26 -4
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/index.mjs +26 -4
- package/dist/agents/index.mjs.map +1 -1
- package/dist/react/index.d.mts +13 -3
- package/dist/react/index.d.ts +13 -3
- package/dist/react/index.js +137 -60
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +137 -60
- package/dist/react/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/agents/index.d.mts
CHANGED
|
@@ -384,6 +384,12 @@ interface AgentOptions<Ctx = unknown, Out = string> {
|
|
|
384
384
|
* `{ widget }` whether or not this is on.
|
|
385
385
|
*/
|
|
386
386
|
widgets?: boolean;
|
|
387
|
+
/**
|
|
388
|
+
* Run an agent stored in Cencori (POST /v1/agents, or the console) by its
|
|
389
|
+
* id: its model, instructions and stored tools apply, and any `tools` you
|
|
390
|
+
* add here run in your process on top. Usually set with Agent.fromCencori().
|
|
391
|
+
*/
|
|
392
|
+
cencoriAgentId?: string;
|
|
387
393
|
}
|
|
388
394
|
/** The model an agent uses when none is given: GPT OSS 120B on Cerebras, chosen for speed. */
|
|
389
395
|
declare const DEFAULT_MODEL = "gpt-oss-120b";
|
|
@@ -412,9 +418,23 @@ declare class Agent<Ctx = unknown, Out = string> {
|
|
|
412
418
|
readonly inputGuardrails: InputGuardrail<Ctx>[];
|
|
413
419
|
readonly outputGuardrails: OutputGuardrail<Ctx>[];
|
|
414
420
|
readonly widgets: boolean;
|
|
421
|
+
readonly cencoriAgentId?: string;
|
|
415
422
|
constructor(options: AgentOptions<Ctx, Out>);
|
|
416
423
|
/** A copy with some options changed. */
|
|
417
424
|
clone(overrides: Partial<AgentOptions<Ctx, Out>>): Agent<Ctx, Out>;
|
|
425
|
+
/**
|
|
426
|
+
* An agent stored in Cencori, run by id. Its model, instructions, stored
|
|
427
|
+
* tools and widgets setting come from Cencori; add local tools, guardrails
|
|
428
|
+
* or handoffs here as for any agent.
|
|
429
|
+
*
|
|
430
|
+
* ```ts
|
|
431
|
+
* const support = Agent.fromCencori('agent_123', { tools: [lookupOrder] });
|
|
432
|
+
* await run(support, 'Where is order 1042?');
|
|
433
|
+
* ```
|
|
434
|
+
*/
|
|
435
|
+
static fromCencori<Ctx = unknown>(agentId: string, options?: Omit<AgentOptions<Ctx, string>, 'cencoriAgentId' | 'name'> & {
|
|
436
|
+
name?: string;
|
|
437
|
+
}): Agent<Ctx, string>;
|
|
418
438
|
/** The tool name a handoff to this agent goes by. */
|
|
419
439
|
static handoffToolName(agent: Agent<any>): string;
|
|
420
440
|
/** Instructions for this run, resolving a function if given. */
|
package/dist/agents/index.d.ts
CHANGED
|
@@ -384,6 +384,12 @@ interface AgentOptions<Ctx = unknown, Out = string> {
|
|
|
384
384
|
* `{ widget }` whether or not this is on.
|
|
385
385
|
*/
|
|
386
386
|
widgets?: boolean;
|
|
387
|
+
/**
|
|
388
|
+
* Run an agent stored in Cencori (POST /v1/agents, or the console) by its
|
|
389
|
+
* id: its model, instructions and stored tools apply, and any `tools` you
|
|
390
|
+
* add here run in your process on top. Usually set with Agent.fromCencori().
|
|
391
|
+
*/
|
|
392
|
+
cencoriAgentId?: string;
|
|
387
393
|
}
|
|
388
394
|
/** The model an agent uses when none is given: GPT OSS 120B on Cerebras, chosen for speed. */
|
|
389
395
|
declare const DEFAULT_MODEL = "gpt-oss-120b";
|
|
@@ -412,9 +418,23 @@ declare class Agent<Ctx = unknown, Out = string> {
|
|
|
412
418
|
readonly inputGuardrails: InputGuardrail<Ctx>[];
|
|
413
419
|
readonly outputGuardrails: OutputGuardrail<Ctx>[];
|
|
414
420
|
readonly widgets: boolean;
|
|
421
|
+
readonly cencoriAgentId?: string;
|
|
415
422
|
constructor(options: AgentOptions<Ctx, Out>);
|
|
416
423
|
/** A copy with some options changed. */
|
|
417
424
|
clone(overrides: Partial<AgentOptions<Ctx, Out>>): Agent<Ctx, Out>;
|
|
425
|
+
/**
|
|
426
|
+
* An agent stored in Cencori, run by id. Its model, instructions, stored
|
|
427
|
+
* tools and widgets setting come from Cencori; add local tools, guardrails
|
|
428
|
+
* or handoffs here as for any agent.
|
|
429
|
+
*
|
|
430
|
+
* ```ts
|
|
431
|
+
* const support = Agent.fromCencori('agent_123', { tools: [lookupOrder] });
|
|
432
|
+
* await run(support, 'Where is order 1042?');
|
|
433
|
+
* ```
|
|
434
|
+
*/
|
|
435
|
+
static fromCencori<Ctx = unknown>(agentId: string, options?: Omit<AgentOptions<Ctx, string>, 'cencoriAgentId' | 'name'> & {
|
|
436
|
+
name?: string;
|
|
437
|
+
}): Agent<Ctx, string>;
|
|
418
438
|
/** The tool name a handoff to this agent goes by. */
|
|
419
439
|
static handoffToolName(agent: Agent<any>): string;
|
|
420
440
|
/** Instructions for this run, resolving a function if given. */
|
package/dist/agents/index.js
CHANGED
|
@@ -827,7 +827,7 @@ var init_transport = __esm({
|
|
|
827
827
|
* predate this answer with the plain session JSON; the turn then goes in a
|
|
828
828
|
* second request, as before.
|
|
829
829
|
*/
|
|
830
|
-
async createSessionWithTurn(metadata, body) {
|
|
830
|
+
async createSessionWithTurn(metadata, body, agentId) {
|
|
831
831
|
const turn = { ...body, stream: true, pause_on_tool_calls: true };
|
|
832
832
|
const response = await this.fetchImpl(`${this.baseUrl}/v1/sessions`, {
|
|
833
833
|
method: "POST",
|
|
@@ -836,7 +836,7 @@ var init_transport = __esm({
|
|
|
836
836
|
"Content-Type": "application/json",
|
|
837
837
|
"Accept": "text/event-stream, application/json"
|
|
838
838
|
},
|
|
839
|
-
body: JSON.stringify({ metadata, turn }),
|
|
839
|
+
body: JSON.stringify({ metadata, turn, ...agentId ? { agent_id: agentId } : {} }),
|
|
840
840
|
signal: this.signal
|
|
841
841
|
});
|
|
842
842
|
const headerId = response.headers.get("X-Cencori-Session-Id") ?? void 0;
|
|
@@ -1018,7 +1018,13 @@ async function* runLoop(startAgent, input, options) {
|
|
|
1018
1018
|
Object.defineProperty(ctx, "__runOptions", { value: options, enumerable: false });
|
|
1019
1019
|
return ctx;
|
|
1020
1020
|
};
|
|
1021
|
-
const nextFor = async (agent2, sessionId2) =>
|
|
1021
|
+
const nextFor = async (agent2, sessionId2) => {
|
|
1022
|
+
if (agent2.cencoriAgentId) {
|
|
1023
|
+
throw new AgentsError(`"${agent2.name}" is stored in Cencori and can't be a handoff target yet. Use ${agent2.name}.asTool() instead.`);
|
|
1024
|
+
}
|
|
1025
|
+
return nextForLocal(agent2, sessionId2);
|
|
1026
|
+
};
|
|
1027
|
+
const nextForLocal = async (agent2, sessionId2) => ({
|
|
1022
1028
|
instructions: await agent2.resolveInstructions(contextFor(agent2, sessionId2)) ?? "",
|
|
1023
1029
|
model: agent2.model,
|
|
1024
1030
|
tools: wireTools(agent2),
|
|
@@ -1074,7 +1080,7 @@ async function* runLoop(startAgent, input, options) {
|
|
|
1074
1080
|
...options.metadata ?? {},
|
|
1075
1081
|
sdk: "cencori/agents",
|
|
1076
1082
|
agent: startAgent.name
|
|
1077
|
-
}, firstTurn);
|
|
1083
|
+
}, firstTurn, agent.cencoriAgentId);
|
|
1078
1084
|
sessionId = created.sessionId;
|
|
1079
1085
|
response = created.response;
|
|
1080
1086
|
}
|
|
@@ -1328,6 +1334,7 @@ var init_agent = __esm({
|
|
|
1328
1334
|
this.inputGuardrails = options.inputGuardrails ?? [];
|
|
1329
1335
|
this.outputGuardrails = options.outputGuardrails ?? [];
|
|
1330
1336
|
this.widgets = options.widgets ?? false;
|
|
1337
|
+
this.cencoriAgentId = options.cencoriAgentId;
|
|
1331
1338
|
const names = /* @__PURE__ */ new Set();
|
|
1332
1339
|
for (const t of [...this.tools.map((t2) => t2.name), ...this.handoffs.map((a) => _Agent.handoffToolName(a))]) {
|
|
1333
1340
|
if (names.has(t)) throw new TypeError(`Agent "${this.name}" has two tools named "${t}".`);
|
|
@@ -1348,9 +1355,24 @@ var init_agent = __esm({
|
|
|
1348
1355
|
inputGuardrails: this.inputGuardrails,
|
|
1349
1356
|
outputGuardrails: this.outputGuardrails,
|
|
1350
1357
|
widgets: this.widgets,
|
|
1358
|
+
cencoriAgentId: this.cencoriAgentId,
|
|
1351
1359
|
...overrides
|
|
1352
1360
|
});
|
|
1353
1361
|
}
|
|
1362
|
+
/**
|
|
1363
|
+
* An agent stored in Cencori, run by id. Its model, instructions, stored
|
|
1364
|
+
* tools and widgets setting come from Cencori; add local tools, guardrails
|
|
1365
|
+
* or handoffs here as for any agent.
|
|
1366
|
+
*
|
|
1367
|
+
* ```ts
|
|
1368
|
+
* const support = Agent.fromCencori('agent_123', { tools: [lookupOrder] });
|
|
1369
|
+
* await run(support, 'Where is order 1042?');
|
|
1370
|
+
* ```
|
|
1371
|
+
*/
|
|
1372
|
+
static fromCencori(agentId, options = {}) {
|
|
1373
|
+
if (!agentId || typeof agentId !== "string") throw new TypeError("Agent.fromCencori needs the stored agent's id.");
|
|
1374
|
+
return new _Agent({ ...options, name: options.name ?? "Agent", cencoriAgentId: agentId });
|
|
1375
|
+
}
|
|
1354
1376
|
/** The tool name a handoff to this agent goes by. */
|
|
1355
1377
|
static handoffToolName(agent) {
|
|
1356
1378
|
const name = `transfer_to_${toolSafe(agent.name)}`.slice(0, 64);
|