@stigmer/sdk 3.12.4 → 3.12.6

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.
Files changed (159) hide show
  1. package/__tests__/mcpserver-connect.test.d.ts +2 -0
  2. package/__tests__/mcpserver-connect.test.d.ts.map +1 -0
  3. package/__tests__/mcpserver-connect.test.js +146 -0
  4. package/__tests__/mcpserver-connect.test.js.map +1 -0
  5. package/__tests__/update-input-roundtrip.test.d.ts +2 -0
  6. package/__tests__/update-input-roundtrip.test.d.ts.map +1 -0
  7. package/__tests__/update-input-roundtrip.test.js +791 -0
  8. package/__tests__/update-input-roundtrip.test.js.map +1 -0
  9. package/__tests__/update-input.test.d.ts +2 -0
  10. package/__tests__/update-input.test.d.ts.map +1 -0
  11. package/__tests__/update-input.test.js +188 -0
  12. package/__tests__/update-input.test.js.map +1 -0
  13. package/gen/agent.d.ts +21 -0
  14. package/gen/agent.d.ts.map +1 -1
  15. package/gen/agent.js +73 -1
  16. package/gen/agent.js.map +1 -1
  17. package/gen/agentchannel.d.ts +23 -1
  18. package/gen/agentchannel.d.ts.map +1 -1
  19. package/gen/agentchannel.js +55 -1
  20. package/gen/agentchannel.js.map +1 -1
  21. package/gen/agentexecution.d.ts +29 -1
  22. package/gen/agentexecution.d.ts.map +1 -1
  23. package/gen/agentexecution.js +155 -2
  24. package/gen/agentexecution.js.map +1 -1
  25. package/gen/agentinstance.d.ts +21 -0
  26. package/gen/agentinstance.d.ts.map +1 -1
  27. package/gen/agentinstance.js +32 -1
  28. package/gen/agentinstance.js.map +1 -1
  29. package/gen/agentshare.d.ts +23 -1
  30. package/gen/agentshare.d.ts.map +1 -1
  31. package/gen/agentshare.js +53 -1
  32. package/gen/agentshare.js.map +1 -1
  33. package/gen/apikey.d.ts +21 -0
  34. package/gen/apikey.d.ts.map +1 -1
  35. package/gen/apikey.js +33 -1
  36. package/gen/apikey.js.map +1 -1
  37. package/gen/artifact.d.ts +8 -0
  38. package/gen/artifact.d.ts.map +1 -1
  39. package/gen/artifact.js +1 -0
  40. package/gen/artifact.js.map +1 -1
  41. package/gen/channelapp.d.ts +21 -0
  42. package/gen/channelapp.d.ts.map +1 -1
  43. package/gen/channelapp.js +45 -0
  44. package/gen/channelapp.js.map +1 -1
  45. package/gen/client.d.ts +3 -3
  46. package/gen/client.d.ts.map +1 -1
  47. package/gen/environment.d.ts +21 -0
  48. package/gen/environment.d.ts.map +1 -1
  49. package/gen/environment.js +31 -1
  50. package/gen/environment.js.map +1 -1
  51. package/gen/executioncontext.d.ts +8 -0
  52. package/gen/executioncontext.d.ts.map +1 -1
  53. package/gen/executioncontext.js +1 -0
  54. package/gen/executioncontext.js.map +1 -1
  55. package/gen/iampolicy.d.ts +8 -0
  56. package/gen/iampolicy.d.ts.map +1 -1
  57. package/gen/iampolicy.js +1 -0
  58. package/gen/iampolicy.js.map +1 -1
  59. package/gen/identityaccount.d.ts +29 -0
  60. package/gen/identityaccount.d.ts.map +1 -1
  61. package/gen/identityaccount.js +57 -2
  62. package/gen/identityaccount.js.map +1 -1
  63. package/gen/identityprovider.d.ts +21 -0
  64. package/gen/identityprovider.d.ts.map +1 -1
  65. package/gen/identityprovider.js +40 -0
  66. package/gen/identityprovider.js.map +1 -1
  67. package/gen/invitation.d.ts +8 -0
  68. package/gen/invitation.d.ts.map +1 -1
  69. package/gen/invitation.js +1 -0
  70. package/gen/invitation.js.map +1 -1
  71. package/gen/mcpserver.d.ts +22 -0
  72. package/gen/mcpserver.d.ts.map +1 -1
  73. package/gen/mcpserver.js +87 -1
  74. package/gen/mcpserver.js.map +1 -1
  75. package/gen/oauthapp.d.ts +23 -1
  76. package/gen/oauthapp.d.ts.map +1 -1
  77. package/gen/oauthapp.js +40 -0
  78. package/gen/oauthapp.js.map +1 -1
  79. package/gen/organization.d.ts +26 -0
  80. package/gen/organization.d.ts.map +1 -1
  81. package/gen/organization.js +49 -2
  82. package/gen/organization.js.map +1 -1
  83. package/gen/platformclient.d.ts +22 -0
  84. package/gen/platformclient.d.ts.map +1 -1
  85. package/gen/platformclient.js +42 -1
  86. package/gen/platformclient.js.map +1 -1
  87. package/gen/project.d.ts +21 -0
  88. package/gen/project.d.ts.map +1 -1
  89. package/gen/project.js +32 -1
  90. package/gen/project.js.map +1 -1
  91. package/gen/proto-utils.d.ts +36 -0
  92. package/gen/proto-utils.d.ts.map +1 -1
  93. package/gen/proto-utils.js +58 -0
  94. package/gen/proto-utils.js.map +1 -1
  95. package/gen/schedule.d.ts +23 -1
  96. package/gen/schedule.d.ts.map +1 -1
  97. package/gen/schedule.js +79 -1
  98. package/gen/schedule.js.map +1 -1
  99. package/gen/session.d.ts +21 -0
  100. package/gen/session.d.ts.map +1 -1
  101. package/gen/session.js +80 -1
  102. package/gen/session.js.map +1 -1
  103. package/gen/skill.d.ts +8 -0
  104. package/gen/skill.d.ts.map +1 -1
  105. package/gen/skill.js +1 -0
  106. package/gen/skill.js.map +1 -1
  107. package/gen/workflow.d.ts +21 -0
  108. package/gen/workflow.d.ts.map +1 -1
  109. package/gen/workflow.js +79 -0
  110. package/gen/workflow.js.map +1 -1
  111. package/gen/workflowexecution.d.ts +21 -0
  112. package/gen/workflowexecution.d.ts.map +1 -1
  113. package/gen/workflowexecution.js +36 -1
  114. package/gen/workflowexecution.js.map +1 -1
  115. package/gen/workflowinstance.d.ts +21 -0
  116. package/gen/workflowinstance.d.ts.map +1 -1
  117. package/gen/workflowinstance.js +33 -1
  118. package/gen/workflowinstance.js.map +1 -1
  119. package/index.d.ts +21 -20
  120. package/index.d.ts.map +1 -1
  121. package/index.js +25 -21
  122. package/index.js.map +1 -1
  123. package/mcpserver-connect.d.ts +79 -0
  124. package/mcpserver-connect.d.ts.map +1 -0
  125. package/mcpserver-connect.js +114 -0
  126. package/mcpserver-connect.js.map +1 -0
  127. package/package.json +2 -2
  128. package/src/__tests__/mcpserver-connect.test.ts +181 -0
  129. package/src/__tests__/update-input-roundtrip.test.ts +1031 -0
  130. package/src/__tests__/update-input.test.ts +250 -0
  131. package/src/gen/agent.ts +89 -3
  132. package/src/gen/agentchannel.ts +72 -4
  133. package/src/gen/agentexecution.ts +188 -6
  134. package/src/gen/agentinstance.ts +41 -1
  135. package/src/gen/agentshare.ts +68 -4
  136. package/src/gen/apikey.ts +42 -1
  137. package/src/gen/artifact.ts +9 -0
  138. package/src/gen/channelapp.ts +57 -1
  139. package/src/gen/client.ts +3 -3
  140. package/src/gen/environment.ts +40 -1
  141. package/src/gen/executioncontext.ts +9 -0
  142. package/src/gen/iampolicy.ts +9 -0
  143. package/src/gen/identityaccount.ts +77 -2
  144. package/src/gen/identityprovider.ts +49 -0
  145. package/src/gen/invitation.ts +9 -0
  146. package/src/gen/mcpserver.ts +101 -3
  147. package/src/gen/oauthapp.ts +51 -1
  148. package/src/gen/organization.ts +66 -2
  149. package/src/gen/platformclient.ts +52 -1
  150. package/src/gen/project.ts +41 -1
  151. package/src/gen/proto-utils.ts +64 -0
  152. package/src/gen/schedule.ts +98 -4
  153. package/src/gen/session.ts +97 -3
  154. package/src/gen/skill.ts +9 -0
  155. package/src/gen/workflow.ts +96 -2
  156. package/src/gen/workflowexecution.ts +45 -1
  157. package/src/gen/workflowinstance.ts +42 -1
  158. package/src/index.ts +32 -3
  159. package/src/mcpserver-connect.ts +159 -0
