@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.
- package/__tests__/mcpserver-connect.test.d.ts +2 -0
- package/__tests__/mcpserver-connect.test.d.ts.map +1 -0
- package/__tests__/mcpserver-connect.test.js +146 -0
- package/__tests__/mcpserver-connect.test.js.map +1 -0
- 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 +791 -0
- package/__tests__/update-input-roundtrip.test.js.map +1 -0
- package/__tests__/update-input.test.d.ts +2 -0
- package/__tests__/update-input.test.d.ts.map +1 -0
- package/__tests__/update-input.test.js +188 -0
- package/__tests__/update-input.test.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 +29 -1
- package/gen/agentexecution.d.ts.map +1 -1
- package/gen/agentexecution.js +155 -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 +3 -3
- package/gen/client.d.ts.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 +29 -0
- package/gen/identityaccount.d.ts.map +1 -1
- package/gen/identityaccount.js +57 -2
- 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 +22 -0
- package/gen/mcpserver.d.ts.map +1 -1
- package/gen/mcpserver.js +87 -1
- package/gen/mcpserver.js.map +1 -1
- package/gen/oauthapp.d.ts +23 -1
- package/gen/oauthapp.d.ts.map +1 -1
- package/gen/oauthapp.js +40 -0
- package/gen/oauthapp.js.map +1 -1
- package/gen/organization.d.ts +26 -0
- package/gen/organization.d.ts.map +1 -1
- package/gen/organization.js +49 -2
- package/gen/organization.js.map +1 -1
- package/gen/platformclient.d.ts +22 -0
- package/gen/platformclient.d.ts.map +1 -1
- package/gen/platformclient.js +42 -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 +21 -20
- package/index.d.ts.map +1 -1
- package/index.js +25 -21
- package/index.js.map +1 -1
- package/mcpserver-connect.d.ts +79 -0
- package/mcpserver-connect.d.ts.map +1 -0
- package/mcpserver-connect.js +114 -0
- package/mcpserver-connect.js.map +1 -0
- package/package.json +2 -2
- package/src/__tests__/mcpserver-connect.test.ts +181 -0
- package/src/__tests__/update-input-roundtrip.test.ts +1031 -0
- package/src/__tests__/update-input.test.ts +250 -0
- package/src/gen/agent.ts +89 -3
- package/src/gen/agentchannel.ts +72 -4
- package/src/gen/agentexecution.ts +188 -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 +3 -3
- 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 +77 -2
- package/src/gen/identityprovider.ts +49 -0
- package/src/gen/invitation.ts +9 -0
- package/src/gen/mcpserver.ts +101 -3
- package/src/gen/oauthapp.ts +51 -1
- package/src/gen/organization.ts +66 -2
- package/src/gen/platformclient.ts +52 -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 +32 -3
- 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
|
+
}
|
package/src/gen/agentchannel.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 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
|
+
}
|