@agent-os-sdk/client 0.7.13 → 0.8.1
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/client/AgentOsClient.d.ts +25 -23
- package/dist/client/AgentOsClient.d.ts.map +1 -1
- package/dist/client/AgentOsClient.js +26 -22
- package/dist/modules/presets.d.ts +32 -0
- package/dist/modules/presets.d.ts.map +1 -0
- package/dist/modules/presets.js +128 -0
- package/package.json +2 -2
- package/src/client/AgentOsClient.ts +27 -24
- package/src/modules/presets.ts +176 -0
|
@@ -26,43 +26,44 @@
|
|
|
26
26
|
* });
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
|
-
import { type RawClient } from "./raw.js";
|
|
30
29
|
import { type AgentOsClientOptions } from "./auth.js";
|
|
30
|
+
import { type RawClient } from "./raw.js";
|
|
31
31
|
import { AgentsModule } from "../modules/agents.js";
|
|
32
|
+
import { BuilderModule } from "../modules/builder.js";
|
|
33
|
+
import { CredentialsModule } from "../modules/credentials.js";
|
|
34
|
+
import { KnowledgeModule } from "../modules/knowledge.js";
|
|
35
|
+
import { MembersModule } from "../modules/members.js";
|
|
32
36
|
import { RunsModule } from "../modules/runs.js";
|
|
37
|
+
import { TenantsModule } from "../modules/tenants.js";
|
|
33
38
|
import { ThreadsModule } from "../modules/threads.js";
|
|
34
39
|
import { ToolsModule } from "../modules/tools.js";
|
|
35
|
-
import { KnowledgeModule } from "../modules/knowledge.js";
|
|
36
40
|
import { TriggersModule } from "../modules/triggers.js";
|
|
37
|
-
import { CredentialsModule } from "../modules/credentials.js";
|
|
38
|
-
import { BuilderModule } from "../modules/builder.js";
|
|
39
|
-
import { MembersModule } from "../modules/members.js";
|
|
40
|
-
import { TenantsModule } from "../modules/tenants.js";
|
|
41
41
|
import { WorkspacesModule } from "../modules/workspaces.js";
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
42
|
+
import { A2aModule } from "../modules/a2a.js";
|
|
43
|
+
import { ApiTokensModule } from "../modules/apiTokens.js";
|
|
44
|
+
import { ApprovalsModule } from "../modules/approvals.js";
|
|
45
|
+
import { AuditModule } from "../modules/audit.js";
|
|
46
|
+
import { CatalogModule } from "../modules/catalog.js";
|
|
47
47
|
import { CheckpointsModule } from "../modules/checkpoints.js";
|
|
48
|
-
import { PlaygroundModule } from "../modules/playground.js";
|
|
49
48
|
import { CronsModule } from "../modules/crons.js";
|
|
50
49
|
import { DlqModule } from "../modules/dlq.js";
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
50
|
+
import { EvaluationModule } from "../modules/evaluation.js";
|
|
51
|
+
import { FilesModule } from "../modules/files.js";
|
|
52
|
+
import { GraphsModule } from "../modules/graphs.js";
|
|
53
|
+
import { InfoModule } from "../modules/info.js";
|
|
54
54
|
import { McpModule } from "../modules/mcp.js";
|
|
55
|
-
import { A2aModule } from "../modules/a2a.js";
|
|
56
55
|
import { MeModule } from "../modules/me.js";
|
|
57
|
-
import { InfoModule } from "../modules/info.js";
|
|
58
|
-
import { MetricsModule } from "../modules/metrics.js";
|
|
59
|
-
import { GraphsModule } from "../modules/graphs.js";
|
|
60
|
-
import { CatalogModule } from "../modules/catalog.js";
|
|
61
|
-
import { ApprovalsModule } from "../modules/approvals.js";
|
|
62
|
-
import { ApiTokensModule } from "../modules/apiTokens.js";
|
|
63
56
|
import { MembershipsModule } from "../modules/memberships.js";
|
|
64
|
-
|
|
57
|
+
import { MetricsModule } from "../modules/metrics.js";
|
|
58
|
+
import { PlaygroundModule } from "../modules/playground.js";
|
|
59
|
+
import { PresetsModule } from "../modules/presets.js";
|
|
60
|
+
import { PromptsModule } from "../modules/prompts.js";
|
|
61
|
+
import { StoreModule } from "../modules/store.js";
|
|
62
|
+
import { TracesModule } from "../modules/traces.js";
|
|
63
|
+
import { UsageModule } from "../modules/usage.js";
|
|
64
|
+
import { VectorStoresModule } from "../modules/vectorStores.js";
|
|
65
65
|
export { isApiTokenAuth, isJwtAuth } from "./auth.js";
|
|
66
|
+
export type { AgentOsClientOptions, AuthProvider } from "./auth.js";
|
|
66
67
|
export declare class AgentOsClient {
|
|
67
68
|
private readonly _client;
|
|
68
69
|
private readonly _baseUrl;
|
|
@@ -106,6 +107,7 @@ export declare class AgentOsClient {
|
|
|
106
107
|
};
|
|
107
108
|
readonly apiTokens: ApiTokensModule;
|
|
108
109
|
readonly memberships: MembershipsModule;
|
|
110
|
+
readonly presets: PresetsModule;
|
|
109
111
|
constructor(options: AgentOsClientOptions);
|
|
110
112
|
/**
|
|
111
113
|
* Validate auth configuration at construction time
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentOsClient.d.ts","sourceRoot":"","sources":["../../src/client/AgentOsClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"AgentOsClient.d.ts","sourceRoot":"","sources":["../../src/client/AgentOsClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACH,KAAK,oBAAoB,EAK5B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC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26
26
|
* });
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
|
+
import { isApiTokenAuth, isBrowser, isJwtAuth, } from "./auth.js";
|
|
29
30
|
import { createRawClient } from "./raw.js";
|
|
30
|
-
import { isApiTokenAuth, isJwtAuth, isBrowser, } from "./auth.js";
|
|
31
31
|
import { AgentsModule } from "../modules/agents.js";
|
|
32
|
+
import { BuilderModule } from "../modules/builder.js";
|
|
33
|
+
import { CredentialsModule } from "../modules/credentials.js";
|
|
34
|
+
import { KnowledgeModule } from "../modules/knowledge.js";
|
|
35
|
+
import { MembersModule } from "../modules/members.js";
|
|
32
36
|
import { RunsModule } from "../modules/runs.js";
|
|
37
|
+
import { TenantsModule } from "../modules/tenants.js";
|
|
33
38
|
import { ThreadsModule } from "../modules/threads.js";
|
|
34
39
|
import { ToolsModule } from "../modules/tools.js";
|
|
35
|
-
import { KnowledgeModule } from "../modules/knowledge.js";
|
|
36
40
|
import { TriggersModule } from "../modules/triggers.js";
|
|
37
|
-
import { CredentialsModule } from "../modules/credentials.js";
|
|
38
|
-
import { BuilderModule } from "../modules/builder.js";
|
|
39
|
-
import { MembersModule } from "../modules/members.js";
|
|
40
|
-
import { TenantsModule } from "../modules/tenants.js";
|
|
41
41
|
import { WorkspacesModule } from "../modules/workspaces.js";
|
|
42
42
|
// Platform modules
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
43
|
+
import { A2aModule } from "../modules/a2a.js";
|
|
44
|
+
import { ApiTokensModule } from "../modules/apiTokens.js";
|
|
45
|
+
import { ApprovalsModule } from "../modules/approvals.js";
|
|
46
|
+
import { AuditModule } from "../modules/audit.js";
|
|
47
|
+
import { CatalogModule } from "../modules/catalog.js";
|
|
48
48
|
import { CheckpointsModule } from "../modules/checkpoints.js";
|
|
49
|
-
import { PlaygroundModule } from "../modules/playground.js";
|
|
50
49
|
import { CronsModule } from "../modules/crons.js";
|
|
51
50
|
import { DlqModule } from "../modules/dlq.js";
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
51
|
+
import { EvaluationModule } from "../modules/evaluation.js";
|
|
52
|
+
import { FilesModule } from "../modules/files.js";
|
|
53
|
+
import { GraphsModule } from "../modules/graphs.js";
|
|
54
|
+
import { InfoModule } from "../modules/info.js";
|
|
55
55
|
import { McpModule } from "../modules/mcp.js";
|
|
56
|
-
import { A2aModule } from "../modules/a2a.js";
|
|
57
56
|
import { MeModule } from "../modules/me.js";
|
|
58
|
-
import { InfoModule } from "../modules/info.js";
|
|
59
|
-
import { MetricsModule } from "../modules/metrics.js";
|
|
60
|
-
import { GraphsModule } from "../modules/graphs.js";
|
|
61
|
-
import { CatalogModule } from "../modules/catalog.js";
|
|
62
|
-
import { ApprovalsModule } from "../modules/approvals.js";
|
|
63
|
-
import { ApiTokensModule } from "../modules/apiTokens.js";
|
|
64
57
|
import { MembershipsModule } from "../modules/memberships.js";
|
|
58
|
+
import { MetricsModule } from "../modules/metrics.js";
|
|
59
|
+
import { PlaygroundModule } from "../modules/playground.js";
|
|
60
|
+
import { PresetsModule } from "../modules/presets.js";
|
|
61
|
+
import { PromptsModule } from "../modules/prompts.js";
|
|
62
|
+
import { StoreModule } from "../modules/store.js";
|
|
63
|
+
import { TracesModule } from "../modules/traces.js";
|
|
64
|
+
import { UsageModule } from "../modules/usage.js";
|
|
65
|
+
import { VectorStoresModule } from "../modules/vectorStores.js";
|
|
66
|
+
// Re-export auth types
|
|
65
67
|
export { isApiTokenAuth, isJwtAuth } from "./auth.js";
|
|
66
68
|
export class AgentOsClient {
|
|
67
69
|
_client;
|
|
@@ -105,6 +107,7 @@ export class AgentOsClient {
|
|
|
105
107
|
experiments;
|
|
106
108
|
apiTokens;
|
|
107
109
|
memberships;
|
|
110
|
+
presets;
|
|
108
111
|
constructor(options) {
|
|
109
112
|
this._baseUrl = options.baseUrl;
|
|
110
113
|
this._auth = options.auth;
|
|
@@ -161,6 +164,7 @@ export class AgentOsClient {
|
|
|
161
164
|
};
|
|
162
165
|
this.apiTokens = new ApiTokensModule(this._client);
|
|
163
166
|
this.memberships = new MembershipsModule(this._client);
|
|
167
|
+
this.presets = new PresetsModule(this._client, getHeaders);
|
|
164
168
|
}
|
|
165
169
|
/**
|
|
166
170
|
* Validate auth configuration at construction time
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { RawClient } from "../client/raw.js";
|
|
2
|
+
export interface AgentTemplateConfig {
|
|
3
|
+
name: string;
|
|
4
|
+
trigger_type: "chatwoot" | "webhook" | "schedule";
|
|
5
|
+
output_type: "chatwoot" | "http";
|
|
6
|
+
llm?: {
|
|
7
|
+
credential_id?: string;
|
|
8
|
+
model?: string;
|
|
9
|
+
system_prompt?: string;
|
|
10
|
+
};
|
|
11
|
+
bindings?: Array<{
|
|
12
|
+
credential_id: string;
|
|
13
|
+
alias: string;
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
16
|
+
export interface CreatedAgentResult {
|
|
17
|
+
agent_id: string;
|
|
18
|
+
agent_name: string;
|
|
19
|
+
bundle_id?: string;
|
|
20
|
+
trigger_id?: string;
|
|
21
|
+
trigger_url?: string;
|
|
22
|
+
status: "live" | "draft";
|
|
23
|
+
}
|
|
24
|
+
export declare class PresetsModule {
|
|
25
|
+
private _client;
|
|
26
|
+
private _headers;
|
|
27
|
+
private _agents;
|
|
28
|
+
private _triggers;
|
|
29
|
+
constructor(client: RawClient, getHeaders: () => Record<string, string>);
|
|
30
|
+
createAgent(config: AgentTemplateConfig): Promise<CreatedAgentResult | null>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=presets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../src/modules/presets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIlD,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;IAClD,WAAW,EAAE,UAAU,GAAG,MAAM,CAAC;IACjC,GAAG,CAAC,EAAE;QACJ,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,QAAQ,CAAC,EAAE,KAAK,CAAC;QACf,aAAa,EAAE,MAAM,CAAC;QACtB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAwED,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,QAAQ,CAA+B;IAG/C,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,SAAS,CAAiB;gBAEtB,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAOjE,WAAW,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;CA8DnF"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { AgentsModule } from "./agents.js";
|
|
2
|
+
import { TriggersModule } from "./triggers.js";
|
|
3
|
+
const TRIGGER_TYPE_MAP = {
|
|
4
|
+
chatwoot: { type: "webhook", template_slug: "chatwoot" },
|
|
5
|
+
webhook: { type: "webhook", template_slug: "generic" },
|
|
6
|
+
schedule: { type: "schedule", template_slug: "cron" },
|
|
7
|
+
};
|
|
8
|
+
const OUTPUT_NODE_MAP = {
|
|
9
|
+
chatwoot: { kind: "output.chatwoot", config: {} },
|
|
10
|
+
http: { kind: "output.http", config: {} },
|
|
11
|
+
};
|
|
12
|
+
function generateGraphSpec(config) {
|
|
13
|
+
const triggerMapping = TRIGGER_TYPE_MAP[config.trigger_type] ?? TRIGGER_TYPE_MAP.webhook;
|
|
14
|
+
const outputMapping = OUTPUT_NODE_MAP[config.output_type] ?? OUTPUT_NODE_MAP.http;
|
|
15
|
+
// Safe validation (TS knows these keys exist in the constant, but runtime check is good practice)
|
|
16
|
+
if (!triggerMapping)
|
|
17
|
+
throw new Error(`Invalid trigger type: ${config.trigger_type}`);
|
|
18
|
+
if (!outputMapping)
|
|
19
|
+
throw new Error(`Invalid output type: ${config.output_type}`);
|
|
20
|
+
const nodes = [
|
|
21
|
+
{
|
|
22
|
+
id: "node-llm",
|
|
23
|
+
kind: "llm.chat",
|
|
24
|
+
label: "LLM",
|
|
25
|
+
config: {
|
|
26
|
+
model: config.llm?.model || "gpt-4o",
|
|
27
|
+
system_prompt: config.llm?.system_prompt || "You are a helpful assistant.",
|
|
28
|
+
...(config.llm?.credential_id ? { credential_id: config.llm.credential_id } : {}),
|
|
29
|
+
},
|
|
30
|
+
ui: { x: 300, y: 200 },
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "node-output",
|
|
34
|
+
...outputMapping,
|
|
35
|
+
label: "Output",
|
|
36
|
+
ui: { x: 500, y: 200 },
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
const edges = [
|
|
40
|
+
{ from: "node-llm", to: "node-output" },
|
|
41
|
+
];
|
|
42
|
+
const triggers = [
|
|
43
|
+
{
|
|
44
|
+
type: `${triggerMapping.template_slug}.${triggerMapping.type}`,
|
|
45
|
+
config: { events: ["message_created"] },
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
return {
|
|
49
|
+
version: "1",
|
|
50
|
+
entrypoint: "node-llm",
|
|
51
|
+
nodes,
|
|
52
|
+
edges,
|
|
53
|
+
triggers,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function generateUUID() {
|
|
57
|
+
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
|
58
|
+
return crypto.randomUUID();
|
|
59
|
+
}
|
|
60
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
61
|
+
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
62
|
+
return v.toString(16);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export class PresetsModule {
|
|
66
|
+
_client;
|
|
67
|
+
_headers;
|
|
68
|
+
// Internal modules needed for orchestration
|
|
69
|
+
_agents;
|
|
70
|
+
_triggers;
|
|
71
|
+
constructor(client, getHeaders) {
|
|
72
|
+
this._client = client;
|
|
73
|
+
this._headers = getHeaders;
|
|
74
|
+
this._agents = new AgentsModule(client, getHeaders);
|
|
75
|
+
this._triggers = new TriggersModule(client, getHeaders);
|
|
76
|
+
}
|
|
77
|
+
async createAgent(config) {
|
|
78
|
+
try {
|
|
79
|
+
console.log("[AgentOS SDK] Creating agent from preset...", {
|
|
80
|
+
name: config.name,
|
|
81
|
+
trigger_type: config.trigger_type,
|
|
82
|
+
output_type: config.output_type,
|
|
83
|
+
});
|
|
84
|
+
const { data: agent, error: createError } = await this._agents.create({
|
|
85
|
+
name: config.name,
|
|
86
|
+
idempotency_key: generateUUID()
|
|
87
|
+
});
|
|
88
|
+
if (createError || !agent) {
|
|
89
|
+
console.error("[AgentOS SDK] Failed to create agent:", createError);
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
const graphSpec = generateGraphSpec(config);
|
|
93
|
+
const { data: bundle, error: publishError } = await this._agents.publish(agent.id, graphSpec, { set_as_live: true });
|
|
94
|
+
if (publishError) {
|
|
95
|
+
console.error("[AgentOS SDK] Failed to publish bundle:", publishError);
|
|
96
|
+
return {
|
|
97
|
+
agent_id: agent.id,
|
|
98
|
+
agent_name: agent.name,
|
|
99
|
+
status: "draft",
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const triggerMapping = TRIGGER_TYPE_MAP[config.trigger_type] ?? TRIGGER_TYPE_MAP.webhook;
|
|
103
|
+
if (!triggerMapping)
|
|
104
|
+
throw new Error("Trigger mapping failed");
|
|
105
|
+
const { data: trigger, error: triggerError } = await this._triggers.create({
|
|
106
|
+
name: `${config.name} - ${config.trigger_type}`,
|
|
107
|
+
agent_id: agent.id,
|
|
108
|
+
trigger_type: triggerMapping.type,
|
|
109
|
+
template_slug: triggerMapping.template_slug,
|
|
110
|
+
});
|
|
111
|
+
if (triggerError) {
|
|
112
|
+
console.warn("[AgentOS SDK] Failed to create trigger:", triggerError);
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
agent_id: agent.id,
|
|
116
|
+
agent_name: agent.name,
|
|
117
|
+
bundle_id: bundle?.id,
|
|
118
|
+
trigger_id: trigger?.id,
|
|
119
|
+
trigger_url: trigger?.invoke_url,
|
|
120
|
+
status: "live",
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
console.error("[AgentOS SDK] Exception creating agent from preset:", err);
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
package/package.json
CHANGED
|
@@ -27,54 +27,55 @@
|
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
import { createRawClient, type RawClient } from "./raw.js";
|
|
31
30
|
import {
|
|
32
31
|
type AgentOsClientOptions,
|
|
33
32
|
type AuthProvider,
|
|
34
33
|
isApiTokenAuth,
|
|
35
|
-
isJwtAuth,
|
|
36
34
|
isBrowser,
|
|
35
|
+
isJwtAuth,
|
|
37
36
|
} from "./auth.js";
|
|
37
|
+
import { createRawClient, type RawClient } from "./raw.js";
|
|
38
38
|
|
|
39
39
|
import { AgentsModule } from "../modules/agents.js";
|
|
40
|
+
import { BuilderModule } from "../modules/builder.js";
|
|
41
|
+
import { CredentialsModule } from "../modules/credentials.js";
|
|
42
|
+
import { KnowledgeModule } from "../modules/knowledge.js";
|
|
43
|
+
import { MembersModule } from "../modules/members.js";
|
|
40
44
|
import { RunsModule } from "../modules/runs.js";
|
|
45
|
+
import { TenantsModule } from "../modules/tenants.js";
|
|
41
46
|
import { ThreadsModule } from "../modules/threads.js";
|
|
42
47
|
import { ToolsModule } from "../modules/tools.js";
|
|
43
|
-
import { KnowledgeModule } from "../modules/knowledge.js";
|
|
44
48
|
import { TriggersModule } from "../modules/triggers.js";
|
|
45
|
-
import { CredentialsModule } from "../modules/credentials.js";
|
|
46
|
-
import { BuilderModule } from "../modules/builder.js";
|
|
47
|
-
import { MembersModule } from "../modules/members.js";
|
|
48
|
-
import { TenantsModule } from "../modules/tenants.js";
|
|
49
49
|
import { WorkspacesModule } from "../modules/workspaces.js";
|
|
50
50
|
|
|
51
51
|
// Platform modules
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
52
|
+
import { A2aModule } from "../modules/a2a.js";
|
|
53
|
+
import { ApiTokensModule } from "../modules/apiTokens.js";
|
|
54
|
+
import { ApprovalsModule } from "../modules/approvals.js";
|
|
55
|
+
import { AuditModule } from "../modules/audit.js";
|
|
56
|
+
import { CatalogModule } from "../modules/catalog.js";
|
|
57
57
|
import { CheckpointsModule } from "../modules/checkpoints.js";
|
|
58
|
-
import { PlaygroundModule } from "../modules/playground.js";
|
|
59
58
|
import { CronsModule } from "../modules/crons.js";
|
|
60
59
|
import { DlqModule } from "../modules/dlq.js";
|
|
61
|
-
import {
|
|
62
|
-
import {
|
|
63
|
-
import {
|
|
60
|
+
import { EvaluationModule } from "../modules/evaluation.js";
|
|
61
|
+
import { FilesModule } from "../modules/files.js";
|
|
62
|
+
import { GraphsModule } from "../modules/graphs.js";
|
|
63
|
+
import { InfoModule } from "../modules/info.js";
|
|
64
64
|
import { McpModule } from "../modules/mcp.js";
|
|
65
|
-
import { A2aModule } from "../modules/a2a.js";
|
|
66
65
|
import { MeModule } from "../modules/me.js";
|
|
67
|
-
import { InfoModule } from "../modules/info.js";
|
|
68
|
-
import { MetricsModule } from "../modules/metrics.js";
|
|
69
|
-
import { GraphsModule } from "../modules/graphs.js";
|
|
70
|
-
import { CatalogModule } from "../modules/catalog.js";
|
|
71
|
-
import { ApprovalsModule } from "../modules/approvals.js";
|
|
72
|
-
import { ApiTokensModule } from "../modules/apiTokens.js";
|
|
73
66
|
import { MembershipsModule } from "../modules/memberships.js";
|
|
67
|
+
import { MetricsModule } from "../modules/metrics.js";
|
|
68
|
+
import { PlaygroundModule } from "../modules/playground.js";
|
|
69
|
+
import { PresetsModule } from "../modules/presets.js";
|
|
70
|
+
import { PromptsModule } from "../modules/prompts.js";
|
|
71
|
+
import { StoreModule } from "../modules/store.js";
|
|
72
|
+
import { TracesModule } from "../modules/traces.js";
|
|
73
|
+
import { UsageModule } from "../modules/usage.js";
|
|
74
|
+
import { VectorStoresModule } from "../modules/vectorStores.js";
|
|
74
75
|
|
|
75
76
|
// Re-export auth types
|
|
76
|
-
export type { AgentOsClientOptions, AuthProvider } from "./auth.js";
|
|
77
77
|
export { isApiTokenAuth, isJwtAuth } from "./auth.js";
|
|
78
|
+
export type { AgentOsClientOptions, AuthProvider } from "./auth.js";
|
|
78
79
|
|
|
79
80
|
export class AgentOsClient {
|
|
80
81
|
private readonly _client: RawClient;
|
|
@@ -126,6 +127,7 @@ export class AgentOsClient {
|
|
|
126
127
|
|
|
127
128
|
public readonly apiTokens: ApiTokensModule;
|
|
128
129
|
public readonly memberships: MembershipsModule;
|
|
130
|
+
public readonly presets: PresetsModule;
|
|
129
131
|
|
|
130
132
|
|
|
131
133
|
|
|
@@ -192,6 +194,7 @@ export class AgentOsClient {
|
|
|
192
194
|
|
|
193
195
|
this.apiTokens = new ApiTokensModule(this._client);
|
|
194
196
|
this.memberships = new MembershipsModule(this._client);
|
|
197
|
+
this.presets = new PresetsModule(this._client, getHeaders);
|
|
195
198
|
|
|
196
199
|
}
|
|
197
200
|
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import type { RawClient } from "../client/raw.js";
|
|
2
|
+
import { AgentsModule } from "./agents.js";
|
|
3
|
+
import { TriggersModule } from "./triggers.js";
|
|
4
|
+
|
|
5
|
+
export interface AgentTemplateConfig {
|
|
6
|
+
name: string;
|
|
7
|
+
trigger_type: "chatwoot" | "webhook" | "schedule";
|
|
8
|
+
output_type: "chatwoot" | "http";
|
|
9
|
+
llm?: {
|
|
10
|
+
credential_id?: string;
|
|
11
|
+
model?: string;
|
|
12
|
+
system_prompt?: string;
|
|
13
|
+
};
|
|
14
|
+
bindings?: Array<{
|
|
15
|
+
credential_id: string;
|
|
16
|
+
alias: string;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface CreatedAgentResult {
|
|
21
|
+
agent_id: string;
|
|
22
|
+
agent_name: string;
|
|
23
|
+
bundle_id?: string;
|
|
24
|
+
trigger_id?: string;
|
|
25
|
+
trigger_url?: string;
|
|
26
|
+
status: "live" | "draft";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const TRIGGER_TYPE_MAP: Record<string, { type: string; template_slug: string }> = {
|
|
30
|
+
chatwoot: { type: "webhook", template_slug: "chatwoot" },
|
|
31
|
+
webhook: { type: "webhook", template_slug: "generic" },
|
|
32
|
+
schedule: { type: "schedule", template_slug: "cron" },
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const OUTPUT_NODE_MAP: Record<string, { kind: string; config: Record<string, unknown> }> = {
|
|
36
|
+
chatwoot: { kind: "output.chatwoot", config: {} },
|
|
37
|
+
http: { kind: "output.http", config: {} },
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
function generateGraphSpec(config: AgentTemplateConfig): Record<string, unknown> {
|
|
41
|
+
const triggerMapping = TRIGGER_TYPE_MAP[config.trigger_type] ?? TRIGGER_TYPE_MAP.webhook;
|
|
42
|
+
const outputMapping = OUTPUT_NODE_MAP[config.output_type] ?? OUTPUT_NODE_MAP.http;
|
|
43
|
+
|
|
44
|
+
// Safe validation (TS knows these keys exist in the constant, but runtime check is good practice)
|
|
45
|
+
if (!triggerMapping) throw new Error(`Invalid trigger type: ${config.trigger_type}`);
|
|
46
|
+
if (!outputMapping) throw new Error(`Invalid output type: ${config.output_type}`);
|
|
47
|
+
|
|
48
|
+
const nodes = [
|
|
49
|
+
{
|
|
50
|
+
id: "node-llm",
|
|
51
|
+
kind: "llm.chat",
|
|
52
|
+
label: "LLM",
|
|
53
|
+
config: {
|
|
54
|
+
model: config.llm?.model || "gpt-4o",
|
|
55
|
+
system_prompt: config.llm?.system_prompt || "You are a helpful assistant.",
|
|
56
|
+
...(config.llm?.credential_id ? { credential_id: config.llm.credential_id } : {}),
|
|
57
|
+
},
|
|
58
|
+
ui: { x: 300, y: 200 },
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "node-output",
|
|
62
|
+
...outputMapping,
|
|
63
|
+
label: "Output",
|
|
64
|
+
ui: { x: 500, y: 200 },
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
const edges = [
|
|
69
|
+
{ from: "node-llm", to: "node-output" },
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
const triggers = [
|
|
73
|
+
{
|
|
74
|
+
type: `${triggerMapping.template_slug}.${triggerMapping.type}`,
|
|
75
|
+
config: { events: ["message_created"] },
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
version: "1",
|
|
81
|
+
entrypoint: "node-llm",
|
|
82
|
+
nodes,
|
|
83
|
+
edges,
|
|
84
|
+
triggers,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
function generateUUID(): string {
|
|
90
|
+
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
|
91
|
+
return crypto.randomUUID();
|
|
92
|
+
}
|
|
93
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
94
|
+
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
95
|
+
return v.toString(16);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export class PresetsModule {
|
|
100
|
+
private _client: RawClient;
|
|
101
|
+
private _headers: () => Record<string, string>;
|
|
102
|
+
|
|
103
|
+
// Internal modules needed for orchestration
|
|
104
|
+
private _agents: AgentsModule;
|
|
105
|
+
private _triggers: TriggersModule;
|
|
106
|
+
|
|
107
|
+
constructor(client: RawClient, getHeaders: () => Record<string, string>) {
|
|
108
|
+
this._client = client;
|
|
109
|
+
this._headers = getHeaders;
|
|
110
|
+
this._agents = new AgentsModule(client, getHeaders);
|
|
111
|
+
this._triggers = new TriggersModule(client, getHeaders);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async createAgent(config: AgentTemplateConfig): Promise<CreatedAgentResult | null> {
|
|
115
|
+
try {
|
|
116
|
+
console.log("[AgentOS SDK] Creating agent from preset...", {
|
|
117
|
+
name: config.name,
|
|
118
|
+
trigger_type: config.trigger_type,
|
|
119
|
+
output_type: config.output_type,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const { data: agent, error: createError } = await this._agents.create({
|
|
123
|
+
name: config.name,
|
|
124
|
+
idempotency_key: generateUUID()
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
if (createError || !agent) {
|
|
128
|
+
console.error("[AgentOS SDK] Failed to create agent:", createError);
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const graphSpec = generateGraphSpec(config);
|
|
133
|
+
|
|
134
|
+
const { data: bundle, error: publishError } = await this._agents.publish(
|
|
135
|
+
agent.id,
|
|
136
|
+
graphSpec,
|
|
137
|
+
{ set_as_live: true }
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
if (publishError) {
|
|
141
|
+
console.error("[AgentOS SDK] Failed to publish bundle:", publishError);
|
|
142
|
+
return {
|
|
143
|
+
agent_id: agent.id,
|
|
144
|
+
agent_name: agent.name,
|
|
145
|
+
status: "draft",
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const triggerMapping = TRIGGER_TYPE_MAP[config.trigger_type] ?? TRIGGER_TYPE_MAP.webhook;
|
|
150
|
+
if (!triggerMapping) throw new Error("Trigger mapping failed");
|
|
151
|
+
|
|
152
|
+
const { data: trigger, error: triggerError } = await this._triggers.create({
|
|
153
|
+
name: `${config.name} - ${config.trigger_type}`,
|
|
154
|
+
agent_id: agent.id,
|
|
155
|
+
trigger_type: triggerMapping.type,
|
|
156
|
+
template_slug: triggerMapping.template_slug,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
if (triggerError) {
|
|
160
|
+
console.warn("[AgentOS SDK] Failed to create trigger:", triggerError);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
agent_id: agent.id,
|
|
165
|
+
agent_name: agent.name,
|
|
166
|
+
bundle_id: bundle?.id,
|
|
167
|
+
trigger_id: trigger?.id,
|
|
168
|
+
trigger_url: (trigger as any)?.invoke_url,
|
|
169
|
+
status: "live",
|
|
170
|
+
};
|
|
171
|
+
} catch (err) {
|
|
172
|
+
console.error("[AgentOS SDK] Exception creating agent from preset:", err);
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|