@agent-os-sdk/client 0.9.25 → 0.9.27
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/generated/openapi.d.ts +82 -0
- package/dist/generated/openapi.d.ts.map +1 -1
- package/dist/modules/runs.d.ts.map +1 -1
- package/dist/modules/templates.d.ts +23 -0
- package/dist/modules/templates.d.ts.map +1 -1
- package/dist/modules/templates.js +7 -0
- package/package.json +2 -2
- package/src/client/AgentOsClient.ts +0 -294
- package/src/client/HttpRequestBuilder.ts +0 -115
- package/src/client/OperationContext.ts +0 -22
- package/src/client/OperationContextProvider.ts +0 -89
- package/src/client/auth.ts +0 -136
- package/src/client/config.ts +0 -100
- package/src/client/helpers.ts +0 -98
- package/src/client/pagination.ts +0 -218
- package/src/client/raw.ts +0 -609
- package/src/client/retry.ts +0 -150
- package/src/client/sanitize.ts +0 -31
- package/src/client/timeout.ts +0 -59
- package/src/errors/factory.ts +0 -140
- package/src/errors/index.ts +0 -365
- package/src/generated/client.ts +0 -32
- package/src/generated/index.ts +0 -2
- package/src/generated/openapi.ts +0 -12302
- package/src/generated/swagger.json +0 -16851
- package/src/index.ts +0 -131
- package/src/modules/a2a.ts +0 -64
- package/src/modules/agents.ts +0 -604
- package/src/modules/apiTokens.ts +0 -101
- package/src/modules/approvals.ts +0 -151
- package/src/modules/audit.ts +0 -145
- package/src/modules/auth.ts +0 -33
- package/src/modules/catalog.ts +0 -241
- package/src/modules/chatwoot.ts +0 -242
- package/src/modules/checkpoints.ts +0 -87
- package/src/modules/contracts.ts +0 -80
- package/src/modules/credentials.ts +0 -216
- package/src/modules/crons.ts +0 -115
- package/src/modules/datasets.ts +0 -142
- package/src/modules/evaluation.ts +0 -269
- package/src/modules/files.ts +0 -208
- package/src/modules/improvements.ts +0 -71
- package/src/modules/info.ts +0 -143
- package/src/modules/me.ts +0 -74
- package/src/modules/members.ts +0 -199
- package/src/modules/memberships.ts +0 -42
- package/src/modules/metaAgent.ts +0 -131
- package/src/modules/metrics.ts +0 -34
- package/src/modules/observability.ts +0 -28
- package/src/modules/playground.ts +0 -68
- package/src/modules/presets.ts +0 -246
- package/src/modules/prompts.ts +0 -147
- package/src/modules/roles.ts +0 -112
- package/src/modules/runs.ts +0 -878
- package/src/modules/store.ts +0 -65
- package/src/modules/templates.ts +0 -40
- package/src/modules/tenants.ts +0 -79
- package/src/modules/threads.ts +0 -343
- package/src/modules/tools.ts +0 -91
- package/src/modules/traces.ts +0 -133
- package/src/modules/triggers.ts +0 -357
- package/src/modules/usage.ts +0 -117
- package/src/modules/vectorStores.ts +0 -257
- package/src/modules/workspaces.ts +0 -216
- package/src/sse/client.ts +0 -179
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
3
|
-
|
|
4
|
-
export interface MembershipResponse {
|
|
5
|
-
id: string;
|
|
6
|
-
user_id: string;
|
|
7
|
-
tenant_id: string;
|
|
8
|
-
role_id: string;
|
|
9
|
-
role_name?: string;
|
|
10
|
-
workspace_id?: string;
|
|
11
|
-
workspace_name?: string;
|
|
12
|
-
created_at: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface EnsureMembershipRequest {
|
|
16
|
-
tenant_id?: string;
|
|
17
|
-
workspace_id?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export class MembershipsModule {
|
|
21
|
-
private client: RawClient;
|
|
22
|
-
|
|
23
|
-
constructor(client: RawClient) {
|
|
24
|
-
this.client = client;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
private headers() {
|
|
28
|
-
return {
|
|
29
|
-
"Content-Type": "application/json",
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Ensure the current user has a membership in a tenant (self-provisioning).
|
|
35
|
-
*/
|
|
36
|
-
async ensure(body: EnsureMembershipRequest): Promise<APIResponse<MembershipResponse>> {
|
|
37
|
-
return this.client.POST<MembershipResponse>("/v1/api/memberships/ensure", {
|
|
38
|
-
body,
|
|
39
|
-
headers: this.headers(),
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
package/src/modules/metaAgent.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import type { APIResponse, RawClient } from "../client/raw.js";
|
|
2
|
-
|
|
3
|
-
export interface MetaAgentPatchValidationIssue {
|
|
4
|
-
code: string;
|
|
5
|
-
message: string;
|
|
6
|
-
node_id?: string | null;
|
|
7
|
-
path?: string | null;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface MetaAgentPreviewValidationIssue {
|
|
11
|
-
code: string;
|
|
12
|
-
message: string;
|
|
13
|
-
path?: string | null;
|
|
14
|
-
severity?: string | null;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface MetaAgentPatchOp {
|
|
18
|
-
op: string;
|
|
19
|
-
node_id?: string | null;
|
|
20
|
-
capability_ref?: string | null;
|
|
21
|
-
capability_version?: string | null;
|
|
22
|
-
label?: string | null;
|
|
23
|
-
data?: Record<string, unknown> | null;
|
|
24
|
-
set?: Record<string, unknown> | null;
|
|
25
|
-
from?: string | null;
|
|
26
|
-
to?: string | null;
|
|
27
|
-
entrypoint?: string | null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface MetaAgentPatchProposal {
|
|
31
|
-
patch_id: string;
|
|
32
|
-
description?: string | null;
|
|
33
|
-
ops: MetaAgentPatchOp[];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface MetaAgentDiffPreview {
|
|
37
|
-
added_node_ids: string[];
|
|
38
|
-
removed_node_ids: string[];
|
|
39
|
-
updated_node_ids: string[];
|
|
40
|
-
added_edge_ids: string[];
|
|
41
|
-
removed_edge_ids: string[];
|
|
42
|
-
entrypoint_changed: boolean;
|
|
43
|
-
before_entrypoint?: string | null;
|
|
44
|
-
after_entrypoint?: string | null;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface MetaAgentBlastRadiusCredentialImpact {
|
|
48
|
-
required_credential: string;
|
|
49
|
-
status: "bound" | "missing";
|
|
50
|
-
binding_key?: string | null;
|
|
51
|
-
credential_instance_ref?: string | null;
|
|
52
|
-
credential_name?: string | null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface MetaAgentBlastRadius {
|
|
56
|
-
affected_node_ids: string[];
|
|
57
|
-
affected_edge_ids: string[];
|
|
58
|
-
added_capabilities: string[];
|
|
59
|
-
removed_capabilities: string[];
|
|
60
|
-
changed_capabilities: string[];
|
|
61
|
-
impacted_credentials: MetaAgentBlastRadiusCredentialImpact[];
|
|
62
|
-
warnings: MetaAgentPreviewValidationIssue[];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface MetaAgentValidationResult {
|
|
66
|
-
valid: boolean;
|
|
67
|
-
preview_valid: boolean;
|
|
68
|
-
errors: MetaAgentPatchValidationIssue[];
|
|
69
|
-
warnings: MetaAgentPreviewValidationIssue[];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface MetaAgentPatchProposalResponse {
|
|
73
|
-
agent_id: string;
|
|
74
|
-
draft_revision?: string | null;
|
|
75
|
-
draft_etag: string;
|
|
76
|
-
source_contract: "agent_ir.v1";
|
|
77
|
-
mode?: "chat" | "proposal";
|
|
78
|
-
patch?: MetaAgentPatchProposal | null;
|
|
79
|
-
preview_draft_ir?: Record<string, unknown> | null;
|
|
80
|
-
diff_preview?: MetaAgentDiffPreview | null;
|
|
81
|
-
blast_radius?: MetaAgentBlastRadius | null;
|
|
82
|
-
validation_result: MetaAgentValidationResult;
|
|
83
|
-
message: string;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface MetaAgentApplyPatchResponse {
|
|
87
|
-
agent_id: string;
|
|
88
|
-
draft_revision?: string | null;
|
|
89
|
-
draft_etag_before: string;
|
|
90
|
-
draft_etag_after: string;
|
|
91
|
-
patch_id: string;
|
|
92
|
-
source_contract: "agent_ir.v1";
|
|
93
|
-
applied_at: string;
|
|
94
|
-
applied_by?: string | null;
|
|
95
|
-
draft_ir: Record<string, unknown>;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export class MetaAgentModule {
|
|
99
|
-
constructor(private client: RawClient, private headers: () => Record<string, string>) {}
|
|
100
|
-
|
|
101
|
-
async chat(agentId: string, message: string): Promise<APIResponse<MetaAgentPatchProposalResponse>> {
|
|
102
|
-
return this.client.POST<MetaAgentPatchProposalResponse>("/v1/api/agents/{id}/meta-agent/chat", {
|
|
103
|
-
params: { path: { id: agentId } },
|
|
104
|
-
headers: this.headers(),
|
|
105
|
-
body: { message },
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async propose(agentId: string, instruction: string): Promise<APIResponse<MetaAgentPatchProposalResponse>> {
|
|
110
|
-
return this.client.POST<MetaAgentPatchProposalResponse>("/v1/api/agents/{id}/meta-agent/proposals", {
|
|
111
|
-
params: { path: { id: agentId } },
|
|
112
|
-
headers: this.headers(),
|
|
113
|
-
body: { instruction },
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
async apply(
|
|
118
|
-
agentId: string,
|
|
119
|
-
draftEtag: string,
|
|
120
|
-
patch: MetaAgentPatchProposal,
|
|
121
|
-
): Promise<APIResponse<MetaAgentApplyPatchResponse>> {
|
|
122
|
-
return this.client.POST<MetaAgentApplyPatchResponse>("/v1/api/agents/{id}/meta-agent/proposals/apply", {
|
|
123
|
-
params: { path: { id: agentId } },
|
|
124
|
-
headers: this.headers(),
|
|
125
|
-
body: {
|
|
126
|
-
draft_etag: draftEtag,
|
|
127
|
-
patch,
|
|
128
|
-
},
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
package/src/modules/metrics.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Metrics Module - Fully Typed
|
|
3
|
-
*
|
|
4
|
-
* ALL HTTP goes through rawClient - no direct fetch calls.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { RawClient } from "../client/raw.js";
|
|
8
|
-
|
|
9
|
-
export interface MetricsResponse {
|
|
10
|
-
raw: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export class MetricsModule {
|
|
14
|
-
constructor(private client: RawClient) { }
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Get Prometheus metrics.
|
|
18
|
-
*
|
|
19
|
-
* Uses rawClient - headers resolved asynchronously.
|
|
20
|
-
*/
|
|
21
|
-
async get(): Promise<MetricsResponse> {
|
|
22
|
-
// Use streamGet for raw text response (metrics endpoint returns text/plain)
|
|
23
|
-
const response = await this.client.streamGet("/metrics", {
|
|
24
|
-
headers: { Accept: "text/plain" }
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
if (!response.ok) {
|
|
28
|
-
throw new Error(`Failed to fetch metrics: ${response.status}`);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const raw = await response.text();
|
|
32
|
-
return { raw };
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { APIResponse, RawClient } from "../client/raw.js";
|
|
2
|
-
|
|
3
|
-
export type FrontendLogLevel = "DEBUG" | "INFO" | "WARN" | "ERROR";
|
|
4
|
-
|
|
5
|
-
export interface FrontendLogPayload {
|
|
6
|
-
level: FrontendLogLevel;
|
|
7
|
-
message: string;
|
|
8
|
-
stack?: string;
|
|
9
|
-
route?: string;
|
|
10
|
-
url?: string;
|
|
11
|
-
user_agent?: string;
|
|
12
|
-
session_id?: string;
|
|
13
|
-
context?: Record<string, unknown>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class ObservabilityModule {
|
|
17
|
-
constructor(
|
|
18
|
-
private client: RawClient,
|
|
19
|
-
private headers: () => Record<string, string>
|
|
20
|
-
) { }
|
|
21
|
-
|
|
22
|
-
async logFrontend(payload: FrontendLogPayload): Promise<APIResponse<Record<string, unknown>>> {
|
|
23
|
-
return this.client.POST<Record<string, unknown>>("/v1/api/observability/frontend-log", {
|
|
24
|
-
body: payload,
|
|
25
|
-
headers: this.headers(),
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Playground Module - Fully Typed
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
6
|
-
|
|
7
|
-
export interface PlaygroundSession {
|
|
8
|
-
session_id: string;
|
|
9
|
-
agent_id: string;
|
|
10
|
-
thread_id: string;
|
|
11
|
-
status: "active" | "expired";
|
|
12
|
-
created_at: string;
|
|
13
|
-
expires_at: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface PlaygroundMessageResponse {
|
|
17
|
-
run_id: string;
|
|
18
|
-
message_id: string;
|
|
19
|
-
content: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export class PlaygroundModule {
|
|
23
|
-
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Create a playground session.
|
|
27
|
-
*/
|
|
28
|
-
async createSession(body: {
|
|
29
|
-
agent_id: string;
|
|
30
|
-
thread_id?: string;
|
|
31
|
-
}): Promise<APIResponse<PlaygroundSession>> {
|
|
32
|
-
return this.client.POST<PlaygroundSession>("/v1/api/playground/sessions", {
|
|
33
|
-
body,
|
|
34
|
-
headers: this.headers(),
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Get a playground session.
|
|
40
|
-
*/
|
|
41
|
-
async getSession(sessionId: string): Promise<APIResponse<PlaygroundSession>> {
|
|
42
|
-
return this.client.GET<PlaygroundSession>("/v1/api/playground/sessions/{id}", {
|
|
43
|
-
params: { path: { id: sessionId } },
|
|
44
|
-
headers: this.headers(),
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Send a message in a playground session.
|
|
50
|
-
*/
|
|
51
|
-
async sendMessage(sessionId: string, message: string): Promise<APIResponse<PlaygroundMessageResponse>> {
|
|
52
|
-
return this.client.POST<PlaygroundMessageResponse>("/v1/api/playground/sessions/{id}/messages", {
|
|
53
|
-
params: { path: { id: sessionId } },
|
|
54
|
-
body: { content: message },
|
|
55
|
-
headers: this.headers(),
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Delete a playground session.
|
|
61
|
-
*/
|
|
62
|
-
async deleteSession(sessionId: string): Promise<APIResponse<void>> {
|
|
63
|
-
return this.client.DELETE<void>("/v1/api/playground/sessions/{id}", {
|
|
64
|
-
params: { path: { id: sessionId } },
|
|
65
|
-
headers: this.headers(),
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
package/src/modules/presets.ts
DELETED
|
@@ -1,246 +0,0 @@
|
|
|
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
|
-
instructions?: 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
|
-
function buildAgentDefinitionId(name: string): string {
|
|
36
|
-
const normalized = name
|
|
37
|
-
.trim()
|
|
38
|
-
.toLowerCase()
|
|
39
|
-
.replace(/[^a-z0-9]+/g, ".")
|
|
40
|
-
.replace(/\.{2,}/g, ".")
|
|
41
|
-
.replace(/^\.|\.$/g, "");
|
|
42
|
-
return `agent.${normalized || "untitled"}`;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function generateAgentIr(config: AgentTemplateConfig): Record<string, unknown> {
|
|
46
|
-
const agentDefinitionId = buildAgentDefinitionId(config.name);
|
|
47
|
-
const triggerLabel = config.trigger_type === "schedule" ? "Scheduled Trigger" : "Incoming Trigger";
|
|
48
|
-
const outputLabel = config.output_type === "chatwoot" ? "Chatwoot Output" : "HTTP Output";
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
ir_version: "1.0",
|
|
52
|
-
agent_definition_id: agentDefinitionId,
|
|
53
|
-
version: "1.0.0",
|
|
54
|
-
metadata: {
|
|
55
|
-
name: config.name,
|
|
56
|
-
description: "Preset-generated agent_ir.v1 draft",
|
|
57
|
-
},
|
|
58
|
-
state_schema: {
|
|
59
|
-
type: "object",
|
|
60
|
-
properties: {
|
|
61
|
-
global: {
|
|
62
|
-
type: "object",
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
inputs_schema: {
|
|
67
|
-
type: "object",
|
|
68
|
-
properties: {
|
|
69
|
-
message: {
|
|
70
|
-
type: "string",
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
required: ["message"],
|
|
74
|
-
},
|
|
75
|
-
outputs_schema: {
|
|
76
|
-
type: "object",
|
|
77
|
-
},
|
|
78
|
-
outcome_schema: {
|
|
79
|
-
type: "object",
|
|
80
|
-
properties: {
|
|
81
|
-
preset_ready: {
|
|
82
|
-
type: "boolean",
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
required: ["preset_ready"],
|
|
86
|
-
},
|
|
87
|
-
kpi_bindings: [
|
|
88
|
-
{
|
|
89
|
-
kpi_ref: `${agentDefinitionId}.preset_ready`,
|
|
90
|
-
source_scope: "outcome",
|
|
91
|
-
source_path: "preset_ready",
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
evaluation_policy: {
|
|
95
|
-
execution_mode: "async",
|
|
96
|
-
evaluators: [
|
|
97
|
-
{
|
|
98
|
-
evaluator_ref: `eval.${agentDefinitionId}.preset_shape_v1`,
|
|
99
|
-
kind: "rule",
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
sampling_policy: {
|
|
103
|
-
mode: "all",
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
improvement_policy_ref: null,
|
|
107
|
-
nodes: [
|
|
108
|
-
{
|
|
109
|
-
id: "start",
|
|
110
|
-
kind: "start",
|
|
111
|
-
capability_ref: "capability://agent-ir/start",
|
|
112
|
-
label: triggerLabel,
|
|
113
|
-
config: {},
|
|
114
|
-
bindings: {},
|
|
115
|
-
editability: { mode: "read_only" },
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
id: "draft_output",
|
|
119
|
-
kind: "end",
|
|
120
|
-
capability_ref: "capability://agent-ir/end",
|
|
121
|
-
label: outputLabel,
|
|
122
|
-
config: {},
|
|
123
|
-
bindings: {},
|
|
124
|
-
editability: { mode: "full" },
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
edges: [
|
|
128
|
-
{
|
|
129
|
-
id: "edge_start_to_output",
|
|
130
|
-
from: "start",
|
|
131
|
-
to: "draft_output",
|
|
132
|
-
kind: "default",
|
|
133
|
-
priority: 0,
|
|
134
|
-
},
|
|
135
|
-
],
|
|
136
|
-
capability_registry_refs: [],
|
|
137
|
-
policies: {},
|
|
138
|
-
editability: {
|
|
139
|
-
mode: "full",
|
|
140
|
-
},
|
|
141
|
-
entrypoints: ["start"],
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
function generateUUID(): string {
|
|
147
|
-
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
|
148
|
-
return crypto.randomUUID();
|
|
149
|
-
}
|
|
150
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
151
|
-
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
152
|
-
return v.toString(16);
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export class PresetsModule {
|
|
157
|
-
private _client: RawClient;
|
|
158
|
-
private _headers: () => Record<string, string>;
|
|
159
|
-
|
|
160
|
-
// Internal modules needed for orchestration
|
|
161
|
-
private _agents: AgentsModule;
|
|
162
|
-
private _triggers: TriggersModule;
|
|
163
|
-
|
|
164
|
-
constructor(client: RawClient, getHeaders: () => Record<string, string>) {
|
|
165
|
-
this._client = client;
|
|
166
|
-
this._headers = getHeaders;
|
|
167
|
-
this._agents = new AgentsModule(client, getHeaders);
|
|
168
|
-
this._triggers = new TriggersModule(client, getHeaders);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
async createAgent(config: AgentTemplateConfig): Promise<CreatedAgentResult | null> {
|
|
172
|
-
try {
|
|
173
|
-
console.log("[AgentOS SDK] Creating agent from preset...", {
|
|
174
|
-
name: config.name,
|
|
175
|
-
trigger_type: config.trigger_type,
|
|
176
|
-
output_type: config.output_type,
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
const { data: agent, error: createError } = await this._agents.create({
|
|
180
|
-
name: config.name,
|
|
181
|
-
idempotency_key: generateUUID()
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
if (createError || !agent) {
|
|
185
|
-
console.error("[AgentOS SDK] Failed to create agent:", createError);
|
|
186
|
-
return null;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const { error: draftError } = await this._agents.updateDraftIr(
|
|
190
|
-
agent.id,
|
|
191
|
-
generateAgentIr(config),
|
|
192
|
-
{ if_match: `"${agent.id}:0"` },
|
|
193
|
-
);
|
|
194
|
-
|
|
195
|
-
if (draftError) {
|
|
196
|
-
console.error("[AgentOS SDK] Failed to save agent_ir.v1 draft:", draftError);
|
|
197
|
-
return {
|
|
198
|
-
agent_id: agent.id,
|
|
199
|
-
agent_name: agent.name,
|
|
200
|
-
status: "draft",
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const { data: bundle, error: publishError } = await this._agents.publish(agent.id, {
|
|
205
|
-
set_as_live: true,
|
|
206
|
-
required_tools: [],
|
|
207
|
-
idempotency_key: generateUUID(),
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
if (publishError) {
|
|
211
|
-
console.error("[AgentOS SDK] Failed to publish bundle:", publishError);
|
|
212
|
-
return {
|
|
213
|
-
agent_id: agent.id,
|
|
214
|
-
agent_name: agent.name,
|
|
215
|
-
status: "draft",
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
const triggerMapping = TRIGGER_TYPE_MAP[config.trigger_type] ?? TRIGGER_TYPE_MAP.webhook;
|
|
220
|
-
if (!triggerMapping) throw new Error("Trigger mapping failed");
|
|
221
|
-
|
|
222
|
-
const { data: trigger, error: triggerError } = await this._triggers.create({
|
|
223
|
-
name: `${config.name} - ${config.trigger_type}`,
|
|
224
|
-
agent_id: agent.id,
|
|
225
|
-
trigger_type: triggerMapping.type,
|
|
226
|
-
template_slug: triggerMapping.template_slug,
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
if (triggerError) {
|
|
230
|
-
console.warn("[AgentOS SDK] Failed to create trigger:", triggerError);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
return {
|
|
234
|
-
agent_id: agent.id,
|
|
235
|
-
agent_name: agent.name,
|
|
236
|
-
bundle_id: bundle?.id,
|
|
237
|
-
trigger_id: trigger?.id,
|
|
238
|
-
trigger_url: (trigger as any)?.invoke_url,
|
|
239
|
-
status: "live",
|
|
240
|
-
};
|
|
241
|
-
} catch (err) {
|
|
242
|
-
console.error("[AgentOS SDK] Exception creating agent from preset:", err);
|
|
243
|
-
return null;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
package/src/modules/prompts.ts
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Prompts Module - Fully Typed
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { RawClient, APIResponse, components } from "../client/raw.js";
|
|
6
|
-
|
|
7
|
-
type CreatePromptRequest = components["schemas"]["CreatePromptRequest"];
|
|
8
|
-
type CreatePromptVersionRequest = components["schemas"]["CreatePromptVersionRequest"];
|
|
9
|
-
|
|
10
|
-
export interface Prompt {
|
|
11
|
-
id: string;
|
|
12
|
-
name: string;
|
|
13
|
-
description?: string;
|
|
14
|
-
workspace_id: string;
|
|
15
|
-
tenant_id: string;
|
|
16
|
-
created_at: string;
|
|
17
|
-
updated_at: string;
|
|
18
|
-
versions?: PromptVersion[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface PromptVersion {
|
|
22
|
-
id: string;
|
|
23
|
-
prompt_id: string;
|
|
24
|
-
version: number;
|
|
25
|
-
template: string;
|
|
26
|
-
input_schema?: Record<string, unknown>;
|
|
27
|
-
output_schema?: Record<string, unknown>;
|
|
28
|
-
is_live: boolean;
|
|
29
|
-
created_at: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface PromptListResponse {
|
|
33
|
-
items: Prompt[];
|
|
34
|
-
total: number;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface PromptVersionListResponse {
|
|
38
|
-
items: PromptVersion[];
|
|
39
|
-
total: number;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface RenderPromptResponse {
|
|
43
|
-
rendered: string;
|
|
44
|
-
input_used: Record<string, unknown>;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export class PromptsModule {
|
|
48
|
-
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* List all prompts.
|
|
52
|
-
*/
|
|
53
|
-
async list(params?: {
|
|
54
|
-
workspace_id?: string;
|
|
55
|
-
limit?: number;
|
|
56
|
-
offset?: number;
|
|
57
|
-
}): Promise<APIResponse<PromptListResponse>> {
|
|
58
|
-
return this.client.GET<PromptListResponse>("/v1/api/prompts", {
|
|
59
|
-
params: { query: params },
|
|
60
|
-
headers: this.headers(),
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Get a prompt by ID.
|
|
66
|
-
*/
|
|
67
|
-
async get(promptId: string): Promise<APIResponse<Prompt>> {
|
|
68
|
-
return this.client.GET<Prompt>("/v1/api/prompts/{id}", {
|
|
69
|
-
params: { path: { id: promptId } },
|
|
70
|
-
headers: this.headers(),
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Create a new prompt.
|
|
76
|
-
*/
|
|
77
|
-
async create(body: {
|
|
78
|
-
name: string;
|
|
79
|
-
description?: string;
|
|
80
|
-
template?: string;
|
|
81
|
-
input_schema?: Record<string, unknown>;
|
|
82
|
-
}): Promise<APIResponse<Prompt>> {
|
|
83
|
-
return this.client.POST<Prompt>("/v1/api/prompts", {
|
|
84
|
-
body,
|
|
85
|
-
headers: this.headers(),
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Delete a prompt.
|
|
91
|
-
*/
|
|
92
|
-
async delete(promptId: string): Promise<APIResponse<void>> {
|
|
93
|
-
return this.client.DELETE<void>("/v1/api/prompts/{id}", {
|
|
94
|
-
params: { path: { id: promptId } },
|
|
95
|
-
headers: this.headers(),
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// ======================== Versions ========================
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* List all versions of a prompt.
|
|
103
|
-
*/
|
|
104
|
-
async listVersions(promptId: string): Promise<APIResponse<PromptVersionListResponse>> {
|
|
105
|
-
return this.client.GET<PromptVersionListResponse>("/v1/api/prompts/{id}/versions", {
|
|
106
|
-
params: { path: { id: promptId } },
|
|
107
|
-
headers: this.headers(),
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Create a new version.
|
|
113
|
-
*/
|
|
114
|
-
async createVersion(promptId: string, body: {
|
|
115
|
-
template: string;
|
|
116
|
-
input_schema?: Record<string, unknown>;
|
|
117
|
-
output_schema?: Record<string, unknown>;
|
|
118
|
-
}): Promise<APIResponse<PromptVersion>> {
|
|
119
|
-
return this.client.POST<PromptVersion>("/v1/api/prompts/{id}/versions", {
|
|
120
|
-
params: { path: { id: promptId } },
|
|
121
|
-
body,
|
|
122
|
-
headers: this.headers(),
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Set the live version.
|
|
128
|
-
*/
|
|
129
|
-
async setLiveVersion(promptId: string, versionNumber: number): Promise<APIResponse<void>> {
|
|
130
|
-
return this.client.POST<void>("/v1/api/prompts/{id}/set-live", {
|
|
131
|
-
params: { path: { id: promptId } },
|
|
132
|
-
body: { version_number: versionNumber },
|
|
133
|
-
headers: this.headers(),
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Render a prompt with variables.
|
|
139
|
-
*/
|
|
140
|
-
async render(promptId: string, variables: Record<string, unknown>): Promise<APIResponse<RenderPromptResponse>> {
|
|
141
|
-
return this.client.POST<RenderPromptResponse>("/v1/api/prompts/{id}/render", {
|
|
142
|
-
params: { path: { id: promptId } },
|
|
143
|
-
body: { variables },
|
|
144
|
-
headers: this.headers(),
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
}
|