@@ -0,0 +1,250 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { create, toJson } from "@bufbuild/protobuf";
3
+ import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
4
+ import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
5
+ import {
6
+ OrganizationSchema,
7
+ type Organization,
8
+ } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/api_pb";
9
+ import { OrganizationSpecSchema } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/spec_pb";
10
+ import { ManagementMode } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/enum_pb";
11
+ import {
12
+ IdentityAccountSchema,
13
+ type IdentityAccount,
14
+ } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/api_pb";
15
+ import { IdentityAccountSpecSchema } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/spec_pb";
16
+ import { IdentityAccountProvisioningMode } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/enum_pb";
17
+ import {
18
+ buildOrganizationProto,
19
+ toOrganizationUpdateInput,
20
+ } from "../gen/organization";
21
+ import {
22
+ buildIdentityAccountProto,
23
+ toIdentityAccountUpdateInput,
24
+ } from "../gen/identityaccount";
25
+
26
+ /**
27
+ * Update RPCs are full-spec replacements, so a complete mapper must
28
+ * round-trip EVERY mutable field of a loaded resource through the generated
29
+ * builder without loss. These tests pin that contract: fully-populated
30
+ * resource → mapper → builder → spec (as JSON, defaults omitted) deep-equals
31
+ * the original. If a mapper drops a field, the wipe-bug class is back.
32
+ */
33
+
34
+ function fullOrganization(): Organization {
35
+ return create(OrganizationSchema, {
36
+ apiVersion: "tenancy.stigmer.ai/v1",
37
+ kind: "Organization",
38
+ metadata: {
39
+ id: "acme",
40
+ name: "Acme Corp",
41
+ slug: "acme",
42
+ org: "acme",
43
+ labels: { tier: "gold" },
44
+ visibility: ApiResourceVisibility.visibility_private,
45
+ },
46
+ spec: {
47
+ description: "We make everything.",
48
+ logoUrl: "https://acme.example/logo.png",
49
+ managementMode: ManagementMode.self_managed,
50
+ identityProviderRef: {
51
+ org: "acme",
52
+ slug: "acme-okta",
53
+ kind: ApiResourceKind.identity_provider,
54
+ },
55
+ externalOrgId: "ext-org-1",
56
+ isPersonal: true,
57
+ preferences: { standingContext: "We deploy to us-east-1." },
58
+ },
59
+ });
60
+ }
61
+
62
+ function fullIdentityAccount(): IdentityAccount {
63
+ return create(IdentityAccountSchema, {
64
+ apiVersion: "iam.stigmer.ai/v1",
65
+ kind: "IdentityAccount",
66
+ metadata: {
67
+ id: "ia-123",
68
+ name: "Ada Lovelace",
69
+ slug: "ada-lovelace",
70
+ org: "acme",
71
+ labels: { team: "platform" },
72
+ visibility: ApiResourceVisibility.visibility_private,
73
+ },
74
+ spec: {
75
+ idpId: "auth0|abc123",
76
+ email: "ada@acme.example",
77
+ firstName: "Ada",
78
+ lastName: "Lovelace",
79
+ pictureUrl: "https://acme.example/ada.png",
80
+ isMachineAccount: true,
81
+ provisioningMode: IdentityAccountProvisioningMode.federated,
82
+ identityProviderRef: { org: "acme", slug: "acme-okta" },
83
+ preferences: {
84
+ standingContext: "Keep answers terse.",
85
+ defaultHarness: "cursor",
86
+ defaultNativeModel: "claude-sonnet-4.6",
87
+ defaultCursorModel: "composer-2.5",
88
+ },
89
+ },
90
+ });
91
+ }
92
+
93
+ describe("toOrganizationUpdateInput", () => {
94
+ it("round-trips a fully-populated organization spec through the builder", () => {
95
+ const org = fullOrganization();
96
+
97
+ const built = buildOrganizationProto(toOrganizationUpdateInput(org));
98
+
99
+ expect(toJson(OrganizationSpecSchema, built.spec!)).toEqual(
100
+ toJson(OrganizationSpecSchema, org.spec!),
101
+ );
102
+ expect(built.metadata?.name).toBe("Acme Corp");
103
+ expect(built.metadata?.slug).toBe("acme");
104
+ expect(built.metadata?.org).toBe("acme");
105
+ expect(built.metadata?.labels).toEqual({ tier: "gold" });
106
+ expect(built.metadata?.visibility).toBe(
107
+ ApiResourceVisibility.visibility_private,
108
+ );
109
+ });
110
+
111
+ it("preserves preferences when a caller overrides only profile fields (the wipe-bug class)", () => {
112
+ const org = fullOrganization();
113
+
114
+ const built = buildOrganizationProto({
115
+ ...toOrganizationUpdateInput(org),
116
+ description: "New description",
117
+ });
118
+
119
+ expect(built.spec?.preferences?.standingContext).toBe(
120
+ "We deploy to us-east-1.",
121
+ );
122
+ expect(built.spec?.description).toBe("New description");
123
+ expect(built.spec?.logoUrl).toBe("https://acme.example/logo.png");
124
+ });
125
+
126
+ it("maps an empty spec without inventing values", () => {
127
+ const org = create(OrganizationSchema, {
128
+ metadata: { name: "Bare", slug: "bare", org: "bare" },
129
+ spec: {},
130
+ });
131
+
132
+ const built = buildOrganizationProto(toOrganizationUpdateInput(org));
133
+
134
+ expect(toJson(OrganizationSpecSchema, built.spec!)).toEqual({});
135
+ });
136
+
137
+ it("falls back to the slug when metadata.org is empty", () => {
138
+ const org = create(OrganizationSchema, {
139
+ metadata: { name: "Bare", slug: "bare" },
140
+ });
141
+
142
+ expect(toOrganizationUpdateInput(org).org).toBe("bare");
143
+ });
144
+
145
+ it("carries metadata.id for exact update addressing", () => {
146
+ const built = buildOrganizationProto(
147
+ toOrganizationUpdateInput(fullOrganization()),
148
+ );
149
+
150
+ expect(built.metadata?.id).toBe("acme");
151
+ });
152
+ });
153
+
154
+ describe("toIdentityAccountUpdateInput", () => {
155
+ it("round-trips a fully-populated identity account spec through the builder", () => {
156
+ const account = fullIdentityAccount();
157
+
158
+ const built = buildIdentityAccountProto(
159
+ toIdentityAccountUpdateInput(account),
160
+ );
161
+
162
+ expect(toJson(IdentityAccountSpecSchema, built.spec!)).toEqual(
163
+ toJson(IdentityAccountSpecSchema, account.spec!),
164
+ );
165
+ expect(built.metadata?.name).toBe("Ada Lovelace");
166
+ expect(built.metadata?.labels).toEqual({ team: "platform" });
167
+ });
168
+
169
+ it("carries org and slug — the update pipeline's fallback address", () => {
170
+ const input = toIdentityAccountUpdateInput(fullIdentityAccount());
171
+
172
+ expect(input.org).toBe("acme");
173
+ expect(input.slug).toBe("ada-lovelace");
174
+ });
175
+
176
+ it("carries metadata.id — the ONLY address that works for a real (org-less) account", () => {
177
+ // Identity accounts are platform-scoped: metadata.org is never set in
178
+ // production, so the pipeline's org+slug fallback structurally cannot
179
+ // match one. Without the id, this update is NOT_FOUND by construction.
180
+ const account = create(IdentityAccountSchema, {
181
+ metadata: {
182
+ id: "ida_01JEXAMPLE",
183
+ name: "ada@acme.example",
184
+ slug: "ada-acme-example",
185
+ },
186
+ spec: { idpId: "auth0|abc123" },
187
+ });
188
+
189
+ const built = buildIdentityAccountProto(
190
+ toIdentityAccountUpdateInput(account),
191
+ );
192
+
193
+ expect(built.metadata?.id).toBe("ida_01JEXAMPLE");
194
+ expect(built.metadata?.slug).toBe("ada-acme-example");
195
+ });
196
+
197
+ it("preserves the rest of the spec when a caller overrides only preferences", () => {
198
+ const account = fullIdentityAccount();
199
+ const mapped = toIdentityAccountUpdateInput(account);
200
+
201
+ const built = buildIdentityAccountProto({
202
+ ...mapped,
203
+ preferences: { ...mapped.preferences, standingContext: "Prefer bullet points." },
204
+ });
205
+
206
+ expect(built.spec?.preferences?.standingContext).toBe(
207
+ "Prefer bullet points.",
208
+ );
209
+ expect(built.spec?.email).toBe("ada@acme.example");
210
+ expect(built.spec?.idpId).toBe("auth0|abc123");
211
+ expect(built.spec?.provisioningMode).toBe(
212
+ IdentityAccountProvisioningMode.federated,
213
+ );
214
+ });
215
+
216
+ it("preserves structured defaults when only standing context is edited (nested wipe-bug class)", () => {
217
+ const account = fullIdentityAccount();
218
+ const mapped = toIdentityAccountUpdateInput(account);
219
+
220
+ // The correct editor pattern for a nested message: spread the mapper's
221
+ // COMPLETE preferences and override only the edited field. A bare
222
+ // `preferences: { standingContext }` literal would wipe the structured
223
+ // defaults — the session-4 wipe bug recurring one level down.
224
+ const built = buildIdentityAccountProto({
225
+ ...mapped,
226
+ preferences: { ...mapped.preferences, standingContext: "Terser still." },
227
+ });
228
+
229
+ expect(built.spec?.preferences?.standingContext).toBe("Terser still.");
230
+ expect(built.spec?.preferences?.defaultHarness).toBe("cursor");
231
+ expect(built.spec?.preferences?.defaultNativeModel).toBe("claude-sonnet-4.6");
232
+ expect(built.spec?.preferences?.defaultCursorModel).toBe("composer-2.5");
233
+ });
234
+
235
+ it("clears standing context to wire-absent when the text is emptied", () => {
236
+ const account = fullIdentityAccount();
237
+ const mapped = toIdentityAccountUpdateInput(account);
238
+
239
+ const built = buildIdentityAccountProto({
240
+ ...mapped,
241
+ preferences: { ...mapped.preferences, standingContext: "" },
242
+ });
243
+
244
+ // Proto3 empty string is the field default — wire-identical to absent,
245
+ // which the server compose steps treat as "no preference declared".
246
+ expect(built.spec?.preferences?.standingContext ?? "").toBe("");
247
+ // Clearing one field never disturbs its siblings.
248
+ expect(built.spec?.preferences?.defaultHarness).toBe("cursor");
249
+ });
250
+ });
package/src/gen/agent.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, toResourceRefInputs } from "./proto-utils.js";
5
5
  import { 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";
@@ -9,8 +9,8 @@ import { AgentSchema, type Agent } from "@stigmer/protos/ai/stigmer/agentic/agen
9
9
  import { AgentCommandController } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/command_pb";
10
10
  import { AgentIdSchema, GetDefaultAgentRequestSchema, type GetDefaultAgentRequest } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/io_pb";
11
11
  import { AgentQueryController } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/query_pb";
12
- import { AgentSpecSchema, ToolApprovalOverrideSchema, McpServerUsageSchema, McpAccessSchema, SubAgentSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/spec_pb";
13
- import { EnvVarDeclarationSchema } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/spec_pb";
12
+ import { AgentSpecSchema, ToolApprovalOverrideSchema, McpServerUsageSchema, McpAccessSchema, SubAgentSchema, type ToolApprovalOverride, type McpServerUsage, type McpAccess, type SubAgent } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/spec_pb";
13
+ import { EnvVarDeclarationSchema, type EnvVarDeclaration } from "@stigmer/protos/ai/stigmer/agentic/environment/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 { ApiResourceReferenceSchema, type UpdateVisibilityInput } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
@@ -100,6 +100,14 @@ export class AgentClient {
100
100
 
101
101
  /** Input for creating/updating a Agent. */
102
102
  export interface AgentInput {
103
+ /**
104
+ * The resource's `metadata.id`, for exact update addressing when set
105
+ * from a loaded resource. Required for updates to platform-scoped
106
+ * (org-less) kinds, where the org+slug fallback cannot match. On
107
+ * create, the cloud server stamps its own id regardless; the OSS
108
+ * server honors a caller-supplied id (existing apply semantics).
109
+ */
110
+ id?: string;
103
111
  name: string;
104
112
  slug?: string;
105
113
  org: string;
@@ -205,6 +213,7 @@ export function buildAgentProto(input: AgentInput): Agent {
205
213
  apiVersion: "agentic.stigmer.ai/v1",
206
214
  kind: "Agent",
207
215
  metadata: Object.assign(create(ApiResourceMetadataSchema), {
216
+ ...(input.id && { id: input.id }),
208
217
  name: input.name,
209
218
  org: input.org,
210
219
  ...(input.slug && { slug: input.slug }),
@@ -222,3 +231,80 @@ export function buildAgentProto(input: AgentInput): Agent {
222
231
  })),
223
232
  }) as Agent;
224
233
  }
234
+
235
+ function toToolApprovalOverrideInput(msg: ToolApprovalOverride): ToolApprovalOverrideInput {
236
+ return {
237
+ toolName: msg.toolName || undefined,
238
+ requiresApproval: msg.requiresApproval || undefined,
239
+ message: msg.message || undefined,
240
+ };
241
+ }
242
+
243
+ function toMcpServerUsageInput(msg: McpServerUsage): McpServerUsageInput {
244
+ return {
245
+ mcpServerRef: toResourceRefInput(msg.mcpServerRef) ?? { org: "", slug: "" },
246
+ enabledTools: msg.enabledTools?.length ? [...msg.enabledTools] : undefined,
247
+ toolApprovalOverrides: msg.toolApprovalOverrides?.length ? msg.toolApprovalOverrides.map(toToolApprovalOverrideInput) : undefined,
248
+ };
249
+ }
250
+
251
+ function toMcpAccessInput(msg: McpAccess): McpAccessInput {
252
+ return {
253
+ mcpServer: msg.mcpServer ?? "",
254
+ enabledTools: msg.enabledTools?.length ? [...msg.enabledTools] : undefined,
255
+ };
256
+ }
257
+
258
+ function toSubAgentInput(msg: SubAgent): SubAgentInput {
259
+ return {
260
+ name: msg.name ?? "",
261
+ description: msg.description || undefined,
262
+ instructions: msg.instructions || undefined,
263
+ mcpAccess: msg.mcpAccess?.length ? msg.mcpAccess.map(toMcpAccessInput) : undefined,
264
+ skillRefs: toResourceRefInputs(msg.skillRefs),
265
+ modelOverride: msg.modelOverride || undefined,
266
+ };
267
+ }
268
+
269
+ function toEnvVarDeclarationInput(msg: EnvVarDeclaration): EnvVarDeclarationInput {
270
+ return {
271
+ isSecret: msg.isSecret || undefined,
272
+ description: msg.description || undefined,
273
+ optional: msg.optional || undefined,
274
+ };
275
+ }
276
+
277
+ /**
278
+ * Maps a fetched {@link Agent} to a complete {@link AgentInput} for `update()`.
279
+ *
280
+ * The update RPC replaces the ENTIRE spec — spread this mapper's output
281
+ * and override only the fields you edit (spread nested objects the same
282
+ * way):
283
+ *
284
+ * await client.update({ ...toAgentUpdateInput(res), description: next });
285
+ *
286
+ * Proto3 defaults normalize to `undefined`; resource references keep
287
+ * `version` (pinned refs) and `kind`.
288
+ */
289
+ export function toAgentUpdateInput(resource: Agent): AgentInput {
290
+ const meta = resource.metadata;
291
+ const spec = resource.spec ?? create(AgentSpecSchema);
292
+ return {
293
+ // Exact update addressing (id-first in the update pipeline) — for
294
+ // platform-scoped (org-less) kinds the org+slug fallback cannot
295
+ // match, so the id is the ONLY working address.
296
+ id: meta?.id || undefined,
297
+ name: meta?.name ?? "",
298
+ slug: meta?.slug || undefined,
299
+ org: meta?.org ?? "",
300
+ labels: meta?.labels && Object.keys(meta.labels).length > 0 ? { ...meta.labels } : undefined,
301
+ visibility: meta?.visibility || undefined,
302
+ description: spec.description || undefined,
303
+ iconUrl: spec.iconUrl || undefined,
304
+ instructions: spec.instructions || undefined,
305
+ mcpServerUsages: spec.mcpServerUsages?.length ? spec.mcpServerUsages.map(toMcpServerUsageInput) : undefined,
306
+ skillRefs: toResourceRefInputs(spec.skillRefs),
307
+ subAgents: spec.subAgents?.length ? spec.subAgents.map(toSubAgentInput) : undefined,
308
+ env: Object.keys(spec.env ?? {}).length > 0 ? Object.fromEntries(Object.entries(spec.env).map(([k, v]) => [k, toEnvVarDeclarationInput(v)])) : undefined,
309
+ };
310
+ }
@@ -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, 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";
@@ -15,9 +15,9 @@ import { ChannelMessageCommandController } from "@stigmer/protos/ai/stigmer/agen
15
15
  import { SendChannelMessageOutputSchema, SendChannelMessageInputSchema, ListChannelTemplatesInputSchema, ChannelTemplatesSchema, ListMessagingChannelsInputSchema, MessagingChannelsSchema, type SendChannelMessageOutput, type SendChannelMessageInput, type ListChannelTemplatesInput, type ChannelTemplates, type ListMessagingChannelsInput, type MessagingChannels } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/message_io_pb";
16
16
  import { ChannelMessageQueryController } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/message_query_pb";
17
17
  import { AgentChannelQueryController } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/query_pb";
18
- import { AgentChannelSpecSchema, SlackChannelConfigSchema, WhatsAppChannelConfigSchema } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/spec_pb";
19
- import { ServiceTier } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
20
- import { RunConfigSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/invocation_pb";
18
+ import { AgentChannelSpecSchema, SlackChannelConfigSchema, WhatsAppChannelConfigSchema, type SlackChannelConfig, type WhatsAppChannelConfig } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/spec_pb";
19
+ import { ServiceTier, ThinkingMode } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
20
+ import { RunConfigSchema, type RunConfig } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/invocation_pb";
21
21
  import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
22
22
  import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
23
23
  import { ApiResourceReferenceSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
@@ -176,6 +176,14 @@ export class AgentChannelClient {
176
176
 
177
177
  /** Input for creating/updating a AgentChannel. */
178
178
  export interface AgentChannelInput {
179
+ /**
180
+ * The resource's `metadata.id`, for exact update addressing when set
181
+ * from a loaded resource. Required for updates to platform-scoped
182
+ * (org-less) kinds, where the org+slug fallback cannot match. On
183
+ * create, the cloud server stamps its own id regardless; the OSS
184
+ * server honors a caller-supplied id (existing apply semantics).
185
+ */
186
+ id?: string;
179
187
  name: string;
180
188
  slug?: string;
181
189
  org: string;
@@ -206,6 +214,7 @@ export interface RunConfigInput {
206
214
  maxCostUsd?: number;
207
215
  maxToolRounds?: number;
208
216
  serviceTier?: ServiceTier;
217
+ thinkingMode?: ThinkingMode;
209
218
  }
210
219
 
211
220
  function buildSlackChannelConfigProto(input: SlackChannelConfigInput) {
@@ -225,6 +234,7 @@ function buildRunConfigProto(input: RunConfigInput) {
225
234
  maxCostUsd: input.maxCostUsd,
226
235
  maxToolRounds: input.maxToolRounds,
227
236
  serviceTier: input.serviceTier,
237
+ thinkingMode: input.thinkingMode,
228
238
  }));
229
239
  }
230
240
 
@@ -250,6 +260,7 @@ export function buildAgentChannelProto(input: AgentChannelInput): AgentChannel {
250
260
  apiVersion: "agentic.stigmer.ai/v1",
251
261
  kind: "AgentChannel",
252
262
  metadata: Object.assign(create(ApiResourceMetadataSchema), {
263
+ ...(input.id && { id: input.id }),
253
264
  name: input.name,
254
265
  org: input.org,
255
266
  ...(input.slug && { slug: input.slug }),
@@ -259,3 +270,60 @@ export function buildAgentChannelProto(input: AgentChannelInput): AgentChannel {
259
270
  spec,
260
271
  }) as AgentChannel;
261
272
  }
273
+
274
+ function toSlackChannelConfigInput(msg: SlackChannelConfig): SlackChannelConfigInput {
275
+ return {
276
+ };
277
+ }
278
+
279
+ function toWhatsAppChannelConfigInput(msg: WhatsAppChannelConfig): WhatsAppChannelConfigInput {
280
+ return {
281
+ phoneNumberId: msg.phoneNumberId || undefined,
282
+ };
283
+ }
284
+
285
+ function toRunConfigInput(msg: RunConfig): RunConfigInput {
286
+ return {
287
+ modelName: msg.modelName || undefined,
288
+ maxCostUsd: msg.maxCostUsd || undefined,
289
+ maxToolRounds: msg.maxToolRounds || undefined,
290
+ serviceTier: msg.serviceTier || undefined,
291
+ thinkingMode: msg.thinkingMode || undefined,
292
+ };
293
+ }
294
+
295
+ /**
296
+ * Maps a fetched {@link AgentChannel} to a complete {@link AgentChannelInput} for `update()`.
297
+ *
298
+ * The update RPC replaces the ENTIRE spec — spread this mapper's output
299
+ * and override only the fields you edit (spread nested objects the same
300
+ * way):
301
+ *
302
+ * await client.update({ ...toAgentChannelUpdateInput(res), description: next });
303
+ *
304
+ * Proto3 defaults normalize to `undefined`; resource references keep
305
+ * `version` (pinned refs) and `kind`.
306
+ */
307
+ export function toAgentChannelUpdateInput(resource: AgentChannel): AgentChannelInput {
308
+ const meta = resource.metadata;
309
+ const spec = resource.spec ?? create(AgentChannelSpecSchema);
310
+ return {
311
+ // Exact update addressing (id-first in the update pipeline) — for
312
+ // platform-scoped (org-less) kinds the org+slug fallback cannot
313
+ // match, so the id is the ONLY working address.
314
+ id: meta?.id || undefined,
315
+ name: meta?.name ?? "",
316
+ slug: meta?.slug || undefined,
317
+ org: meta?.org ?? "",
318
+ labels: meta?.labels && Object.keys(meta.labels).length > 0 ? { ...meta.labels } : undefined,
319
+ visibility: meta?.visibility || undefined,
320
+ agentRef: toResourceRefInput(spec.agentRef) ?? { org: "", slug: "" },
321
+ enabled: spec.enabled || undefined,
322
+ slack: spec.providerConfig?.case === "slack" ? toSlackChannelConfigInput(spec.providerConfig.value) : undefined,
323
+ whatsapp: spec.providerConfig?.case === "whatsapp" ? toWhatsAppChannelConfigInput(spec.providerConfig.value) : undefined,
324
+ environmentRefs: toResourceRefInputs(spec.environmentRefs),
325
+ appRef: toResourceRefInput(spec.appRef),
326
+ proactiveMessagingEnabled: spec.proactiveMessagingEnabled || undefined,
327
+ runConfig: spec.runConfig ? toRunConfigInput(spec.runConfig) : undefined,
328
+ };
329
+ }