@stigmer/sdk 3.12.5 → 3.12.7
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/__tests__/update-input-roundtrip.test.d.ts +2 -0
- package/__tests__/update-input-roundtrip.test.d.ts.map +1 -0
- package/__tests__/update-input-roundtrip.test.js +795 -0
- package/__tests__/update-input-roundtrip.test.js.map +1 -0
- package/__tests__/update-input.test.js +22 -3
- package/__tests__/update-input.test.js.map +1 -1
- package/execution/__tests__/transcript.test.d.ts +2 -0
- package/execution/__tests__/transcript.test.d.ts.map +1 -0
- package/execution/__tests__/transcript.test.js +527 -0
- package/execution/__tests__/transcript.test.js.map +1 -0
- package/execution/conversation-rules.d.ts +64 -0
- package/execution/conversation-rules.d.ts.map +1 -0
- package/execution/conversation-rules.js +113 -0
- package/execution/conversation-rules.js.map +1 -0
- package/execution/transcript.d.ts +171 -0
- package/execution/transcript.d.ts.map +1 -0
- package/execution/transcript.js +484 -0
- package/execution/transcript.js.map +1 -0
- package/gen/agent.d.ts +21 -0
- package/gen/agent.d.ts.map +1 -1
- package/gen/agent.js +73 -1
- package/gen/agent.js.map +1 -1
- package/gen/agentchannel.d.ts +23 -1
- package/gen/agentchannel.d.ts.map +1 -1
- package/gen/agentchannel.js +55 -1
- package/gen/agentchannel.js.map +1 -1
- package/gen/agentexecution.d.ts +34 -1
- package/gen/agentexecution.d.ts.map +1 -1
- package/gen/agentexecution.js +176 -2
- package/gen/agentexecution.js.map +1 -1
- package/gen/agentinstance.d.ts +21 -0
- package/gen/agentinstance.d.ts.map +1 -1
- package/gen/agentinstance.js +32 -1
- package/gen/agentinstance.js.map +1 -1
- package/gen/agentshare.d.ts +23 -1
- package/gen/agentshare.d.ts.map +1 -1
- package/gen/agentshare.js +53 -1
- package/gen/agentshare.js.map +1 -1
- package/gen/apikey.d.ts +21 -0
- package/gen/apikey.d.ts.map +1 -1
- package/gen/apikey.js +33 -1
- package/gen/apikey.js.map +1 -1
- package/gen/artifact.d.ts +8 -0
- package/gen/artifact.d.ts.map +1 -1
- package/gen/artifact.js +1 -0
- package/gen/artifact.js.map +1 -1
- package/gen/channelapp.d.ts +21 -0
- package/gen/channelapp.d.ts.map +1 -1
- package/gen/channelapp.js +45 -0
- package/gen/channelapp.js.map +1 -1
- package/gen/client.d.ts +5 -1
- package/gen/client.d.ts.map +1 -1
- package/gen/client.js +4 -0
- package/gen/client.js.map +1 -1
- package/gen/environment.d.ts +21 -0
- package/gen/environment.d.ts.map +1 -1
- package/gen/environment.js +31 -1
- package/gen/environment.js.map +1 -1
- package/gen/executioncontext.d.ts +8 -0
- package/gen/executioncontext.d.ts.map +1 -1
- package/gen/executioncontext.js +1 -0
- package/gen/executioncontext.js.map +1 -1
- package/gen/iampolicy.d.ts +8 -0
- package/gen/iampolicy.d.ts.map +1 -1
- package/gen/iampolicy.js +1 -0
- package/gen/iampolicy.js.map +1 -1
- package/gen/identityaccount.d.ts +22 -0
- package/gen/identityaccount.d.ts.map +1 -1
- package/gen/identityaccount.js +48 -1
- package/gen/identityaccount.js.map +1 -1
- package/gen/identityprovider.d.ts +21 -0
- package/gen/identityprovider.d.ts.map +1 -1
- package/gen/identityprovider.js +40 -0
- package/gen/identityprovider.js.map +1 -1
- package/gen/invitation.d.ts +8 -0
- package/gen/invitation.d.ts.map +1 -1
- package/gen/invitation.js +1 -0
- package/gen/invitation.js.map +1 -1
- package/gen/mcpserver.d.ts +21 -0
- package/gen/mcpserver.d.ts.map +1 -1
- package/gen/mcpserver.js +79 -1
- package/gen/mcpserver.js.map +1 -1
- package/gen/memory.d.ts +58 -0
- package/gen/memory.d.ts.map +1 -0
- package/gen/memory.js +143 -0
- package/gen/memory.js.map +1 -0
- package/gen/oauthapp.d.ts +21 -0
- package/gen/oauthapp.d.ts.map +1 -1
- package/gen/oauthapp.js +39 -0
- package/gen/oauthapp.js.map +1 -1
- package/gen/organization.d.ts +22 -0
- package/gen/organization.d.ts.map +1 -1
- package/gen/organization.js +43 -1
- package/gen/organization.js.map +1 -1
- package/gen/platformclient.d.ts +21 -0
- package/gen/platformclient.d.ts.map +1 -1
- package/gen/platformclient.js +40 -1
- package/gen/platformclient.js.map +1 -1
- package/gen/project.d.ts +21 -0
- package/gen/project.d.ts.map +1 -1
- package/gen/project.js +32 -1
- package/gen/project.js.map +1 -1
- package/gen/proto-utils.d.ts +36 -0
- package/gen/proto-utils.d.ts.map +1 -1
- package/gen/proto-utils.js +58 -0
- package/gen/proto-utils.js.map +1 -1
- package/gen/schedule.d.ts +23 -1
- package/gen/schedule.d.ts.map +1 -1
- package/gen/schedule.js +79 -1
- package/gen/schedule.js.map +1 -1
- package/gen/session.d.ts +21 -0
- package/gen/session.d.ts.map +1 -1
- package/gen/session.js +80 -1
- package/gen/session.js.map +1 -1
- package/gen/skill.d.ts +8 -0
- package/gen/skill.d.ts.map +1 -1
- package/gen/skill.js +1 -0
- package/gen/skill.js.map +1 -1
- package/gen/workflow.d.ts +21 -0
- package/gen/workflow.d.ts.map +1 -1
- package/gen/workflow.js +79 -0
- package/gen/workflow.js.map +1 -1
- package/gen/workflowexecution.d.ts +21 -0
- package/gen/workflowexecution.d.ts.map +1 -1
- package/gen/workflowexecution.js +36 -1
- package/gen/workflowexecution.js.map +1 -1
- package/gen/workflowinstance.d.ts +21 -0
- package/gen/workflowinstance.d.ts.map +1 -1
- package/gen/workflowinstance.js +33 -1
- package/gen/workflowinstance.js.map +1 -1
- package/index.d.ts +23 -21
- package/index.d.ts.map +1 -1
- package/index.js +27 -23
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/update-input-roundtrip.test.ts +1035 -0
- package/src/__tests__/update-input.test.ts +34 -3
- package/src/execution/__tests__/transcript.golden.md +100 -0
- package/src/execution/__tests__/transcript.test.ts +627 -0
- package/src/execution/conversation-rules.ts +119 -0
- package/src/execution/transcript.ts +735 -0
- package/src/gen/agent.ts +89 -3
- package/src/gen/agentchannel.ts +72 -4
- package/src/gen/agentexecution.ts +216 -6
- package/src/gen/agentinstance.ts +41 -1
- package/src/gen/agentshare.ts +68 -4
- package/src/gen/apikey.ts +42 -1
- package/src/gen/artifact.ts +9 -0
- package/src/gen/channelapp.ts +57 -1
- package/src/gen/client.ts +6 -1
- package/src/gen/environment.ts +40 -1
- package/src/gen/executioncontext.ts +9 -0
- package/src/gen/iampolicy.ts +9 -0
- package/src/gen/identityaccount.ts +60 -2
- package/src/gen/identityprovider.ts +49 -0
- package/src/gen/invitation.ts +9 -0
- package/src/gen/mcpserver.ts +95 -3
- package/src/gen/memory.ts +164 -0
- package/src/gen/oauthapp.ts +48 -0
- package/src/gen/organization.ts +55 -2
- package/src/gen/platformclient.ts +49 -1
- package/src/gen/project.ts +41 -1
- package/src/gen/proto-utils.ts +64 -0
- package/src/gen/schedule.ts +98 -4
- package/src/gen/session.ts +97 -3
- package/src/gen/skill.ts +9 -0
- package/src/gen/workflow.ts +96 -2
- package/src/gen/workflowexecution.ts +45 -1
- package/src/gen/workflowinstance.ts +42 -1
- package/src/index.ts +52 -9
- package/src/update-input.ts +0 -168
- package/update-input.d.ts +0 -24
- package/update-input.d.ts.map +0 -1
- package/update-input.js +0 -126
- package/update-input.js.map +0 -1
package/src/gen/mcpserver.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// Code generated by stigmer-codegen. DO NOT EDIT.
|
|
2
2
|
|
|
3
3
|
import { wrapError } from "./errors.js";
|
|
4
|
-
import { stripUndefined } from "./proto-utils.js";
|
|
4
|
+
import { stripUndefined, toResourceRefInput } from "./proto-utils.js";
|
|
5
5
|
import { type DeleteResourceInput, type ListParams, type ListResult, type ResourceRef } from "./types.js";
|
|
6
6
|
import { create } from "@bufbuild/protobuf";
|
|
7
7
|
import { createClient, type Client, type Transport } from "@connectrpc/connect";
|
|
8
|
-
import { EnvVarDeclarationSchema } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/spec_pb";
|
|
8
|
+
import { EnvVarDeclarationSchema, type EnvVarDeclaration } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/spec_pb";
|
|
9
9
|
import { McpServerSchema, type McpServer } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/api_pb";
|
|
10
10
|
import { McpServerCommandController } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/command_pb";
|
|
11
11
|
import { ConnectInputSchema, InitiateOAuthConnectInputSchema, InitiateOAuthConnectOutputSchema, CompleteOAuthConnectInputSchema, CompleteOAuthConnectOutputSchema, DisconnectOAuthInputSchema, DisconnectOAuthOutputSchema, SetOrgOAuthAppInputSchema, SetOrgOAuthAppOutputSchema, DeleteOrgOAuthAppInputSchema, DeleteOrgOAuthAppOutputSchema, GetOAuthGrantStatusInputSchema, GetOAuthGrantStatusOutputSchema, GetOrgOAuthAppInputSchema, GetOrgOAuthAppOutputSchema, type ConnectInput, type InitiateOAuthConnectInput, type InitiateOAuthConnectOutput, type CompleteOAuthConnectInput, type CompleteOAuthConnectOutput, type DisconnectOAuthInput, type DisconnectOAuthOutput, type SetOrgOAuthAppInput, type SetOrgOAuthAppOutput, type DeleteOrgOAuthAppInput, type DeleteOrgOAuthAppOutput, type GetOAuthGrantStatusInput, type GetOAuthGrantStatusOutput, type GetOrgOAuthAppInput, type GetOrgOAuthAppOutput } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/io_pb";
|
|
12
12
|
import { McpServerQueryController } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/query_pb";
|
|
13
|
-
import { McpServerSpecSchema, StdioServerConfigSchema, HttpServerConfigSchema, ToolApprovalPolicySchema, McpServerAuthSchema } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/spec_pb";
|
|
13
|
+
import { McpServerSpecSchema, StdioServerConfigSchema, HttpServerConfigSchema, ToolApprovalPolicySchema, McpServerAuthSchema, type StdioServerConfig, type HttpServerConfig, type ToolApprovalPolicy, type McpServerAuth } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/spec_pb";
|
|
14
14
|
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
15
15
|
import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
|
|
16
16
|
import { ApiResourceIdSchema, ApiResourceReferenceSchema, ApiResourceDeleteInputSchema, type UpdateVisibilityInput } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
|
|
@@ -152,6 +152,14 @@ export class McpServerClient {
|
|
|
152
152
|
|
|
153
153
|
/** Input for creating/updating a McpServer. */
|
|
154
154
|
export interface McpServerInput {
|
|
155
|
+
/**
|
|
156
|
+
* The resource's `metadata.id`, for exact update addressing when set
|
|
157
|
+
* from a loaded resource. Required for updates to platform-scoped
|
|
158
|
+
* (org-less) kinds, where the org+slug fallback cannot match. On
|
|
159
|
+
* create, the cloud server stamps its own id regardless; the OSS
|
|
160
|
+
* server honors a caller-supplied id (existing apply semantics).
|
|
161
|
+
*/
|
|
162
|
+
id?: string;
|
|
155
163
|
name: string;
|
|
156
164
|
slug?: string;
|
|
157
165
|
org: string;
|
|
@@ -280,6 +288,7 @@ export function buildMcpServerProto(input: McpServerInput): McpServer {
|
|
|
280
288
|
apiVersion: "agentic.stigmer.ai/v1",
|
|
281
289
|
kind: "McpServer",
|
|
282
290
|
metadata: Object.assign(create(ApiResourceMetadataSchema), {
|
|
291
|
+
...(input.id && { id: input.id }),
|
|
283
292
|
name: input.name,
|
|
284
293
|
org: input.org,
|
|
285
294
|
...(input.slug && { slug: input.slug }),
|
|
@@ -289,3 +298,86 @@ export function buildMcpServerProto(input: McpServerInput): McpServer {
|
|
|
289
298
|
spec,
|
|
290
299
|
}) as McpServer;
|
|
291
300
|
}
|
|
301
|
+
|
|
302
|
+
function toStdioServerConfigInput(msg: StdioServerConfig): StdioServerConfigInput {
|
|
303
|
+
return {
|
|
304
|
+
command: msg.command ?? "",
|
|
305
|
+
args: msg.args?.length ? [...msg.args] : undefined,
|
|
306
|
+
workingDir: msg.workingDir || undefined,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function toHttpServerConfigInput(msg: HttpServerConfig): HttpServerConfigInput {
|
|
311
|
+
return {
|
|
312
|
+
url: msg.url ?? "",
|
|
313
|
+
headers: Object.keys(msg.headers ?? {}).length > 0 ? { ...msg.headers } : undefined,
|
|
314
|
+
queryParams: Object.keys(msg.queryParams ?? {}).length > 0 ? { ...msg.queryParams } : undefined,
|
|
315
|
+
timeoutSeconds: msg.timeoutSeconds || undefined,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function toEnvVarDeclarationInput(msg: EnvVarDeclaration): EnvVarDeclarationInput {
|
|
320
|
+
return {
|
|
321
|
+
isSecret: msg.isSecret || undefined,
|
|
322
|
+
description: msg.description || undefined,
|
|
323
|
+
optional: msg.optional || undefined,
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function toToolApprovalPolicyInput(msg: ToolApprovalPolicy): ToolApprovalPolicyInput {
|
|
328
|
+
return {
|
|
329
|
+
toolName: msg.toolName || undefined,
|
|
330
|
+
message: msg.message || undefined,
|
|
331
|
+
fromDestructiveHint: msg.fromDestructiveHint || undefined,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function toMcpServerAuthInput(msg: McpServerAuth): McpServerAuthInput {
|
|
336
|
+
return {
|
|
337
|
+
oauthAppRef: toResourceRefInput(msg.oauthAppRef),
|
|
338
|
+
targetEnvVar: msg.targetEnvVar || undefined,
|
|
339
|
+
tokenLifetimeHint: msg.tokenLifetimeHint || undefined,
|
|
340
|
+
scopeHints: msg.scopeHints?.length ? [...msg.scopeHints] : undefined,
|
|
341
|
+
discoveryUrl: msg.discoveryUrl || undefined,
|
|
342
|
+
oauthOnly: msg.oauthOnly || undefined,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Maps a fetched {@link McpServer} to a complete {@link McpServerInput} for `update()`.
|
|
348
|
+
*
|
|
349
|
+
* The update RPC replaces the ENTIRE spec — spread this mapper's output
|
|
350
|
+
* and override only the fields you edit (spread nested objects the same
|
|
351
|
+
* way):
|
|
352
|
+
*
|
|
353
|
+
* await client.update({ ...toMcpServerUpdateInput(res), description: next });
|
|
354
|
+
*
|
|
355
|
+
* Proto3 defaults normalize to `undefined`; resource references keep
|
|
356
|
+
* `version` (pinned refs) and `kind`.
|
|
357
|
+
*/
|
|
358
|
+
export function toMcpServerUpdateInput(resource: McpServer): McpServerInput {
|
|
359
|
+
const meta = resource.metadata;
|
|
360
|
+
const spec = resource.spec ?? create(McpServerSpecSchema);
|
|
361
|
+
return {
|
|
362
|
+
// Exact update addressing (id-first in the update pipeline) — for
|
|
363
|
+
// platform-scoped (org-less) kinds the org+slug fallback cannot
|
|
364
|
+
// match, so the id is the ONLY working address.
|
|
365
|
+
id: meta?.id || undefined,
|
|
366
|
+
name: meta?.name ?? "",
|
|
367
|
+
slug: meta?.slug || undefined,
|
|
368
|
+
org: meta?.org ?? "",
|
|
369
|
+
labels: meta?.labels && Object.keys(meta.labels).length > 0 ? { ...meta.labels } : undefined,
|
|
370
|
+
visibility: meta?.visibility || undefined,
|
|
371
|
+
description: spec.description || undefined,
|
|
372
|
+
iconUrl: spec.iconUrl || undefined,
|
|
373
|
+
tags: spec.tags?.length ? [...spec.tags] : undefined,
|
|
374
|
+
stdio: spec.serverType?.case === "stdio" ? toStdioServerConfigInput(spec.serverType.value) : undefined,
|
|
375
|
+
http: spec.serverType?.case === "http" ? toHttpServerConfigInput(spec.serverType.value) : undefined,
|
|
376
|
+
defaultEnabledTools: spec.defaultEnabledTools?.length ? [...spec.defaultEnabledTools] : undefined,
|
|
377
|
+
env: Object.keys(spec.env ?? {}).length > 0 ? Object.fromEntries(Object.entries(spec.env).map(([k, v]) => [k, toEnvVarDeclarationInput(v)])) : undefined,
|
|
378
|
+
pinnedToolApprovals: spec.pinnedToolApprovals?.length ? spec.pinnedToolApprovals.map(toToolApprovalPolicyInput) : undefined,
|
|
379
|
+
repositoryUrl: spec.repositoryUrl || undefined,
|
|
380
|
+
githubStars: spec.githubStars || undefined,
|
|
381
|
+
auth: spec.auth ? toMcpServerAuthInput(spec.auth) : undefined,
|
|
382
|
+
};
|
|
383
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// Code generated by stigmer-codegen. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
import { wrapError } from "./errors.js";
|
|
4
|
+
import { stripUndefined } from "./proto-utils.js";
|
|
5
|
+
import { create } from "@bufbuild/protobuf";
|
|
6
|
+
import { createClient, type Client, type Transport } from "@connectrpc/connect";
|
|
7
|
+
import { MemorySchema, type Memory } from "@stigmer/protos/ai/stigmer/agentic/memory/v1/api_pb";
|
|
8
|
+
import { MemoryCommandController } from "@stigmer/protos/ai/stigmer/agentic/memory/v1/command_pb";
|
|
9
|
+
import { MemoryIdSchema, ListMemoriesRequestSchema, MemoryListSchema, type ListMemoriesRequest, type MemoryList } from "@stigmer/protos/ai/stigmer/agentic/memory/v1/io_pb";
|
|
10
|
+
import { MemoryQueryController } from "@stigmer/protos/ai/stigmer/agentic/memory/v1/query_pb";
|
|
11
|
+
import { MemorySpecSchema, MemoryProvenanceSchema, type MemoryProvenance } from "@stigmer/protos/ai/stigmer/agentic/memory/v1/spec_pb";
|
|
12
|
+
import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
|
|
13
|
+
import { ApiResourceMetadataSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
|
|
14
|
+
|
|
15
|
+
/** Provides operations on memory resources. */
|
|
16
|
+
export class MemoryClient {
|
|
17
|
+
private readonly command: Client<typeof MemoryCommandController>;
|
|
18
|
+
private readonly query: Client<typeof MemoryQueryController>;
|
|
19
|
+
|
|
20
|
+
constructor(transport: Transport) {
|
|
21
|
+
this.command = createClient(MemoryCommandController, transport);
|
|
22
|
+
this.query = createClient(MemoryQueryController, transport);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async create(input: MemoryInput): Promise<Memory> {
|
|
26
|
+
try {
|
|
27
|
+
return await this.command.create(buildMemoryProto(input));
|
|
28
|
+
} catch (e) { throw wrapError(e); }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async update(input: MemoryInput): Promise<Memory> {
|
|
32
|
+
try {
|
|
33
|
+
return await this.command.update(buildMemoryProto(input));
|
|
34
|
+
} catch (e) { throw wrapError(e); }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async delete(id: string): Promise<Memory> {
|
|
38
|
+
try {
|
|
39
|
+
return await this.command.delete(create(MemoryIdSchema, { value: id }));
|
|
40
|
+
} catch (e) { throw wrapError(e); }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async confirm(id: string): Promise<Memory> {
|
|
44
|
+
try {
|
|
45
|
+
return await this.command.confirm(create(MemoryIdSchema, { value: id }));
|
|
46
|
+
} catch (e) { throw wrapError(e); }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async reject(id: string): Promise<Memory> {
|
|
50
|
+
try {
|
|
51
|
+
return await this.command.reject(create(MemoryIdSchema, { value: id }));
|
|
52
|
+
} catch (e) { throw wrapError(e); }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async get(id: string): Promise<Memory> {
|
|
56
|
+
try {
|
|
57
|
+
return await this.query.get(create(MemoryIdSchema, { value: id }));
|
|
58
|
+
} catch (e) { throw wrapError(e); }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async list(input: ListMemoriesRequest): Promise<MemoryList> {
|
|
62
|
+
try {
|
|
63
|
+
return await this.query.list(input);
|
|
64
|
+
} catch (e) { throw wrapError(e); }
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Input for creating/updating a Memory. */
|
|
69
|
+
export interface MemoryInput {
|
|
70
|
+
/**
|
|
71
|
+
* The resource's `metadata.id`, for exact update addressing when set
|
|
72
|
+
* from a loaded resource. Required for updates to platform-scoped
|
|
73
|
+
* (org-less) kinds, where the org+slug fallback cannot match. On
|
|
74
|
+
* create, the cloud server stamps its own id regardless; the OSS
|
|
75
|
+
* server honors a caller-supplied id (existing apply semantics).
|
|
76
|
+
*/
|
|
77
|
+
id?: string;
|
|
78
|
+
name: string;
|
|
79
|
+
slug?: string;
|
|
80
|
+
org: string;
|
|
81
|
+
labels?: Record<string, string>;
|
|
82
|
+
visibility?: ApiResourceVisibility;
|
|
83
|
+
content?: string;
|
|
84
|
+
subjectIdentityAccountId?: string;
|
|
85
|
+
provenance?: MemoryProvenanceInput;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** SDK input type for MemoryProvenance. */
|
|
89
|
+
export interface MemoryProvenanceInput {
|
|
90
|
+
agentId?: string;
|
|
91
|
+
sessionId?: string;
|
|
92
|
+
agentExecutionId?: string;
|
|
93
|
+
toolCallId?: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function buildMemoryProvenanceProto(input: MemoryProvenanceInput) {
|
|
97
|
+
return Object.assign(create(MemoryProvenanceSchema), stripUndefined({
|
|
98
|
+
agentId: input.agentId,
|
|
99
|
+
sessionId: input.sessionId,
|
|
100
|
+
agentExecutionId: input.agentExecutionId,
|
|
101
|
+
toolCallId: input.toolCallId,
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function buildMemoryProto(input: MemoryInput): Memory {
|
|
106
|
+
const provenance = input.provenance ? buildMemoryProvenanceProto(input.provenance) : undefined;
|
|
107
|
+
return Object.assign(create(MemorySchema), {
|
|
108
|
+
apiVersion: "agentic.stigmer.ai/v1",
|
|
109
|
+
kind: "Memory",
|
|
110
|
+
metadata: Object.assign(create(ApiResourceMetadataSchema), {
|
|
111
|
+
...(input.id && { id: input.id }),
|
|
112
|
+
name: input.name,
|
|
113
|
+
org: input.org,
|
|
114
|
+
...(input.slug && { slug: input.slug }),
|
|
115
|
+
...(input.labels && { labels: input.labels }),
|
|
116
|
+
...(input.visibility && { visibility: input.visibility }),
|
|
117
|
+
}),
|
|
118
|
+
spec: Object.assign(create(MemorySpecSchema), stripUndefined({
|
|
119
|
+
content: input.content,
|
|
120
|
+
subjectIdentityAccountId: input.subjectIdentityAccountId,
|
|
121
|
+
provenance,
|
|
122
|
+
})),
|
|
123
|
+
}) as Memory;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function toMemoryProvenanceInput(msg: MemoryProvenance): MemoryProvenanceInput {
|
|
127
|
+
return {
|
|
128
|
+
agentId: msg.agentId || undefined,
|
|
129
|
+
sessionId: msg.sessionId || undefined,
|
|
130
|
+
agentExecutionId: msg.agentExecutionId || undefined,
|
|
131
|
+
toolCallId: msg.toolCallId || undefined,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Maps a fetched {@link Memory} to a complete {@link MemoryInput} for `update()`.
|
|
137
|
+
*
|
|
138
|
+
* The update RPC replaces the ENTIRE spec — spread this mapper's output
|
|
139
|
+
* and override only the fields you edit (spread nested objects the same
|
|
140
|
+
* way):
|
|
141
|
+
*
|
|
142
|
+
* await client.update({ ...toMemoryUpdateInput(res), description: next });
|
|
143
|
+
*
|
|
144
|
+
* Proto3 defaults normalize to `undefined`; resource references keep
|
|
145
|
+
* `version` (pinned refs) and `kind`.
|
|
146
|
+
*/
|
|
147
|
+
export function toMemoryUpdateInput(resource: Memory): MemoryInput {
|
|
148
|
+
const meta = resource.metadata;
|
|
149
|
+
const spec = resource.spec ?? create(MemorySpecSchema);
|
|
150
|
+
return {
|
|
151
|
+
// Exact update addressing (id-first in the update pipeline) — for
|
|
152
|
+
// platform-scoped (org-less) kinds the org+slug fallback cannot
|
|
153
|
+
// match, so the id is the ONLY working address.
|
|
154
|
+
id: meta?.id || undefined,
|
|
155
|
+
name: meta?.name ?? "",
|
|
156
|
+
slug: meta?.slug || undefined,
|
|
157
|
+
org: meta?.org ?? "",
|
|
158
|
+
labels: meta?.labels && Object.keys(meta.labels).length > 0 ? { ...meta.labels } : undefined,
|
|
159
|
+
visibility: meta?.visibility || undefined,
|
|
160
|
+
content: spec.content || undefined,
|
|
161
|
+
subjectIdentityAccountId: spec.subjectIdentityAccountId || undefined,
|
|
162
|
+
provenance: spec.provenance ? toMemoryProvenanceInput(spec.provenance) : undefined,
|
|
163
|
+
};
|
|
164
|
+
}
|
package/src/gen/oauthapp.ts
CHANGED
|
@@ -74,6 +74,14 @@ export class OAuthAppClient {
|
|
|
74
74
|
|
|
75
75
|
/** Input for creating/updating a OAuthApp. */
|
|
76
76
|
export interface OAuthAppInput {
|
|
77
|
+
/**
|
|
78
|
+
* The resource's `metadata.id`, for exact update addressing when set
|
|
79
|
+
* from a loaded resource. Required for updates to platform-scoped
|
|
80
|
+
* (org-less) kinds, where the org+slug fallback cannot match. On
|
|
81
|
+
* create, the cloud server stamps its own id regardless; the OSS
|
|
82
|
+
* server honors a caller-supplied id (existing apply semantics).
|
|
83
|
+
*/
|
|
84
|
+
id?: string;
|
|
77
85
|
name: string;
|
|
78
86
|
slug?: string;
|
|
79
87
|
org: string;
|
|
@@ -97,6 +105,7 @@ export function buildOAuthAppProto(input: OAuthAppInput): OAuthApp {
|
|
|
97
105
|
apiVersion: "iam.stigmer.ai/v1",
|
|
98
106
|
kind: "OAuthApp",
|
|
99
107
|
metadata: Object.assign(create(ApiResourceMetadataSchema), {
|
|
108
|
+
...(input.id && { id: input.id }),
|
|
100
109
|
name: input.name,
|
|
101
110
|
org: input.org,
|
|
102
111
|
...(input.slug && { slug: input.slug }),
|
|
@@ -118,3 +127,42 @@ export function buildOAuthAppProto(input: OAuthAppInput): OAuthApp {
|
|
|
118
127
|
})),
|
|
119
128
|
}) as OAuthApp;
|
|
120
129
|
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Maps a fetched {@link OAuthApp} to a complete {@link OAuthAppInput} for `update()`.
|
|
133
|
+
*
|
|
134
|
+
* The update RPC replaces the ENTIRE spec — spread this mapper's output
|
|
135
|
+
* and override only the fields you edit (spread nested objects the same
|
|
136
|
+
* way):
|
|
137
|
+
*
|
|
138
|
+
* await client.update({ ...toOAuthAppUpdateInput(res), description: next });
|
|
139
|
+
*
|
|
140
|
+
* Proto3 defaults normalize to `undefined`; resource references keep
|
|
141
|
+
* `version` (pinned refs) and `kind`.
|
|
142
|
+
*/
|
|
143
|
+
export function toOAuthAppUpdateInput(resource: OAuthApp): OAuthAppInput {
|
|
144
|
+
const meta = resource.metadata;
|
|
145
|
+
const spec = resource.spec ?? create(OAuthAppSpecSchema);
|
|
146
|
+
return {
|
|
147
|
+
// Exact update addressing (id-first in the update pipeline) — for
|
|
148
|
+
// platform-scoped (org-less) kinds the org+slug fallback cannot
|
|
149
|
+
// match, so the id is the ONLY working address.
|
|
150
|
+
id: meta?.id || undefined,
|
|
151
|
+
name: meta?.name ?? "",
|
|
152
|
+
slug: meta?.slug || undefined,
|
|
153
|
+
org: meta?.org ?? "",
|
|
154
|
+
labels: meta?.labels && Object.keys(meta.labels).length > 0 ? { ...meta.labels } : undefined,
|
|
155
|
+
visibility: meta?.visibility || undefined,
|
|
156
|
+
provider: spec.provider || undefined,
|
|
157
|
+
clientId: spec.clientId || undefined,
|
|
158
|
+
clientSecret: spec.clientSecret || undefined,
|
|
159
|
+
authorizationUrl: spec.authorizationUrl || undefined,
|
|
160
|
+
tokenUrl: spec.tokenUrl || undefined,
|
|
161
|
+
scopes: spec.scopes?.length ? [...spec.scopes] : undefined,
|
|
162
|
+
userinfoUrl: spec.userinfoUrl || undefined,
|
|
163
|
+
scopeParameterName: spec.scopeParameterName || undefined,
|
|
164
|
+
vendorApprovalStatus: spec.vendorApprovalStatus || undefined,
|
|
165
|
+
vendorApprovalDocsUrl: spec.vendorApprovalDocsUrl || undefined,
|
|
166
|
+
tokenEndpointAuthMethod: spec.tokenEndpointAuthMethod || undefined,
|
|
167
|
+
};
|
|
168
|
+
}
|
package/src/gen/organization.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Code generated by stigmer-codegen. DO NOT EDIT.
|
|
2
2
|
|
|
3
3
|
import { wrapError } from "./errors.js";
|
|
4
|
-
import { stripUndefined } from "./proto-utils.js";
|
|
4
|
+
import { stripUndefined, toResourceRefInput } from "./proto-utils.js";
|
|
5
5
|
import { type ResourceRef } from "./types.js";
|
|
6
6
|
import { create } from "@bufbuild/protobuf";
|
|
7
7
|
import { EmptySchema } from "@bufbuild/protobuf/wkt";
|
|
@@ -14,7 +14,7 @@ import { OrganizationCommandController } from "@stigmer/protos/ai/stigmer/tenanc
|
|
|
14
14
|
import { ManagementMode } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/enum_pb";
|
|
15
15
|
import { OrganizationIdSchema, OrganizationListSchema, OrganizationsSchema, OrganizationExternalLookupSchema, type OrganizationList, type Organizations, type OrganizationExternalLookup } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/io_pb";
|
|
16
16
|
import { OrganizationQueryController } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/query_pb";
|
|
17
|
-
import { OrganizationSpecSchema, OrganizationPreferencesSchema } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/spec_pb";
|
|
17
|
+
import { OrganizationSpecSchema, OrganizationPreferencesSchema, type OrganizationPreferences } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/spec_pb";
|
|
18
18
|
|
|
19
19
|
/** Provides operations on organization resources. */
|
|
20
20
|
export class OrganizationClient {
|
|
@@ -77,6 +77,14 @@ export class OrganizationClient {
|
|
|
77
77
|
|
|
78
78
|
/** Input for creating/updating a Organization. */
|
|
79
79
|
export interface OrganizationInput {
|
|
80
|
+
/**
|
|
81
|
+
* The resource's `metadata.id`, for exact update addressing when set
|
|
82
|
+
* from a loaded resource. Required for updates to platform-scoped
|
|
83
|
+
* (org-less) kinds, where the org+slug fallback cannot match. On
|
|
84
|
+
* create, the cloud server stamps its own id regardless; the OSS
|
|
85
|
+
* server honors a caller-supplied id (existing apply semantics).
|
|
86
|
+
*/
|
|
87
|
+
id?: string;
|
|
80
88
|
name: string;
|
|
81
89
|
slug?: string;
|
|
82
90
|
org: string;
|
|
@@ -94,11 +102,13 @@ export interface OrganizationInput {
|
|
|
94
102
|
/** SDK input type for OrganizationPreferences. */
|
|
95
103
|
export interface OrganizationPreferencesInput {
|
|
96
104
|
standingContext?: string;
|
|
105
|
+
memoryEnabled?: boolean;
|
|
97
106
|
}
|
|
98
107
|
|
|
99
108
|
function buildOrganizationPreferencesProto(input: OrganizationPreferencesInput) {
|
|
100
109
|
return Object.assign(create(OrganizationPreferencesSchema), stripUndefined({
|
|
101
110
|
standingContext: input.standingContext,
|
|
111
|
+
memoryEnabled: input.memoryEnabled,
|
|
102
112
|
}));
|
|
103
113
|
}
|
|
104
114
|
|
|
@@ -109,6 +119,7 @@ export function buildOrganizationProto(input: OrganizationInput): Organization {
|
|
|
109
119
|
apiVersion: "tenancy.stigmer.ai/v1",
|
|
110
120
|
kind: "Organization",
|
|
111
121
|
metadata: Object.assign(create(ApiResourceMetadataSchema), {
|
|
122
|
+
...(input.id && { id: input.id }),
|
|
112
123
|
name: input.name,
|
|
113
124
|
org: input.org,
|
|
114
125
|
...(input.slug && { slug: input.slug }),
|
|
@@ -126,3 +137,45 @@ export function buildOrganizationProto(input: OrganizationInput): Organization {
|
|
|
126
137
|
})),
|
|
127
138
|
}) as Organization;
|
|
128
139
|
}
|
|
140
|
+
|
|
141
|
+
function toOrganizationPreferencesInput(msg: OrganizationPreferences): OrganizationPreferencesInput {
|
|
142
|
+
return {
|
|
143
|
+
standingContext: msg.standingContext || undefined,
|
|
144
|
+
memoryEnabled: msg.memoryEnabled || undefined,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Maps a fetched {@link Organization} to a complete {@link OrganizationInput} for `update()`.
|
|
150
|
+
*
|
|
151
|
+
* The update RPC replaces the ENTIRE spec — spread this mapper's output
|
|
152
|
+
* and override only the fields you edit (spread nested objects the same
|
|
153
|
+
* way):
|
|
154
|
+
*
|
|
155
|
+
* await client.update({ ...toOrganizationUpdateInput(res), description: next });
|
|
156
|
+
*
|
|
157
|
+
* Proto3 defaults normalize to `undefined`; resource references keep
|
|
158
|
+
* `version` (pinned refs) and `kind`.
|
|
159
|
+
*/
|
|
160
|
+
export function toOrganizationUpdateInput(resource: Organization): OrganizationInput {
|
|
161
|
+
const meta = resource.metadata;
|
|
162
|
+
const spec = resource.spec ?? create(OrganizationSpecSchema);
|
|
163
|
+
return {
|
|
164
|
+
// Exact update addressing (id-first in the update pipeline) — for
|
|
165
|
+
// platform-scoped (org-less) kinds the org+slug fallback cannot
|
|
166
|
+
// match, so the id is the ONLY working address.
|
|
167
|
+
id: meta?.id || undefined,
|
|
168
|
+
name: meta?.name ?? "",
|
|
169
|
+
slug: meta?.slug || undefined,
|
|
170
|
+
org: meta?.org || meta?.slug || "",
|
|
171
|
+
labels: meta?.labels && Object.keys(meta.labels).length > 0 ? { ...meta.labels } : undefined,
|
|
172
|
+
visibility: meta?.visibility || undefined,
|
|
173
|
+
description: spec.description || undefined,
|
|
174
|
+
logoUrl: spec.logoUrl || undefined,
|
|
175
|
+
managementMode: spec.managementMode || undefined,
|
|
176
|
+
identityProviderRef: toResourceRefInput(spec.identityProviderRef),
|
|
177
|
+
externalOrgId: spec.externalOrgId || undefined,
|
|
178
|
+
isPersonal: spec.isPersonal || undefined,
|
|
179
|
+
preferences: spec.preferences ? toOrganizationPreferencesInput(spec.preferences) : undefined,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Code generated by stigmer-codegen. DO NOT EDIT.
|
|
2
2
|
|
|
3
3
|
import { wrapError } from "./errors.js";
|
|
4
|
-
import { stripUndefined, toTimestamp } from "./proto-utils.js";
|
|
4
|
+
import { stripUndefined, toTimestamp, toResourceRefInputs } from "./proto-utils.js";
|
|
5
5
|
import { type DeleteResourceInput, type ResourceRef } from "./types.js";
|
|
6
6
|
import { create } from "@bufbuild/protobuf";
|
|
7
|
+
import { timestampDate } from "@bufbuild/protobuf/wkt";
|
|
7
8
|
import { createClient, type Client, type Transport } from "@connectrpc/connect";
|
|
8
9
|
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
9
10
|
import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
|
|
@@ -90,6 +91,14 @@ export class PlatformClientClient {
|
|
|
90
91
|
|
|
91
92
|
/** Input for creating/updating a PlatformClient. */
|
|
92
93
|
export interface PlatformClientInput {
|
|
94
|
+
/**
|
|
95
|
+
* The resource's `metadata.id`, for exact update addressing when set
|
|
96
|
+
* from a loaded resource. Required for updates to platform-scoped
|
|
97
|
+
* (org-less) kinds, where the org+slug fallback cannot match. On
|
|
98
|
+
* create, the cloud server stamps its own id regardless; the OSS
|
|
99
|
+
* server honors a caller-supplied id (existing apply semantics).
|
|
100
|
+
*/
|
|
101
|
+
id?: string;
|
|
93
102
|
name: string;
|
|
94
103
|
slug?: string;
|
|
95
104
|
org: string;
|
|
@@ -114,6 +123,7 @@ export function buildPlatformClientProto(input: PlatformClientInput): PlatformCl
|
|
|
114
123
|
apiVersion: "iam.stigmer.ai/v1",
|
|
115
124
|
kind: "PlatformClient",
|
|
116
125
|
metadata: Object.assign(create(ApiResourceMetadataSchema), {
|
|
126
|
+
...(input.id && { id: input.id }),
|
|
117
127
|
name: input.name,
|
|
118
128
|
org: input.org,
|
|
119
129
|
...(input.slug && { slug: input.slug }),
|
|
@@ -134,3 +144,41 @@ export function buildPlatformClientProto(input: PlatformClientInput): PlatformCl
|
|
|
134
144
|
})),
|
|
135
145
|
}) as PlatformClient;
|
|
136
146
|
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Maps a fetched {@link PlatformClient} to a complete {@link PlatformClientInput} for `update()`.
|
|
150
|
+
*
|
|
151
|
+
* The update RPC replaces the ENTIRE spec — spread this mapper's output
|
|
152
|
+
* and override only the fields you edit (spread nested objects the same
|
|
153
|
+
* way):
|
|
154
|
+
*
|
|
155
|
+
* await client.update({ ...toPlatformClientUpdateInput(res), description: next });
|
|
156
|
+
*
|
|
157
|
+
* Proto3 defaults normalize to `undefined`; resource references keep
|
|
158
|
+
* `version` (pinned refs) and `kind`.
|
|
159
|
+
*/
|
|
160
|
+
export function toPlatformClientUpdateInput(resource: PlatformClient): PlatformClientInput {
|
|
161
|
+
const meta = resource.metadata;
|
|
162
|
+
const spec = resource.spec ?? create(PlatformClientSpecSchema);
|
|
163
|
+
return {
|
|
164
|
+
// Exact update addressing (id-first in the update pipeline) — for
|
|
165
|
+
// platform-scoped (org-less) kinds the org+slug fallback cannot
|
|
166
|
+
// match, so the id is the ONLY working address.
|
|
167
|
+
id: meta?.id || undefined,
|
|
168
|
+
name: meta?.name ?? "",
|
|
169
|
+
slug: meta?.slug || undefined,
|
|
170
|
+
org: meta?.org ?? "",
|
|
171
|
+
labels: meta?.labels && Object.keys(meta.labels).length > 0 ? { ...meta.labels } : undefined,
|
|
172
|
+
visibility: meta?.visibility || undefined,
|
|
173
|
+
clientId: spec.clientId || undefined,
|
|
174
|
+
clientSecretHash: spec.clientSecretHash || undefined,
|
|
175
|
+
secretFingerprint: spec.secretFingerprint || undefined,
|
|
176
|
+
expiresAt: spec.expiresAt ? timestampDate(spec.expiresAt) : undefined,
|
|
177
|
+
neverExpires: spec.neverExpires || undefined,
|
|
178
|
+
autoProvisionAccounts: spec.autoProvisionAccounts || undefined,
|
|
179
|
+
autoGrantOnOrg: spec.autoGrantOnOrg || undefined,
|
|
180
|
+
autoGrantRole: spec.autoGrantRole || undefined,
|
|
181
|
+
allowedOrigins: spec.allowedOrigins?.length ? [...spec.allowedOrigins] : undefined,
|
|
182
|
+
environmentRefs: toResourceRefInputs(spec.environmentRefs),
|
|
183
|
+
};
|
|
184
|
+
}
|
package/src/gen/project.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Code generated by stigmer-codegen. DO NOT EDIT.
|
|
2
2
|
|
|
3
3
|
import { wrapError } from "./errors.js";
|
|
4
|
-
import { stripUndefined } from "./proto-utils.js";
|
|
4
|
+
import { stripUndefined, toResourceRefInputs } from "./proto-utils.js";
|
|
5
5
|
import { type ResourceRef } from "./types.js";
|
|
6
6
|
import { create } from "@bufbuild/protobuf";
|
|
7
7
|
import { createClient, type Client, type Transport } from "@connectrpc/connect";
|
|
@@ -64,6 +64,14 @@ export class ProjectClient {
|
|
|
64
64
|
|
|
65
65
|
/** Input for creating/updating a Project. */
|
|
66
66
|
export interface ProjectInput {
|
|
67
|
+
/**
|
|
68
|
+
* The resource's `metadata.id`, for exact update addressing when set
|
|
69
|
+
* from a loaded resource. Required for updates to platform-scoped
|
|
70
|
+
* (org-less) kinds, where the org+slug fallback cannot match. On
|
|
71
|
+
* create, the cloud server stamps its own id regardless; the OSS
|
|
72
|
+
* server honors a caller-supplied id (existing apply semantics).
|
|
73
|
+
*/
|
|
74
|
+
id?: string;
|
|
67
75
|
name: string;
|
|
68
76
|
slug?: string;
|
|
69
77
|
org: string;
|
|
@@ -80,6 +88,7 @@ export function buildProjectProto(input: ProjectInput): Project {
|
|
|
80
88
|
apiVersion: "tenancy.stigmer.ai/v1",
|
|
81
89
|
kind: "Project",
|
|
82
90
|
metadata: Object.assign(create(ApiResourceMetadataSchema), {
|
|
91
|
+
...(input.id && { id: input.id }),
|
|
83
92
|
name: input.name,
|
|
84
93
|
org: input.org,
|
|
85
94
|
...(input.slug && { slug: input.slug }),
|
|
@@ -93,3 +102,34 @@ export function buildProjectProto(input: ProjectInput): Project {
|
|
|
93
102
|
})),
|
|
94
103
|
}) as Project;
|
|
95
104
|
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Maps a fetched {@link Project} to a complete {@link ProjectInput} for `update()`.
|
|
108
|
+
*
|
|
109
|
+
* The update RPC replaces the ENTIRE spec — spread this mapper's output
|
|
110
|
+
* and override only the fields you edit (spread nested objects the same
|
|
111
|
+
* way):
|
|
112
|
+
*
|
|
113
|
+
* await client.update({ ...toProjectUpdateInput(res), description: next });
|
|
114
|
+
*
|
|
115
|
+
* Proto3 defaults normalize to `undefined`; resource references keep
|
|
116
|
+
* `version` (pinned refs) and `kind`.
|
|
117
|
+
*/
|
|
118
|
+
export function toProjectUpdateInput(resource: Project): ProjectInput {
|
|
119
|
+
const meta = resource.metadata;
|
|
120
|
+
const spec = resource.spec ?? create(ProjectSpecSchema);
|
|
121
|
+
return {
|
|
122
|
+
// Exact update addressing (id-first in the update pipeline) — for
|
|
123
|
+
// platform-scoped (org-less) kinds the org+slug fallback cannot
|
|
124
|
+
// match, so the id is the ONLY working address.
|
|
125
|
+
id: meta?.id || undefined,
|
|
126
|
+
name: meta?.name ?? "",
|
|
127
|
+
slug: meta?.slug || undefined,
|
|
128
|
+
org: meta?.org ?? "",
|
|
129
|
+
labels: meta?.labels && Object.keys(meta.labels).length > 0 ? { ...meta.labels } : undefined,
|
|
130
|
+
visibility: meta?.visibility || undefined,
|
|
131
|
+
entryPoint: spec.entryPoint || undefined,
|
|
132
|
+
description: spec.description || undefined,
|
|
133
|
+
members: toResourceRefInputs(spec.members),
|
|
134
|
+
};
|
|
135
|
+
}
|
package/src/gen/proto-utils.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// Code generated by stigmer-codegen. DO NOT EDIT.
|
|
2
2
|
|
|
3
3
|
import { timestampFromDate, type Timestamp } from "@bufbuild/protobuf/wkt";
|
|
4
|
+
import type { ApiResourceReference } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
|
|
5
|
+
import type { EnvironmentSpec, EnvironmentValue } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/spec_pb";
|
|
6
|
+
import type { ExecutionValue } from "@stigmer/protos/ai/stigmer/agentic/executioncontext/v1/spec_pb";
|
|
7
|
+
import type { EnvSpecInput, EnvVarInput, ResourceRef } from "./types.js";
|
|
4
8
|
|
|
5
9
|
/**
|
|
6
10
|
* Remove keys whose values are `undefined` so that `Object.assign`
|
|
@@ -24,3 +28,63 @@ export function toTimestamp(value: Date | string): Timestamp {
|
|
|
24
28
|
const date = value instanceof Date ? value : new Date(value);
|
|
25
29
|
return timestampFromDate(date);
|
|
26
30
|
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Narrow a fetched ApiResourceReference to the ResourceRef input shape,
|
|
34
|
+
* or `undefined` when the reference is absent/empty (the builders treat a
|
|
35
|
+
* ref without org and slug as "no reference"). `version` is preserved —
|
|
36
|
+
* dropping it would reset a pinned reference to "latest". `kind` is also
|
|
37
|
+
* preserved: builders overwrite it where the proto annotates a reference
|
|
38
|
+
* kind, but refs without that annotation (e.g. an organization's
|
|
39
|
+
* identityProviderRef) carry the stored kind, so dropping it would be
|
|
40
|
+
* lossy.
|
|
41
|
+
*/
|
|
42
|
+
export function toResourceRefInput(ref: ApiResourceReference | undefined): ResourceRef | undefined {
|
|
43
|
+
if (!ref || (!ref.org && !ref.slug)) return undefined;
|
|
44
|
+
return {
|
|
45
|
+
org: ref.org,
|
|
46
|
+
slug: ref.slug,
|
|
47
|
+
...(ref.version && { version: ref.version }),
|
|
48
|
+
...(ref.kind && { kind: ref.kind }),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Map a repeated ApiResourceReference to ResourceRef inputs, or `undefined`
|
|
54
|
+
* when the list is absent/empty (the mappers' canonical shape for empty
|
|
55
|
+
* lists).
|
|
56
|
+
*/
|
|
57
|
+
export function toResourceRefInputs(refs: ApiResourceReference[] | undefined): ResourceRef[] | undefined {
|
|
58
|
+
if (!refs || refs.length === 0) return undefined;
|
|
59
|
+
return refs.map((r) => toResourceRefInput(r) ?? { org: "", slug: "" });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Convert a fetched EnvironmentSpec to the EnvSpecInput shape, or
|
|
64
|
+
* `undefined` when absent/empty.
|
|
65
|
+
*/
|
|
66
|
+
export function toEnvSpecInput(spec: EnvironmentSpec | undefined): EnvSpecInput | undefined {
|
|
67
|
+
if (!spec) return undefined;
|
|
68
|
+
const variables = toEnvVarInputMap(spec.data);
|
|
69
|
+
return variables ? { variables } : undefined;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Convert a map of EnvironmentValue to EnvVarInput entries, or `undefined`
|
|
74
|
+
* when the map is absent/empty.
|
|
75
|
+
*/
|
|
76
|
+
export function toEnvVarInputMap(data: Record<string, EnvironmentValue> | undefined): Record<string, EnvVarInput> | undefined {
|
|
77
|
+
if (!data || Object.keys(data).length === 0) return undefined;
|
|
78
|
+
return Object.fromEntries(Object.entries(data).map(([k, v]) =>
|
|
79
|
+
[k, { value: v.value, isSecret: v.isSecret || undefined, description: v.description || undefined }]));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Convert a map of ExecutionValue to EnvVarInput entries, or `undefined`
|
|
84
|
+
* when the map is absent/empty.
|
|
85
|
+
*/
|
|
86
|
+
export function toExecVarInputMap(data: Record<string, ExecutionValue> | undefined): Record<string, EnvVarInput> | undefined {
|
|
87
|
+
if (!data || Object.keys(data).length === 0) return undefined;
|
|
88
|
+
return Object.fromEntries(Object.entries(data).map(([k, v]) =>
|
|
89
|
+
[k, { value: v.value, isSecret: v.isSecret || undefined }]));
|
|
90
|
+
}
|