@proteos/sdk 0.18.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/LICENSE +40 -0
- package/dist/chunk-7RGN4E22.cjs +1185 -0
- package/dist/chunk-7RGN4E22.cjs.map +1 -0
- package/dist/chunk-XJP5WCRZ.js +1125 -0
- package/dist/chunk-XJP5WCRZ.js.map +1 -0
- package/dist/index.cjs +2384 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +5225 -0
- package/dist/index.d.ts +5225 -0
- package/dist/index.js +2146 -0
- package/dist/index.js.map +1 -0
- package/dist/meta/index.cjs +204 -0
- package/dist/meta/index.cjs.map +1 -0
- package/dist/meta/index.d.cts +2 -0
- package/dist/meta/index.d.ts +2 -0
- package/dist/meta/index.js +3 -0
- package/dist/meta/index.js.map +1 -0
- package/dist/types-BNsjfU8N.d.cts +3299 -0
- package/dist/types-BNsjfU8N.d.ts +3299 -0
- package/package.json +86 -0
- package/src/agent/agents.ts +53 -0
- package/src/agent/index.ts +134 -0
- package/src/agent/mcp-servers.ts +102 -0
- package/src/agent/prompts.ts +80 -0
- package/src/agent/session-types.ts +397 -0
- package/src/agent/sessions.ts +197 -0
- package/src/agent/skills.ts +89 -0
- package/src/agent/tools.ts +53 -0
- package/src/agent/types.ts +362 -0
- package/src/auth/index.ts +111 -0
- package/src/auth/me.ts +46 -0
- package/src/auth/organizations.ts +128 -0
- package/src/auth/platform-entities.ts +78 -0
- package/src/auth/roles.ts +213 -0
- package/src/auth/types.ts +294 -0
- package/src/auth/users.ts +226 -0
- package/src/client.ts +441 -0
- package/src/connector/index.ts +120 -0
- package/src/connector/types.ts +150 -0
- package/src/conversation/index.ts +297 -0
- package/src/conversation/types.ts +590 -0
- package/src/conversation/voice.ts +123 -0
- package/src/data/index.ts +53 -0
- package/src/data/queries.ts +66 -0
- package/src/data/records.ts +122 -0
- package/src/data/types.ts +89 -0
- package/src/errors.ts +148 -0
- package/src/events/index.ts +172 -0
- package/src/events/types.ts +77 -0
- package/src/functions/actions.ts +95 -0
- package/src/functions/index.ts +32 -0
- package/src/functions/types.ts +71 -0
- package/src/http/index.ts +2 -0
- package/src/http/query-params.ts +106 -0
- package/src/index.ts +598 -0
- package/src/iterator.ts +183 -0
- package/src/knowledge/graph.ts +35 -0
- package/src/knowledge/index.ts +104 -0
- package/src/knowledge/labels.ts +70 -0
- package/src/knowledge/links.ts +65 -0
- package/src/knowledge/nodes.ts +198 -0
- package/src/knowledge/record-links.ts +66 -0
- package/src/knowledge/types.ts +569 -0
- package/src/meta/apps.ts +107 -0
- package/src/meta/components.ts +124 -0
- package/src/meta/currency/index.ts +202 -0
- package/src/meta/entities.ts +193 -0
- package/src/meta/filters.ts +76 -0
- package/src/meta/index.ts +227 -0
- package/src/meta/layout/common-props.ts +93 -0
- package/src/meta/layout/control-registry.json +70 -0
- package/src/meta/layout/control-registry.ts +92 -0
- package/src/meta/layout/elements.ts +203 -0
- package/src/meta/layout/index.ts +41 -0
- package/src/meta/layout/page-layout.ts +35 -0
- package/src/meta/layout/size-value.ts +27 -0
- package/src/meta/list-views.ts +109 -0
- package/src/meta/lists.ts +104 -0
- package/src/meta/menu-configurations.ts +128 -0
- package/src/meta/modules.ts +159 -0
- package/src/meta/pages.ts +106 -0
- package/src/meta/types.ts +1115 -0
- package/src/meta/variables.ts +98 -0
- package/src/storage/files.ts +183 -0
- package/src/storage/index.ts +33 -0
- package/src/storage/types.ts +70 -0
- package/src/types/common.ts +143 -0
- package/src/types/index.ts +28 -0
- package/src/types/options.ts +95 -0
- package/src/workflow/executions.ts +99 -0
- package/src/workflow/index.ts +109 -0
- package/src/workflow/node-types.ts +50 -0
- package/src/workflow/types.ts +658 -0
- package/src/workflow/workflows.ts +152 -0
package/package.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proteos/sdk",
|
|
3
|
+
"version": "0.18.1",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"description": "TypeScript SDK for the Proteos platform",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/proteos-ai/go-sdk.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/proteos-ai/go-sdk",
|
|
11
|
+
"bugs": "https://github.com/proteos-ai/go-sdk/issues",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/index.cjs",
|
|
14
|
+
"module": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"require": {
|
|
23
|
+
"types": "./dist/index.d.cts",
|
|
24
|
+
"default": "./dist/index.cjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"./meta": {
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/meta/index.d.ts",
|
|
30
|
+
"default": "./dist/meta/index.js"
|
|
31
|
+
},
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./dist/meta/index.d.cts",
|
|
34
|
+
"default": "./dist/meta/index.cjs"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public",
|
|
40
|
+
"provenance": false
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"src"
|
|
45
|
+
],
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=20.0.0"
|
|
48
|
+
},
|
|
49
|
+
"keywords": [
|
|
50
|
+
"proteos",
|
|
51
|
+
"sdk",
|
|
52
|
+
"api",
|
|
53
|
+
"client",
|
|
54
|
+
"typescript"
|
|
55
|
+
],
|
|
56
|
+
"author": "Tonio Knuth",
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@microsoft/fetch-event-source": "^2.0.1",
|
|
59
|
+
"zod": "^3.23.8"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@biomejs/biome": "^2.4.13",
|
|
63
|
+
"@types/node": "^22.10.0",
|
|
64
|
+
"@vitest/coverage-v8": "^3.0.0",
|
|
65
|
+
"msw": "^2.7.0",
|
|
66
|
+
"tsup": "^8.3.0",
|
|
67
|
+
"typescript": "^5.7.0",
|
|
68
|
+
"vitest": "^3.0.0",
|
|
69
|
+
"@proteos/biome-config": "0.0.0",
|
|
70
|
+
"@proteos/tsconfig": "0.0.0"
|
|
71
|
+
},
|
|
72
|
+
"scripts": {
|
|
73
|
+
"build": "tsup",
|
|
74
|
+
"dev": "tsup --watch",
|
|
75
|
+
"test": "vitest run",
|
|
76
|
+
"test:watch": "vitest",
|
|
77
|
+
"test:coverage": "vitest run --coverage",
|
|
78
|
+
"test:integration": "vitest run --config vitest.integration.config.ts",
|
|
79
|
+
"test:integration:watch": "vitest --config vitest.integration.config.ts",
|
|
80
|
+
"test:all": "pnpm test && pnpm test:integration",
|
|
81
|
+
"typecheck": "tsc -b",
|
|
82
|
+
"lint": "biome check .",
|
|
83
|
+
"format": "biome format --write .",
|
|
84
|
+
"clean": "rm -rf dist"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ProteosClient } from '../client.js'
|
|
2
|
+
import { PageIterator } from '../iterator.js'
|
|
3
|
+
import type { ListResult } from '../types/common.js'
|
|
4
|
+
import type { Agent, CreateAgentRequest, ListAgentsOptions, UpdateAgentRequest } from './types.js'
|
|
5
|
+
|
|
6
|
+
const AGENTS_BASE_PATH = '/agents/v1/agents'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Service for managing Agents — configured personas (system prompt + model
|
|
10
|
+
* config + the skills/tools/sub-agents they can use). Keyed by immutable `key`.
|
|
11
|
+
*/
|
|
12
|
+
export interface AgentService {
|
|
13
|
+
/** Lists agents, auto-paginating. */
|
|
14
|
+
list(options?: ListAgentsOptions): PageIterator<Agent, ListAgentsOptions>
|
|
15
|
+
/** Fetches a single page of agents with pagination metadata. */
|
|
16
|
+
listPage(options?: ListAgentsOptions): Promise<ListResult<Agent>>
|
|
17
|
+
/** Gets a single agent by key. @throws {ProteosError} 404 if not found. */
|
|
18
|
+
get(key: string): Promise<Agent>
|
|
19
|
+
/** Creates a new agent. @throws {ProteosError} 400/409. */
|
|
20
|
+
create(request: CreateAgentRequest): Promise<Agent>
|
|
21
|
+
/** Patches an existing agent (partial). @throws {ProteosError} 404/400. */
|
|
22
|
+
update(key: string, request: UpdateAgentRequest): Promise<Agent>
|
|
23
|
+
/** Deletes an agent. @throws {ProteosError} 404 if not found. */
|
|
24
|
+
delete(key: string): Promise<void>
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class AgentServiceImpl implements AgentService {
|
|
28
|
+
constructor(private readonly client: ProteosClient) {}
|
|
29
|
+
|
|
30
|
+
list(options: ListAgentsOptions = {}): PageIterator<Agent, ListAgentsOptions> {
|
|
31
|
+
return new PageIterator((opts) => this.listPage(opts), options)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async listPage(options: ListAgentsOptions = {}): Promise<ListResult<Agent>> {
|
|
35
|
+
return this.client.requestWithQuery<ListResult<Agent>>('GET', AGENTS_BASE_PATH, options)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async get(key: string): Promise<Agent> {
|
|
39
|
+
return this.client.request<Agent>('GET', `${AGENTS_BASE_PATH}/${key}`)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async create(request: CreateAgentRequest): Promise<Agent> {
|
|
43
|
+
return this.client.request<Agent>('POST', AGENTS_BASE_PATH, request)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async update(key: string, request: UpdateAgentRequest): Promise<Agent> {
|
|
47
|
+
return this.client.request<Agent>('PATCH', `${AGENTS_BASE_PATH}/${key}`, request)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async delete(key: string): Promise<void> {
|
|
51
|
+
await this.client.request<void>('DELETE', `${AGENTS_BASE_PATH}/${key}`)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { ProteosClient } from '../client.js'
|
|
2
|
+
import { type AgentService, AgentServiceImpl } from './agents.js'
|
|
3
|
+
import { type McpServerService, McpServerServiceImpl } from './mcp-servers.js'
|
|
4
|
+
import { type PromptService, PromptServiceImpl } from './prompts.js'
|
|
5
|
+
import { type SessionService, SessionServiceImpl } from './sessions.js'
|
|
6
|
+
import { type SkillService, SkillServiceImpl } from './skills.js'
|
|
7
|
+
import { type ToolService, ToolServiceImpl } from './tools.js'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Client for the Proteos Agent Service API.
|
|
11
|
+
*
|
|
12
|
+
* Manages the AI-agent configuration domain: Agents, Prompts (versioned),
|
|
13
|
+
* Skills (versioned bundles), Tools, and MCP Servers — all org-scoped and keyed
|
|
14
|
+
* by an immutable kebab-case `key`.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { ProteosClient, AgentClient } from '@proteos/sdk';
|
|
19
|
+
*
|
|
20
|
+
* const client = new ProteosClient({ baseUrl, token });
|
|
21
|
+
* const agent = new AgentClient(client);
|
|
22
|
+
*
|
|
23
|
+
* const agents = await agent.agents.list().all();
|
|
24
|
+
* const prompt = await agent.prompts.get('revenue-brief');
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export class AgentClient {
|
|
28
|
+
/** Service for managing agents. */
|
|
29
|
+
readonly agents: AgentService
|
|
30
|
+
/** Service for managing prompts (versioned). */
|
|
31
|
+
readonly prompts: PromptService
|
|
32
|
+
/** Service for managing skills (versioned bundles). */
|
|
33
|
+
readonly skills: SkillService
|
|
34
|
+
/** Service for managing tools. */
|
|
35
|
+
readonly tools: ToolService
|
|
36
|
+
/** Service for managing MCP server registrations. */
|
|
37
|
+
readonly mcpServers: McpServerService
|
|
38
|
+
/** Service for managing chat sessions (conversations + event log + stream). */
|
|
39
|
+
readonly sessions: SessionService
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new AgentClient instance.
|
|
43
|
+
*
|
|
44
|
+
* @param client - The base ProteosClient to use for API requests
|
|
45
|
+
*/
|
|
46
|
+
constructor(client: ProteosClient) {
|
|
47
|
+
this.agents = new AgentServiceImpl(client)
|
|
48
|
+
this.prompts = new PromptServiceImpl(client)
|
|
49
|
+
this.skills = new SkillServiceImpl(client)
|
|
50
|
+
this.tools = new ToolServiceImpl(client)
|
|
51
|
+
this.mcpServers = new McpServerServiceImpl(client)
|
|
52
|
+
this.sessions = new SessionServiceImpl(client)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Re-export service interfaces
|
|
57
|
+
export type { AgentService } from './agents.js'
|
|
58
|
+
export type { McpServerService } from './mcp-servers.js'
|
|
59
|
+
export type { PromptService } from './prompts.js'
|
|
60
|
+
// Re-export session types
|
|
61
|
+
export type {
|
|
62
|
+
AgentArtifactsPayload,
|
|
63
|
+
AgentMessagePayload,
|
|
64
|
+
AppendEventRequest,
|
|
65
|
+
ClientEventType,
|
|
66
|
+
ClientToolSchema,
|
|
67
|
+
ContentBlock,
|
|
68
|
+
ContextCompactedPayload,
|
|
69
|
+
CreateSessionRequest,
|
|
70
|
+
EmptyPayload,
|
|
71
|
+
ErrorPayload,
|
|
72
|
+
EventType,
|
|
73
|
+
FileBlock,
|
|
74
|
+
ListSessionsOptions,
|
|
75
|
+
ModelRequestEndPayload,
|
|
76
|
+
ModelRequestStartPayload,
|
|
77
|
+
ModelUsage,
|
|
78
|
+
ReasoningPayload,
|
|
79
|
+
ResultBlock,
|
|
80
|
+
Session,
|
|
81
|
+
SessionEvent,
|
|
82
|
+
SessionEventEnvelope,
|
|
83
|
+
SessionEventsOptions,
|
|
84
|
+
SessionIdlePayload,
|
|
85
|
+
SessionStatus,
|
|
86
|
+
SessionStreamOptions,
|
|
87
|
+
SessionUpdatedPayload,
|
|
88
|
+
StopReason,
|
|
89
|
+
TextBlock,
|
|
90
|
+
ToolConfirmationPayload,
|
|
91
|
+
ToolResultPayload,
|
|
92
|
+
ToolUsePayload,
|
|
93
|
+
Turn,
|
|
94
|
+
UserMessagePayload,
|
|
95
|
+
} from './session-types.js'
|
|
96
|
+
export type { SessionService } from './sessions.js'
|
|
97
|
+
export type { SkillService } from './skills.js'
|
|
98
|
+
export type { ToolService } from './tools.js'
|
|
99
|
+
// Re-export types
|
|
100
|
+
export type {
|
|
101
|
+
ActionBinding,
|
|
102
|
+
Agent,
|
|
103
|
+
AgentResourceListOptions,
|
|
104
|
+
CreateAgentRequest,
|
|
105
|
+
CreateMcpServerRequest,
|
|
106
|
+
CreatePromptRequest,
|
|
107
|
+
CreateToolRequest,
|
|
108
|
+
ListAgentsOptions,
|
|
109
|
+
ListMcpServersOptions,
|
|
110
|
+
ListPromptsOptions,
|
|
111
|
+
ListSkillsOptions,
|
|
112
|
+
ListToolsOptions,
|
|
113
|
+
McpBinding,
|
|
114
|
+
McpConnectionState,
|
|
115
|
+
McpConnectionStatus,
|
|
116
|
+
McpServer,
|
|
117
|
+
McpServerAuth,
|
|
118
|
+
McpServerOAuth,
|
|
119
|
+
McpToolSummary,
|
|
120
|
+
ModelConfig,
|
|
121
|
+
Prompt,
|
|
122
|
+
PromptVersion,
|
|
123
|
+
Skill,
|
|
124
|
+
SkillBundle,
|
|
125
|
+
SkillVersion,
|
|
126
|
+
StartMcpOAuthResponse,
|
|
127
|
+
Tool,
|
|
128
|
+
ToolBinding,
|
|
129
|
+
ToolKind,
|
|
130
|
+
UpdateAgentRequest,
|
|
131
|
+
UpdateMcpServerRequest,
|
|
132
|
+
UpdatePromptRequest,
|
|
133
|
+
UpdateToolRequest,
|
|
134
|
+
} from './types.js'
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { ProteosClient } from '../client.js'
|
|
2
|
+
import { PageIterator } from '../iterator.js'
|
|
3
|
+
import type { ListResult } from '../types/common.js'
|
|
4
|
+
import type {
|
|
5
|
+
CreateMcpServerRequest,
|
|
6
|
+
ListMcpServersOptions,
|
|
7
|
+
McpConnectionStatus,
|
|
8
|
+
McpServer,
|
|
9
|
+
McpToolSummary,
|
|
10
|
+
StartMcpOAuthResponse,
|
|
11
|
+
UpdateMcpServerRequest,
|
|
12
|
+
} from './types.js'
|
|
13
|
+
|
|
14
|
+
const MCP_SERVERS_BASE_PATH = '/agents/v1/mcp-servers'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Service for managing MCP Servers — the consumer-side registry of MCP servers
|
|
18
|
+
* an org's agents can call (the source of `kind=mcp` tools). When `auth.is_secret`
|
|
19
|
+
* is set, the token is redacted to `''` on read; send a new token only to change
|
|
20
|
+
* it.
|
|
21
|
+
*/
|
|
22
|
+
export interface McpServerService {
|
|
23
|
+
/** Lists MCP servers, auto-paginating. */
|
|
24
|
+
list(options?: ListMcpServersOptions): PageIterator<McpServer, ListMcpServersOptions>
|
|
25
|
+
/** Fetches a single page of MCP servers with pagination metadata. */
|
|
26
|
+
listPage(options?: ListMcpServersOptions): Promise<ListResult<McpServer>>
|
|
27
|
+
/** Gets a single MCP server by key (token redacted if secret). @throws {ProteosError} 404. */
|
|
28
|
+
get(key: string): Promise<McpServer>
|
|
29
|
+
/** Registers a new MCP server. @throws {ProteosError} 400/409. */
|
|
30
|
+
create(request: CreateMcpServerRequest): Promise<McpServer>
|
|
31
|
+
/** Patches an MCP server (partial). @throws {ProteosError} 404/400. */
|
|
32
|
+
update(key: string, request: UpdateMcpServerRequest): Promise<McpServer>
|
|
33
|
+
/** Deletes an MCP server. @throws {ProteosError} 404. */
|
|
34
|
+
delete(key: string): Promise<void>
|
|
35
|
+
/** Lists the live tools of a (connected) MCP server via tools/list. @throws {ProteosError} 404/502. */
|
|
36
|
+
listTools(key: string): Promise<McpToolSummary[]>
|
|
37
|
+
/** Reports a server's derived OAuth connection state. @throws {ProteosError} 404. */
|
|
38
|
+
getConnectionStatus(key: string): Promise<McpConnectionStatus>
|
|
39
|
+
/** Starts the OAuth connect flow; open the returned `authorization_url` in a popup. @throws {ProteosError} 400/404. */
|
|
40
|
+
startOAuth(key: string): Promise<StartMcpOAuthResponse>
|
|
41
|
+
/** Drops a server's stored OAuth tokens. @throws {ProteosError} 400/404. */
|
|
42
|
+
disconnectOAuth(key: string): Promise<void>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export class McpServerServiceImpl implements McpServerService {
|
|
46
|
+
constructor(private readonly client: ProteosClient) {}
|
|
47
|
+
|
|
48
|
+
list(options: ListMcpServersOptions = {}): PageIterator<McpServer, ListMcpServersOptions> {
|
|
49
|
+
return new PageIterator((opts) => this.listPage(opts), options)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async listPage(options: ListMcpServersOptions = {}): Promise<ListResult<McpServer>> {
|
|
53
|
+
return this.client.requestWithQuery<ListResult<McpServer>>(
|
|
54
|
+
'GET',
|
|
55
|
+
MCP_SERVERS_BASE_PATH,
|
|
56
|
+
options,
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async get(key: string): Promise<McpServer> {
|
|
61
|
+
return this.client.request<McpServer>('GET', `${MCP_SERVERS_BASE_PATH}/${key}`)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async create(request: CreateMcpServerRequest): Promise<McpServer> {
|
|
65
|
+
return this.client.request<McpServer>('POST', MCP_SERVERS_BASE_PATH, request)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async update(key: string, request: UpdateMcpServerRequest): Promise<McpServer> {
|
|
69
|
+
return this.client.request<McpServer>('PATCH', `${MCP_SERVERS_BASE_PATH}/${key}`, request)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async delete(key: string): Promise<void> {
|
|
73
|
+
await this.client.request<void>('DELETE', `${MCP_SERVERS_BASE_PATH}/${key}`)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async listTools(key: string): Promise<McpToolSummary[]> {
|
|
77
|
+
const response = await this.client.request<{ data: McpToolSummary[] }>(
|
|
78
|
+
'GET',
|
|
79
|
+
`${MCP_SERVERS_BASE_PATH}/${key}/tools`,
|
|
80
|
+
)
|
|
81
|
+
return response.data
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async getConnectionStatus(key: string): Promise<McpConnectionStatus> {
|
|
85
|
+
const response = await this.client.request<{ data: McpConnectionStatus }>(
|
|
86
|
+
'GET',
|
|
87
|
+
`${MCP_SERVERS_BASE_PATH}/${key}/connection`,
|
|
88
|
+
)
|
|
89
|
+
return response.data
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async startOAuth(key: string): Promise<StartMcpOAuthResponse> {
|
|
93
|
+
return this.client.request<StartMcpOAuthResponse>(
|
|
94
|
+
'POST',
|
|
95
|
+
`${MCP_SERVERS_BASE_PATH}/${key}/oauth/connect`,
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async disconnectOAuth(key: string): Promise<void> {
|
|
100
|
+
await this.client.request<void>('DELETE', `${MCP_SERVERS_BASE_PATH}/${key}/oauth/connect`)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { ProteosClient } from '../client.js'
|
|
2
|
+
import { PageIterator } from '../iterator.js'
|
|
3
|
+
import type { ListResult } from '../types/common.js'
|
|
4
|
+
import type {
|
|
5
|
+
CreatePromptRequest,
|
|
6
|
+
ListPromptsOptions,
|
|
7
|
+
Prompt,
|
|
8
|
+
PromptVersion,
|
|
9
|
+
UpdatePromptRequest,
|
|
10
|
+
} from './types.js'
|
|
11
|
+
|
|
12
|
+
const PROMPTS_BASE_PATH = '/agents/v1/prompts'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Service for managing Prompts — reusable, Liquid-templated instruction texts,
|
|
16
|
+
* versioned like storage files. A `body` change on update forks a new immutable
|
|
17
|
+
* version; metadata-only updates do not.
|
|
18
|
+
*/
|
|
19
|
+
export interface PromptService {
|
|
20
|
+
/** Lists prompts, auto-paginating. */
|
|
21
|
+
list(options?: ListPromptsOptions): PageIterator<Prompt, ListPromptsOptions>
|
|
22
|
+
/** Fetches a single page of prompts with pagination metadata. */
|
|
23
|
+
listPage(options?: ListPromptsOptions): Promise<ListResult<Prompt>>
|
|
24
|
+
/** Gets a prompt (with its current version) by key. @throws {ProteosError} 404. */
|
|
25
|
+
get(key: string): Promise<Prompt>
|
|
26
|
+
/** Creates a new prompt with version 1. @throws {ProteosError} 400/409. */
|
|
27
|
+
create(request: CreatePromptRequest): Promise<Prompt>
|
|
28
|
+
/** Patches a prompt; a new `body` forks a version. @throws {ProteosError} 404/400. */
|
|
29
|
+
update(key: string, request: UpdatePromptRequest): Promise<Prompt>
|
|
30
|
+
/** Deletes a prompt and all its versions. @throws {ProteosError} 404. */
|
|
31
|
+
delete(key: string): Promise<void>
|
|
32
|
+
/** Lists all immutable versions of a prompt, newest first. */
|
|
33
|
+
listVersions(key: string): Promise<PromptVersion[]>
|
|
34
|
+
/** Gets a specific immutable version by number. @throws {ProteosError} 404. */
|
|
35
|
+
getVersion(key: string, number: number): Promise<PromptVersion>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class PromptServiceImpl implements PromptService {
|
|
39
|
+
constructor(private readonly client: ProteosClient) {}
|
|
40
|
+
|
|
41
|
+
list(options: ListPromptsOptions = {}): PageIterator<Prompt, ListPromptsOptions> {
|
|
42
|
+
return new PageIterator((opts) => this.listPage(opts), options)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async listPage(options: ListPromptsOptions = {}): Promise<ListResult<Prompt>> {
|
|
46
|
+
return this.client.requestWithQuery<ListResult<Prompt>>('GET', PROMPTS_BASE_PATH, options)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async get(key: string): Promise<Prompt> {
|
|
50
|
+
return this.client.request<Prompt>('GET', `${PROMPTS_BASE_PATH}/${key}`)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async create(request: CreatePromptRequest): Promise<Prompt> {
|
|
54
|
+
return this.client.request<Prompt>('POST', PROMPTS_BASE_PATH, request)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async update(key: string, request: UpdatePromptRequest): Promise<Prompt> {
|
|
58
|
+
return this.client.request<Prompt>('PATCH', `${PROMPTS_BASE_PATH}/${key}`, request)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async delete(key: string): Promise<void> {
|
|
62
|
+
await this.client.request<void>('DELETE', `${PROMPTS_BASE_PATH}/${key}`)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async listVersions(key: string): Promise<PromptVersion[]> {
|
|
66
|
+
// The versions endpoint wraps in `{ data }` (no pagination meta).
|
|
67
|
+
const response = await this.client.request<{ data: PromptVersion[] }>(
|
|
68
|
+
'GET',
|
|
69
|
+
`${PROMPTS_BASE_PATH}/${key}/versions`,
|
|
70
|
+
)
|
|
71
|
+
return response.data
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async getVersion(key: string, number: number): Promise<PromptVersion> {
|
|
75
|
+
return this.client.request<PromptVersion>(
|
|
76
|
+
'GET',
|
|
77
|
+
`${PROMPTS_BASE_PATH}/${key}/versions/${number}`,
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
}
|