@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
|
@@ -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 { CreateToolRequest, ListToolsOptions, Tool, UpdateToolRequest } from './types.js'
|
|
5
|
+
|
|
6
|
+
const TOOLS_BASE_PATH = '/agents/v1/tools'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Service for managing Tools — thin registry entries over one of three binding
|
|
10
|
+
* sources (action / mcp / client). `update` fully replaces the definition.
|
|
11
|
+
*/
|
|
12
|
+
export interface ToolService {
|
|
13
|
+
/** Lists tools, auto-paginating. Filterable by `kind`. */
|
|
14
|
+
list(options?: ListToolsOptions): PageIterator<Tool, ListToolsOptions>
|
|
15
|
+
/** Fetches a single page of tools with pagination metadata. */
|
|
16
|
+
listPage(options?: ListToolsOptions): Promise<ListResult<Tool>>
|
|
17
|
+
/** Gets a single tool by key. @throws {ProteosError} 404. */
|
|
18
|
+
get(key: string): Promise<Tool>
|
|
19
|
+
/** Creates a new tool. @throws {ProteosError} 400/409. */
|
|
20
|
+
create(request: CreateToolRequest): Promise<Tool>
|
|
21
|
+
/** Fully replaces a tool's definition. @throws {ProteosError} 404/400. */
|
|
22
|
+
update(key: string, request: UpdateToolRequest): Promise<Tool>
|
|
23
|
+
/** Deletes a tool. @throws {ProteosError} 404. */
|
|
24
|
+
delete(key: string): Promise<void>
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class ToolServiceImpl implements ToolService {
|
|
28
|
+
constructor(private readonly client: ProteosClient) {}
|
|
29
|
+
|
|
30
|
+
list(options: ListToolsOptions = {}): PageIterator<Tool, ListToolsOptions> {
|
|
31
|
+
return new PageIterator((opts) => this.listPage(opts), options)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async listPage(options: ListToolsOptions = {}): Promise<ListResult<Tool>> {
|
|
35
|
+
return this.client.requestWithQuery<ListResult<Tool>>('GET', TOOLS_BASE_PATH, options)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async get(key: string): Promise<Tool> {
|
|
39
|
+
return this.client.request<Tool>('GET', `${TOOLS_BASE_PATH}/${key}`)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async create(request: CreateToolRequest): Promise<Tool> {
|
|
43
|
+
return this.client.request<Tool>('POST', TOOLS_BASE_PATH, request)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async update(key: string, request: UpdateToolRequest): Promise<Tool> {
|
|
47
|
+
return this.client.request<Tool>('PATCH', `${TOOLS_BASE_PATH}/${key}`, request)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async delete(key: string): Promise<void> {
|
|
51
|
+
await this.client.request<void>('DELETE', `${TOOLS_BASE_PATH}/${key}`)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the Proteos Agent Service API.
|
|
3
|
+
*
|
|
4
|
+
* Hand-written mirror of the Go models in `go.proteos.ai/model/agent`
|
|
5
|
+
* (`agent.go`, `prompt.go`, `skill.go`, `tool.go`, `tool-kind.go`,
|
|
6
|
+
* `mcp-server.go`, `model-config.go` + `api/*-requests.go`). Field names match
|
|
7
|
+
* the snake_case wire format exactly, including enum values.
|
|
8
|
+
*
|
|
9
|
+
* All five resources are org-scoped and keyed by an immutable kebab-case `key`.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// `inputs` (prompts) and `input_schema` (tools) reuse the platform attribute
|
|
13
|
+
// shape — the same `Attribute` the meta-service uses for entity attributes and
|
|
14
|
+
// action params. Do not redefine it here.
|
|
15
|
+
import type { Attribute } from '../meta/types.js'
|
|
16
|
+
import type { AuditFields, ListOptions, UserRef } from '../types/common.js'
|
|
17
|
+
|
|
18
|
+
export type { Attribute } from '../meta/types.js'
|
|
19
|
+
|
|
20
|
+
/** Shared name/key filter carried by every agent-service list endpoint. */
|
|
21
|
+
export interface AgentResourceListOptions extends ListOptions {
|
|
22
|
+
/** Exact key match. */
|
|
23
|
+
key?: string
|
|
24
|
+
/** Exact name match. */
|
|
25
|
+
name?: string
|
|
26
|
+
/** Filter by owning module slug. */
|
|
27
|
+
module_slug?: string
|
|
28
|
+
/** Case-insensitive substring match on name. */
|
|
29
|
+
'name[contains]'?: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
// Agents
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Inline LLM configuration an Agent runs with. v1 carries the model id plus
|
|
38
|
+
* optional sampling knobs; a provider/credentials registry is deferred.
|
|
39
|
+
*/
|
|
40
|
+
export interface ModelConfig {
|
|
41
|
+
model_id: string
|
|
42
|
+
temperature?: number
|
|
43
|
+
max_tokens?: number
|
|
44
|
+
thinking?: boolean
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A configured persona: a system prompt + model config + the skills, tools,
|
|
49
|
+
* sub-agents and MCP servers it can use. All references are by key (immutable):
|
|
50
|
+
* `system_prompt` is a Prompt key; `skills`/`tools`/`subagents`/`mcp_servers` are
|
|
51
|
+
* Skill/Tool/Agent/McpServer keys. Attaching an MCP server exposes every tool the
|
|
52
|
+
* server provides (vs a `kind: 'mcp'` tool, which binds a single one). Keyed by
|
|
53
|
+
* (org_id, key).
|
|
54
|
+
*/
|
|
55
|
+
export interface Agent extends AuditFields {
|
|
56
|
+
org_id: string
|
|
57
|
+
key: string
|
|
58
|
+
name: string
|
|
59
|
+
module_slug: string
|
|
60
|
+
description: string
|
|
61
|
+
system_prompt: string
|
|
62
|
+
model_config: ModelConfig
|
|
63
|
+
skills: string[]
|
|
64
|
+
tools: string[]
|
|
65
|
+
subagents: string[]
|
|
66
|
+
mcp_servers: string[]
|
|
67
|
+
/** Marks the single agent surfaced by default for the org (at most one). */
|
|
68
|
+
is_org_default: boolean
|
|
69
|
+
version: number
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface CreateAgentRequest {
|
|
73
|
+
key: string
|
|
74
|
+
name: string
|
|
75
|
+
module_slug?: string
|
|
76
|
+
description?: string
|
|
77
|
+
system_prompt?: string
|
|
78
|
+
model_config?: ModelConfig
|
|
79
|
+
skills?: string[]
|
|
80
|
+
tools?: string[]
|
|
81
|
+
subagents?: string[]
|
|
82
|
+
mcp_servers?: string[]
|
|
83
|
+
is_org_default?: boolean
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface UpdateAgentRequest {
|
|
87
|
+
name?: string
|
|
88
|
+
module_slug?: string
|
|
89
|
+
description?: string
|
|
90
|
+
system_prompt?: string
|
|
91
|
+
model_config?: ModelConfig
|
|
92
|
+
skills?: string[]
|
|
93
|
+
tools?: string[]
|
|
94
|
+
subagents?: string[]
|
|
95
|
+
mcp_servers?: string[]
|
|
96
|
+
is_org_default?: boolean
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export type ListAgentsOptions = AgentResourceListOptions
|
|
100
|
+
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
// Prompts (versioned)
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* An immutable snapshot of a Prompt's content. Editing `body` or `inputs` forks
|
|
107
|
+
* a new version; metadata-only edits do not. `inputs` declares the Liquid
|
|
108
|
+
* placeholders the template expects.
|
|
109
|
+
*/
|
|
110
|
+
export interface PromptVersion {
|
|
111
|
+
id: string
|
|
112
|
+
number: number
|
|
113
|
+
org_id: string
|
|
114
|
+
prompt_key: string
|
|
115
|
+
body: string
|
|
116
|
+
inputs: Attribute[]
|
|
117
|
+
hash: string
|
|
118
|
+
created_at: string
|
|
119
|
+
created_by: UserRef
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* A reusable, Liquid-templated instruction text, versioned like a storage file:
|
|
124
|
+
* the parent row holds identity + metadata + a pointer to the current immutable
|
|
125
|
+
* {@link PromptVersion}. Keyed by (org_id, key); key is immutable.
|
|
126
|
+
*/
|
|
127
|
+
export interface Prompt extends AuditFields {
|
|
128
|
+
org_id: string
|
|
129
|
+
key: string
|
|
130
|
+
name: string
|
|
131
|
+
module_slug: string
|
|
132
|
+
description: string
|
|
133
|
+
current_version: PromptVersion | null
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface CreatePromptRequest {
|
|
137
|
+
key: string
|
|
138
|
+
name: string
|
|
139
|
+
module_slug?: string
|
|
140
|
+
description?: string
|
|
141
|
+
body: string
|
|
142
|
+
inputs?: Attribute[]
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* A patch: `name`/`description` edit metadata in place; supplying `body` forks a
|
|
147
|
+
* new immutable version (`inputs` carries forward unless also supplied). A
|
|
148
|
+
* metadata-only patch creates no version.
|
|
149
|
+
*/
|
|
150
|
+
export interface UpdatePromptRequest {
|
|
151
|
+
name?: string
|
|
152
|
+
module_slug?: string
|
|
153
|
+
description?: string
|
|
154
|
+
body?: string
|
|
155
|
+
inputs?: Attribute[]
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export type ListPromptsOptions = AgentResourceListOptions
|
|
159
|
+
|
|
160
|
+
// ---------------------------------------------------------------------------
|
|
161
|
+
// Skills (versioned bundles)
|
|
162
|
+
// ---------------------------------------------------------------------------
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Pins the exact immutable storage Version the SKILL.md+files bundle (tar.gz)
|
|
166
|
+
* was uploaded as. `file_version_id` is the real pin; `checksum_sha256` /
|
|
167
|
+
* `size_in_bytes` are denormalized for cheap display.
|
|
168
|
+
*/
|
|
169
|
+
export interface SkillBundle {
|
|
170
|
+
file_id: string
|
|
171
|
+
file_version_id: string
|
|
172
|
+
checksum_sha256: string
|
|
173
|
+
size_in_bytes: number
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** An immutable snapshot pinning one storage bundle. */
|
|
177
|
+
export interface SkillVersion {
|
|
178
|
+
id: string
|
|
179
|
+
number: number
|
|
180
|
+
org_id: string
|
|
181
|
+
skill_key: string
|
|
182
|
+
bundle: SkillBundle
|
|
183
|
+
created_at: string
|
|
184
|
+
created_by: UserRef
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* A versioned bundle of instructions + files in the Anthropic Agent-Skills
|
|
189
|
+
* shape. `key` = the SKILL.md frontmatter `name`. The parent caches the L1
|
|
190
|
+
* discovery metadata (name + description); the bundle is the source of truth and
|
|
191
|
+
* lives on the immutable version rows. Created/updated only via the multipart
|
|
192
|
+
* deploy endpoint, not a JSON body.
|
|
193
|
+
*/
|
|
194
|
+
export interface Skill extends AuditFields {
|
|
195
|
+
org_id: string
|
|
196
|
+
key: string
|
|
197
|
+
name: string
|
|
198
|
+
module_slug: string
|
|
199
|
+
description: string
|
|
200
|
+
current_version: SkillVersion | null
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export type ListSkillsOptions = AgentResourceListOptions
|
|
204
|
+
|
|
205
|
+
// ---------------------------------------------------------------------------
|
|
206
|
+
// Tools
|
|
207
|
+
// ---------------------------------------------------------------------------
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* The binding SOURCE of a Tool: where the callable comes from.
|
|
211
|
+
* - `action` binds to a function-service Action.
|
|
212
|
+
* - `mcp` binds to one tool on a registered {@link McpServer}.
|
|
213
|
+
* - `client` is a host-provided builtin and carries no binding.
|
|
214
|
+
*/
|
|
215
|
+
export type ToolKind = 'action' | 'mcp' | 'client'
|
|
216
|
+
|
|
217
|
+
/** Binds to a function-service Action by its key (kind=action). */
|
|
218
|
+
export interface ActionBinding {
|
|
219
|
+
action_key: string
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** Binds to one tool on a registered MCP server (kind=mcp). */
|
|
223
|
+
export interface McpBinding {
|
|
224
|
+
server_key: string
|
|
225
|
+
tool_name: string
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** Kind-discriminated binding payload. `kind=client` carries no binding. */
|
|
229
|
+
export type ToolBinding = ActionBinding | McpBinding
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* A thin registry entry over one of three binding sources. `key` is the wire
|
|
233
|
+
* name the model calls (`tool_use.name`) and what `Agent.tools` lists.
|
|
234
|
+
* `input_schema` declares the params. `binding` is decoded by `kind` (absent for
|
|
235
|
+
* client tools). Keyed by (org_id, key).
|
|
236
|
+
*/
|
|
237
|
+
export interface Tool extends AuditFields {
|
|
238
|
+
org_id: string
|
|
239
|
+
key: string
|
|
240
|
+
name: string
|
|
241
|
+
module_slug: string
|
|
242
|
+
description: string
|
|
243
|
+
kind: ToolKind
|
|
244
|
+
input_schema: Attribute[]
|
|
245
|
+
binding?: ToolBinding | null
|
|
246
|
+
version: number
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface CreateToolRequest {
|
|
250
|
+
key: string
|
|
251
|
+
name: string
|
|
252
|
+
module_slug?: string
|
|
253
|
+
description?: string
|
|
254
|
+
kind: ToolKind
|
|
255
|
+
input_schema?: Attribute[]
|
|
256
|
+
/** Omit for `kind=client`. Sent as a structured object; the server decodes it by kind. */
|
|
257
|
+
binding?: ToolBinding | null
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** Fully replaces the tool's definition (the kind↔binding coupling makes a partial patch ambiguous). */
|
|
261
|
+
export interface UpdateToolRequest {
|
|
262
|
+
name: string
|
|
263
|
+
module_slug?: string
|
|
264
|
+
description?: string
|
|
265
|
+
kind: ToolKind
|
|
266
|
+
input_schema?: Attribute[]
|
|
267
|
+
binding?: ToolBinding | null
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface ListToolsOptions extends AgentResourceListOptions {
|
|
271
|
+
/** Filter by binding source. */
|
|
272
|
+
kind?: ToolKind
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// ---------------------------------------------------------------------------
|
|
276
|
+
// MCP Servers
|
|
277
|
+
// ---------------------------------------------------------------------------
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Auth config for reaching an MCP server. When `is_secret` is set, the bearer
|
|
281
|
+
* `token` is secret-managed and redacted to `''` on read. For `type: 'oauth'` the
|
|
282
|
+
* tokens are held server-side (never on this object); only the durable client
|
|
283
|
+
* config in `oauth` is persisted.
|
|
284
|
+
*/
|
|
285
|
+
export interface McpServerAuth {
|
|
286
|
+
type: 'none' | 'bearer' | 'oauth'
|
|
287
|
+
is_secret: boolean
|
|
288
|
+
token?: string
|
|
289
|
+
oauth?: McpServerOAuth
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Durable OAuth client config for an MCP server. Leave `client_id`/`client_secret`
|
|
294
|
+
* blank to attempt Dynamic Client Registration on connect; set them to use a
|
|
295
|
+
* pre-registered client when the authorization server has no registration endpoint.
|
|
296
|
+
* The endpoint fields are discovered automatically but may be set manually for an
|
|
297
|
+
* authorization server that doesn't publish RFC 8414 metadata.
|
|
298
|
+
*/
|
|
299
|
+
export interface McpServerOAuth {
|
|
300
|
+
client_id?: string
|
|
301
|
+
client_secret?: string
|
|
302
|
+
registration_mode?: 'dcr' | 'manual'
|
|
303
|
+
scopes?: string[]
|
|
304
|
+
issuer?: string
|
|
305
|
+
authorization_endpoint?: string
|
|
306
|
+
token_endpoint?: string
|
|
307
|
+
registration_endpoint?: string
|
|
308
|
+
resource?: string
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** One entry of an MCP server's tools/list (the `/tools` subresource). */
|
|
312
|
+
export interface McpToolSummary {
|
|
313
|
+
name: string
|
|
314
|
+
title?: string
|
|
315
|
+
description?: string
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export type McpConnectionState = 'disconnected' | 'connected' | 'expired' | 'error'
|
|
319
|
+
|
|
320
|
+
/** Derived OAuth connection state of an MCP server. */
|
|
321
|
+
export interface McpConnectionStatus {
|
|
322
|
+
key: string
|
|
323
|
+
state: McpConnectionState
|
|
324
|
+
last_connected_at?: string
|
|
325
|
+
error?: string
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/** Returned by {@link McpServerService.startOAuth}: open `authorization_url` in a popup. */
|
|
329
|
+
export interface StartMcpOAuthResponse {
|
|
330
|
+
authorization_url: string
|
|
331
|
+
state: string
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* A registered MCP server an org's agents can call — the source of `kind=mcp`
|
|
336
|
+
* tools (`McpBinding.server_key` points here). Keyed by (org_id, key).
|
|
337
|
+
*/
|
|
338
|
+
export interface McpServer extends AuditFields {
|
|
339
|
+
org_id: string
|
|
340
|
+
key: string
|
|
341
|
+
name: string
|
|
342
|
+
module_slug: string
|
|
343
|
+
url: string
|
|
344
|
+
auth: McpServerAuth
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export interface CreateMcpServerRequest {
|
|
348
|
+
key: string
|
|
349
|
+
name: string
|
|
350
|
+
module_slug?: string
|
|
351
|
+
url: string
|
|
352
|
+
auth: McpServerAuth
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export interface UpdateMcpServerRequest {
|
|
356
|
+
name?: string
|
|
357
|
+
module_slug?: string
|
|
358
|
+
url?: string
|
|
359
|
+
auth?: McpServerAuth
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export type ListMcpServersOptions = AgentResourceListOptions
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { ProteosClient } from '../client.js'
|
|
2
|
+
import { type MeService, MeServiceImpl } from './me.js'
|
|
3
|
+
import { type OrganizationService, OrganizationServiceImpl } from './organizations.js'
|
|
4
|
+
import { type RoleService, RoleServiceImpl } from './roles.js'
|
|
5
|
+
import { type UserService, UserServiceImpl } from './users.js'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Client for the Proteos Auth Service API.
|
|
9
|
+
* Provides access to all authentication and authorization services.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { ProteosClient, AccountClient } from 'proteos-sdk';
|
|
14
|
+
*
|
|
15
|
+
* const client = new ProteosClient({
|
|
16
|
+
* baseUrl: 'https://api.proteos.ai',
|
|
17
|
+
* token: 'your-api-token',
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* const auth = new AccountClient(client);
|
|
21
|
+
*
|
|
22
|
+
* // Use services
|
|
23
|
+
* const users = await auth.users.list().all();
|
|
24
|
+
* const role = await auth.roles.get('admin');
|
|
25
|
+
* const org = await auth.organizations.get('org-123');
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export class AccountClient {
|
|
29
|
+
/**
|
|
30
|
+
* Service for caller-scoped queries ("who am I", my organizations).
|
|
31
|
+
*/
|
|
32
|
+
readonly me: MeService
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Service for managing users and their role assignments.
|
|
36
|
+
*/
|
|
37
|
+
readonly users: UserService
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Service for managing roles and their entity permissions.
|
|
41
|
+
*/
|
|
42
|
+
readonly roles: RoleService
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Service for managing organizations.
|
|
46
|
+
*/
|
|
47
|
+
readonly organizations: OrganizationService
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Creates a new AccountClient instance.
|
|
51
|
+
*
|
|
52
|
+
* @param client - The base ProteosClient to use for API requests
|
|
53
|
+
*/
|
|
54
|
+
constructor(client: ProteosClient) {
|
|
55
|
+
this.me = new MeServiceImpl(client)
|
|
56
|
+
this.users = new UserServiceImpl(client)
|
|
57
|
+
this.roles = new RoleServiceImpl(client)
|
|
58
|
+
this.organizations = new OrganizationServiceImpl(client)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type { MeService } from './me.js'
|
|
63
|
+
export type { OrganizationService } from './organizations.js'
|
|
64
|
+
// Re-export platform entities (canonical mirror of the Go registry)
|
|
65
|
+
export type { PlatformEntity } from './platform-entities.js'
|
|
66
|
+
export { isPlatformEntity, PLATFORM_ENTITIES, PLATFORM_ENTITY_SLUGS } from './platform-entities.js'
|
|
67
|
+
export type { RoleService } from './roles.js'
|
|
68
|
+
// Re-export types
|
|
69
|
+
export type {
|
|
70
|
+
// Api key types
|
|
71
|
+
ApiKey,
|
|
72
|
+
AssignPermissionRequest,
|
|
73
|
+
AssignRoleRequest,
|
|
74
|
+
// Shared types
|
|
75
|
+
AuthListOptions,
|
|
76
|
+
CreateApiKeyRequest,
|
|
77
|
+
CreatedApiKey,
|
|
78
|
+
CreateOrganizationRequest,
|
|
79
|
+
CreateRoleRequest,
|
|
80
|
+
CreateUserRequest,
|
|
81
|
+
ListOrganizationsOptions,
|
|
82
|
+
ListRolePermissionsOptions,
|
|
83
|
+
ListRolesOptions,
|
|
84
|
+
ListUserRoleAssignmentsOptions,
|
|
85
|
+
ListUsersOptions,
|
|
86
|
+
// Organization types
|
|
87
|
+
Organization,
|
|
88
|
+
// Permission types
|
|
89
|
+
Permission,
|
|
90
|
+
// Role types
|
|
91
|
+
Role,
|
|
92
|
+
RoleEntityPermission,
|
|
93
|
+
UpdateOrganizationRequest,
|
|
94
|
+
UpdateRoleRequest,
|
|
95
|
+
UpdateUserRequest,
|
|
96
|
+
// User types
|
|
97
|
+
User,
|
|
98
|
+
// User role assignment types
|
|
99
|
+
UserRoleAssignment,
|
|
100
|
+
} from './types.js'
|
|
101
|
+
// Re-export Zod schemas
|
|
102
|
+
export {
|
|
103
|
+
ApiKeySchema,
|
|
104
|
+
OrganizationSchema,
|
|
105
|
+
RoleEntityPermissionSchema,
|
|
106
|
+
RoleSchema,
|
|
107
|
+
UserRoleAssignmentSchema,
|
|
108
|
+
UserSchema,
|
|
109
|
+
} from './types.js'
|
|
110
|
+
// Re-export service interfaces
|
|
111
|
+
export type { UserService } from './users.js'
|
package/src/auth/me.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ProteosClient } from '../client.js'
|
|
2
|
+
import type { Organization, User } from './types.js'
|
|
3
|
+
|
|
4
|
+
const ME_BASE_PATH = '/accounts/v1/me'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Service for caller-scoped queries — answers about the authenticated user
|
|
8
|
+
* (from the token), not an arbitrary user id.
|
|
9
|
+
*/
|
|
10
|
+
export interface MeService {
|
|
11
|
+
/**
|
|
12
|
+
* Gets the caller's own user record, resolved from the token's user id.
|
|
13
|
+
* The canonical "who am I" — use this instead of filtering `users.list`
|
|
14
|
+
* by email.
|
|
15
|
+
*
|
|
16
|
+
* @returns The calling user
|
|
17
|
+
*/
|
|
18
|
+
get(): Promise<User>
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Lists the organizations the caller can act in (all orgs for a platform
|
|
22
|
+
* admin; otherwise the orgs they're a member of). Powers the org-switcher.
|
|
23
|
+
*
|
|
24
|
+
* @returns The caller's organizations
|
|
25
|
+
*/
|
|
26
|
+
organizations(): Promise<Organization[]>
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Implementation of MeService.
|
|
31
|
+
*/
|
|
32
|
+
export class MeServiceImpl implements MeService {
|
|
33
|
+
constructor(private readonly client: ProteosClient) {}
|
|
34
|
+
|
|
35
|
+
async get(): Promise<User> {
|
|
36
|
+
return this.client.request<User>('GET', ME_BASE_PATH)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async organizations(): Promise<Organization[]> {
|
|
40
|
+
const response = await this.client.request<{ data: Organization[] }>(
|
|
41
|
+
'GET',
|
|
42
|
+
`${ME_BASE_PATH}/organizations`,
|
|
43
|
+
)
|
|
44
|
+
return response.data
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
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
|
+
CreateOrganizationRequest,
|
|
6
|
+
ListOrganizationsOptions,
|
|
7
|
+
Organization,
|
|
8
|
+
UpdateOrganizationRequest,
|
|
9
|
+
} from './types.js'
|
|
10
|
+
|
|
11
|
+
const ORGANIZATIONS_BASE_PATH = '/accounts/v1/organizations'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Service for managing organizations.
|
|
15
|
+
* Handles organization CRUD operations.
|
|
16
|
+
*/
|
|
17
|
+
export interface OrganizationService {
|
|
18
|
+
/**
|
|
19
|
+
* Lists organizations with optional filtering.
|
|
20
|
+
* Returns an async iterator that automatically handles pagination.
|
|
21
|
+
*
|
|
22
|
+
* @param options - Filter and pagination options
|
|
23
|
+
* @returns Async iterator over organizations
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* // Iterate over all organizations
|
|
28
|
+
* for await (const org of service.list()) {
|
|
29
|
+
* console.log(org.name);
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* // With filtering
|
|
33
|
+
* for await (const org of service.list({ name: 'Acme Corp' })) {
|
|
34
|
+
* console.log(org.id);
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
list(options?: ListOrganizationsOptions): PageIterator<Organization, ListOrganizationsOptions>
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Fetches a single page of organizations.
|
|
42
|
+
*
|
|
43
|
+
* @param options - Filter and pagination options (including `page`)
|
|
44
|
+
* @returns A single page of organizations with pagination metadata
|
|
45
|
+
*/
|
|
46
|
+
listPage(options?: ListOrganizationsOptions): Promise<ListResult<Organization>>
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Gets a single organization by ID.
|
|
50
|
+
*
|
|
51
|
+
* @param id - Organization ID
|
|
52
|
+
* @returns The organization
|
|
53
|
+
* @throws {ProteosError} If organization not found (404)
|
|
54
|
+
*/
|
|
55
|
+
get(id: string): Promise<Organization>
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Creates a new organization.
|
|
59
|
+
*
|
|
60
|
+
* @param request - Organization creation request
|
|
61
|
+
* @returns The created organization
|
|
62
|
+
* @throws {ProteosError} If validation fails (400) or conflict (409)
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* const org = await service.create({
|
|
67
|
+
* name: 'Acme Corporation',
|
|
68
|
+
* description: 'Main organization',
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
create(request: CreateOrganizationRequest): Promise<Organization>
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Updates an existing organization.
|
|
76
|
+
*
|
|
77
|
+
* @param id - Organization ID
|
|
78
|
+
* @param request - Fields to update
|
|
79
|
+
* @returns The updated organization
|
|
80
|
+
* @throws {ProteosError} If organization not found (404) or validation fails (400)
|
|
81
|
+
*/
|
|
82
|
+
update(id: string, request: UpdateOrganizationRequest): Promise<Organization>
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Deletes an organization.
|
|
86
|
+
*
|
|
87
|
+
* @param id - Organization ID
|
|
88
|
+
* @throws {ProteosError} If organization not found (404)
|
|
89
|
+
*/
|
|
90
|
+
delete(id: string): Promise<void>
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Implementation of OrganizationService.
|
|
95
|
+
*/
|
|
96
|
+
export class OrganizationServiceImpl implements OrganizationService {
|
|
97
|
+
constructor(private readonly client: ProteosClient) {}
|
|
98
|
+
|
|
99
|
+
list(
|
|
100
|
+
options: ListOrganizationsOptions = {},
|
|
101
|
+
): PageIterator<Organization, ListOrganizationsOptions> {
|
|
102
|
+
return new PageIterator((opts) => this.listPage(opts), options)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async listPage(options: ListOrganizationsOptions = {}): Promise<ListResult<Organization>> {
|
|
106
|
+
return this.client.requestWithQuery<ListResult<Organization>>(
|
|
107
|
+
'GET',
|
|
108
|
+
ORGANIZATIONS_BASE_PATH,
|
|
109
|
+
options,
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async get(id: string): Promise<Organization> {
|
|
114
|
+
return this.client.request<Organization>('GET', `${ORGANIZATIONS_BASE_PATH}/${id}`)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async create(request: CreateOrganizationRequest): Promise<Organization> {
|
|
118
|
+
return this.client.request<Organization>('POST', ORGANIZATIONS_BASE_PATH, request)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async update(id: string, request: UpdateOrganizationRequest): Promise<Organization> {
|
|
122
|
+
return this.client.request<Organization>('PATCH', `${ORGANIZATIONS_BASE_PATH}/${id}`, request)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async delete(id: string): Promise<void> {
|
|
126
|
+
await this.client.request<void>('DELETE', `${ORGANIZATIONS_BASE_PATH}/${id}`)
|
|
127
|
+
}
|
|
128
|
+
}
|