@stigmer/sdk 3.26.0 → 3.27.0

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 (40) hide show
  1. package/__tests__/iam-principal.test.d.ts +2 -0
  2. package/__tests__/iam-principal.test.d.ts.map +1 -0
  3. package/__tests__/iam-principal.test.js +65 -0
  4. package/__tests__/iam-principal.test.js.map +1 -0
  5. package/authorization-config.d.ts +28 -0
  6. package/authorization-config.d.ts.map +1 -1
  7. package/authorization-config.js +26 -1
  8. package/authorization-config.js.map +1 -1
  9. package/gen/authorization-config.d.ts +11 -0
  10. package/gen/authorization-config.d.ts.map +1 -1
  11. package/gen/authorization-config.js +23 -0
  12. package/gen/authorization-config.js.map +1 -1
  13. package/gen/client.d.ts +4 -0
  14. package/gen/client.d.ts.map +1 -1
  15. package/gen/client.js +4 -0
  16. package/gen/client.js.map +1 -1
  17. package/gen/resource-availability.d.ts.map +1 -1
  18. package/gen/resource-availability.js +1 -0
  19. package/gen/resource-availability.js.map +1 -1
  20. package/gen/team.d.ts +49 -0
  21. package/gen/team.d.ts.map +1 -0
  22. package/gen/team.js +119 -0
  23. package/gen/team.js.map +1 -0
  24. package/iam-principal.d.ts +30 -0
  25. package/iam-principal.d.ts.map +1 -0
  26. package/iam-principal.js +73 -0
  27. package/iam-principal.js.map +1 -0
  28. package/index.d.ts +3 -1
  29. package/index.d.ts.map +1 -1
  30. package/index.js +3 -1
  31. package/index.js.map +1 -1
  32. package/package.json +2 -2
  33. package/src/__tests__/iam-principal.test.ts +82 -0
  34. package/src/authorization-config.ts +48 -1
  35. package/src/gen/authorization-config.ts +24 -0
  36. package/src/gen/client.ts +5 -0
  37. package/src/gen/resource-availability.ts +1 -0
  38. package/src/gen/team.ts +132 -0
  39. package/src/iam-principal.ts +92 -0
  40. package/src/index.ts +17 -0
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Who an IAM policy grants a role to: a person or a team, in one shape a
3
+ * client builds grants from and reads access lists back into.
4
+ *
5
+ * The wire spells a grantee as an `ApiResourceRef`: a person is
6
+ * `identity_account:<id>` with no relation qualifier, a team is
7
+ * `team:<id>#member` (every member of the team holds the grant). This
8
+ * module is the one place in the SDK that knows that spelling, so no caller
9
+ * writes the qualifier by hand and no caller can drop it.
10
+ *
11
+ * Reading goes through the same module: `granteeFromView` turns an access
12
+ * list entry back into a `Grantee` and answers `undefined` for anything it
13
+ * does not recognise (another kind, a team with a qualifier other than
14
+ * `member`), so a client never acts on a principal it would misname. A
15
+ * revoke built from the returned grantee names the exact row the list
16
+ * showed, because the server's revoke matches the qualifier exactly.
17
+ */
18
+ import { create } from "@bufbuild/protobuf";
19
+ import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
20
+ import { ApiResourceRefSchema, } from "@stigmer/protos/ai/stigmer/iam/iampolicy/v1/spec_pb";
21
+ const PERSON_KIND = ApiResourceKind[ApiResourceKind.identity_account];
22
+ const TEAM_KIND = ApiResourceKind[ApiResourceKind.team];
23
+ /** The relation that makes every member of a team the grantee. */
24
+ const TEAM_MEMBERS_RELATION = "member";
25
+ /** A person, by identity account id (`ida_...`). */
26
+ export function personGrantee(id) {
27
+ return { kind: "identity_account", id };
28
+ }
29
+ /** A team, by team id (`tm_...`). */
30
+ export function teamGrantee(id) {
31
+ return { kind: "team", id };
32
+ }
33
+ /**
34
+ * The `ApiResourceRef` an IAM policy spec names the grantee with: a person
35
+ * unqualified, a team as its members.
36
+ */
37
+ export function granteeRef(grantee) {
38
+ switch (grantee.kind) {
39
+ case "identity_account":
40
+ return create(ApiResourceRefSchema, { kind: PERSON_KIND, id: grantee.id });
41
+ case "team":
42
+ return create(ApiResourceRefSchema, {
43
+ kind: TEAM_KIND,
44
+ id: grantee.id,
45
+ relation: TEAM_MEMBERS_RELATION,
46
+ });
47
+ default: {
48
+ const unreachable = grantee;
49
+ return unreachable;
50
+ }
51
+ }
52
+ }
53
+ /**
54
+ * The grantee an access-list entry names, or `undefined` when the entry
55
+ * is not a person or a team's members (a structural principal, a kind this
56
+ * SDK does not know, or a team qualifier other than `member`).
57
+ */
58
+ export function granteeFromView(view) {
59
+ if (!view.id)
60
+ return undefined;
61
+ if (view.kind === PERSON_KIND && view.relation === "") {
62
+ return personGrantee(view.id);
63
+ }
64
+ if (view.kind === TEAM_KIND && view.relation === TEAM_MEMBERS_RELATION) {
65
+ return teamGrantee(view.id);
66
+ }
67
+ return undefined;
68
+ }
69
+ /** A stable key for a grantee: its kind and id. */
70
+ export function granteeKey(grantee) {
71
+ return `${grantee.kind}:${grantee.id}`;
72
+ }
73
+ //# sourceMappingURL=iam-principal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iam-principal.js","sourceRoot":"","sources":["../src/iam-principal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AAEtH,OAAO,EAEL,oBAAoB,GACrB,MAAM,qDAAqD,CAAC;AAE7D,MAAM,WAAW,GAAG,eAAe,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;AACtE,MAAM,SAAS,GAAG,eAAe,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AAExD,kEAAkE;AAClE,MAAM,qBAAqB,GAAG,QAAQ,CAAC;AAUvC,oDAAoD;AACpD,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,EAAE,EAAE,CAAC;AAC1C,CAAC;AAED,qCAAqC;AACrC,MAAM,UAAU,WAAW,CAAC,EAAU;IACpC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AAC9B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,OAAgB;IACzC,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,kBAAkB;YACrB,OAAO,MAAM,CAAC,oBAAoB,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;QAC7E,KAAK,MAAM;YACT,OAAO,MAAM,CAAC,oBAAoB,EAAE;gBAClC,IAAI,EAAE,SAAS;gBACf,EAAE,EAAE,OAAO,CAAC,EAAE;gBACd,QAAQ,EAAE,qBAAqB;aAChC,CAAC,CAAC;QACL,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,WAAW,GAAU,OAAO,CAAC;YACnC,OAAO,WAAW,CAAC;QACrB,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,IAA0D;IAE1D,IAAI,CAAC,IAAI,CAAC,EAAE;QAAE,OAAO,SAAS,CAAC;IAC/B,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,QAAQ,KAAK,EAAE,EAAE,CAAC;QACtD,OAAO,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChC,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,KAAK,qBAAqB,EAAE,CAAC;QACvE,OAAO,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,UAAU,CAAC,OAAgB;IACzC,OAAO,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;AACzC,CAAC"}
package/index.d.ts CHANGED
@@ -6,7 +6,8 @@ export { MAX_ALLOWED_ORIGINS, LINK_TOKEN_PARAM, validateOrigin, chatPath, buildC
6
6
  export { StigmerError, type ErrorCode, isNotFound, isUnauthenticated, isPermissionDenied, isRetryable, isUnimplemented, type ErrorCategory, isConnectError, classifyError, isRetryableError, isTransientStreamError, getUserMessage, type ErrorReason, getErrorReason, type RpcErrorMetadata, annotateRpcError, getRpcMetadata, } from "./errors.js";
7
7
  export { type DeploymentMode, deploymentModeOf, isResourceAvailable, } from "./resource-availability.js";
8
8
  export { ensureMyIdentityAccount, type EnsuredIdentityAccount, type EnsureMyIdentityAccountOptions, type IdentityAccountLane, } from "./ensure-identity-account.js";
9
- export { getGrantableRoles, hasGrantableRoles, isRoleGrantable, } from "./authorization-config.js";
9
+ export { getGrantableRoles, hasGrantableRoles, isRoleGrantable, getTeamGrantableRoles, hasTeamGrantableRoles, isRoleTeamGrantable, } from "./authorization-config.js";
10
+ export { type Grantee, type GranteeKind, personGrantee, teamGrantee, granteeRef, granteeFromView, granteeKey, } from "./iam-principal.js";
10
11
  export { iamRoleToString, iamRoleFromString, iamRoleDisplayName, iamRoleDescription, } from "./iam-role.js";
11
12
  export { IamRole } from "@stigmer/protos/ai/stigmer/iam/v1/enum_pb";
12
13
  export { ActivityClient, type ListRecentActivityParams, type ListRecentActivityResponse, } from "./activity.js";
@@ -32,6 +33,7 @@ export { IamPolicyClient, type IamPolicyInput, type ApiResourceRefInput, } from
32
33
  export { IdentityAccountClient, toIdentityAccountUpdateInput, type IdentityAccountInput, } from "./gen/identityaccount.js";
33
34
  export { InvitationClient, type InvitationInput } from "./gen/invitation.js";
34
35
  export { IdentityProviderClient, toIdentityProviderUpdateInput, type IdentityProviderInput, } from "./gen/identityprovider.js";
36
+ export { TeamClient, toTeamUpdateInput, type TeamInput, } from "./gen/team.js";
35
37
  export { OAuthAppClient, toOAuthAppUpdateInput, type OAuthAppInput, } from "./gen/oauthapp.js";
36
38
  export { McpServerClient, buildMcpServerProto, toMcpServerUpdateInput, type McpServerInput, type StdioServerConfigInput, type HttpServerConfigInput, type ToolApprovalPolicyInput, } from "./gen/mcpserver.js";
37
39
  export { MemoryClient, buildMemoryProto, toMemoryUpdateInput, type MemoryInput, type MemoryProvenanceInput, } from "./gen/memory.js";
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAGrE,OAAO,EACL,eAAe,EACf,SAAS,EACT,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,YAAY,EACZ,KAAK,SAAS,EACd,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,KAAK,aAAa,EAClB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,KAAK,WAAW,EAChB,cAAc,EACd,KAAK,gBAAgB,EACrB,gBAAgB,EAChB,cAAc,GACf,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,KAAK,cAAc,EACnB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AAKpC,OAAO,EACL,uBAAuB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,8BAA8B,EACnC,KAAK,mBAAmB,GACzB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,GAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAC;AAGpE,OAAO,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Available, } from "./resource-availability.
16
16
  // platform builders' own gates).
17
17
  export { ensureMyIdentityAccount, } from "./ensure-identity-account.js";
18
18
  // Authorization config and IAM role utilities
19
- export { getGrantableRoles, hasGrantableRoles, isRoleGrantable, } from "./authorization-config.js";
19
+ export { getGrantableRoles, hasGrantableRoles, isRoleGrantable, getTeamGrantableRoles, hasTeamGrantableRoles, isRoleTeamGrantable, } from "./authorization-config.js";
20
+ export { personGrantee, teamGrantee, granteeRef, granteeFromView, granteeKey, } from "./iam-principal.js";
20
21
  export { iamRoleToString, iamRoleFromString, iamRoleDisplayName, iamRoleDescription, } from "./iam-role.js";
21
22
  export { IamRole } from "@stigmer/protos/ai/stigmer/iam/v1/enum_pb";
22
23
  // Activity client (unified recents)
@@ -52,6 +53,7 @@ export { IamPolicyClient, } from "./gen/iampolicy.js";
52
53
  export { IdentityAccountClient, toIdentityAccountUpdateInput, } from "./gen/identityaccount.js";
53
54
  export { InvitationClient } from "./gen/invitation.js";
54
55
  export { IdentityProviderClient, toIdentityProviderUpdateInput, } from "./gen/identityprovider.js";
56
+ export { TeamClient, toTeamUpdateInput, } from "./gen/team.js";
55
57
  export { OAuthAppClient, toOAuthAppUpdateInput, } from "./gen/oauthapp.js";
56
58
  export { McpServerClient, buildMcpServerProto, toMcpServerUpdateInput, } from "./gen/mcpserver.js";
57
59
  export { MemoryClient, buildMemoryProto, toMemoryUpdateInput, } from "./gen/memory.js";
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAE9B,mBAAmB;AACnB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,iBAAiB;AACjB,OAAO,EAGL,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAK7B,4EAA4E;AAC5E,OAAO,EACL,eAAe,EACf,SAAS,GAGV,MAAM,iBAAiB,CAAC;AAEzB,8DAA8D;AAC9D,OAAO,EACL,m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AoB,EACpB,gBAAgB,GAQjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAmB,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,YAAY,EAA4C,MAAM,iBAAiB,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EACL,cAAc,EACd,qBAAqB,GAMtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,uBAAuB,EACvB,8BAA8B,GAE/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,sBAAsB,EACtB,6BAA6B,GAE9B,MAAM,2BAA2B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stigmer/sdk",
3
- "version": "3.26.0",
3
+ "version": "3.27.0",
4
4
  "description": "Stigmer TypeScript SDK — typed API client for all Stigmer platform resources",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -41,6 +41,6 @@
41
41
  "peerDependencies": {
42
42
  "@bufbuild/protobuf": "^2.0.0",
43
43
  "@connectrpc/connect-node": "^2.0.0",
44
- "@stigmer/protos": "3.26.0"
44
+ "@stigmer/protos": "3.27.0"
45
45
  }
46
46
  }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Pins the grantee vocabulary (`iam-principal.ts`) and the team half of the
3
+ * authorization config (`authorization-config.ts`):
4
+ *
5
+ * - a team is always granted as `team:<id>#member` and a person always
6
+ * unqualified, because the server's revoke matches the qualifier
7
+ * exactly and a dropped `#member` revokes nothing while reporting
8
+ * success;
9
+ * - reading an access-list entry back is the inverse of building one,
10
+ * and anything else (a structural principal, another team qualifier)
11
+ * is refused rather than guessed at;
12
+ * - a team may only ever be offered a subset of a person's roles, never
13
+ * `owner`, and nothing on `organization` (the circular grant the
14
+ * model's membership bound forbids).
15
+ */
16
+ import { describe, expect, it } from "vitest";
17
+ import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
18
+ import { IamRole } from "@stigmer/protos/ai/stigmer/iam/v1/enum_pb";
19
+
20
+ import {
21
+ getGrantableRoles,
22
+ getTeamGrantableRoles,
23
+ hasTeamGrantableRoles,
24
+ isRoleTeamGrantable,
25
+ } from "../authorization-config";
26
+ import { TEAM_GRANTABLE_ROLES } from "../gen/authorization-config";
27
+ import {
28
+ granteeFromView,
29
+ granteeRef,
30
+ personGrantee,
31
+ teamGrantee,
32
+ } from "../iam-principal";
33
+
34
+ describe("granteeRef — the one spelling of a grantee on the wire", () => {
35
+ it("names a team as its members", () => {
36
+ const ref = granteeRef(teamGrantee("tm_sre"));
37
+ expect([ref.kind, ref.id, ref.relation]).toEqual(["team", "tm_sre", "member"]);
38
+ });
39
+
40
+ it("names a person with no relation qualifier", () => {
41
+ const ref = granteeRef(personGrantee("ida_alice"));
42
+ expect([ref.kind, ref.id, ref.relation]).toEqual(["identity_account", "ida_alice", ""]);
43
+ });
44
+ });
45
+
46
+ describe("granteeFromView — reading an access-list entry back", () => {
47
+ it("round-trips both grantees through their wire reference", () => {
48
+ for (const grantee of [teamGrantee("tm_sre"), personGrantee("ida_alice")]) {
49
+ expect(granteeFromView(granteeRef(grantee))).toEqual(grantee);
50
+ }
51
+ });
52
+
53
+ it("refuses what it would misname: a team without its members qualifier, a qualified person, a structural principal, an empty id", () => {
54
+ expect(granteeFromView({ kind: "team", id: "tm_sre", relation: "" })).toBeUndefined();
55
+ expect(granteeFromView({ kind: "team", id: "tm_sre", relation: "maintainer" })).toBeUndefined();
56
+ expect(granteeFromView({ kind: "identity_account", id: "ida_alice", relation: "member" })).toBeUndefined();
57
+ expect(granteeFromView({ kind: "organization", id: "acme", relation: "" })).toBeUndefined();
58
+ expect(granteeFromView({ kind: "identity_account", id: "", relation: "" })).toBeUndefined();
59
+ });
60
+ });
61
+
62
+ describe("team grantable roles", () => {
63
+ it("are, for every kind, a subset of the person's roles and never owner", () => {
64
+ for (const [kind, teamRoles] of TEAM_GRANTABLE_ROLES) {
65
+ const personRoles = getGrantableRoles(kind);
66
+ for (const role of teamRoles) {
67
+ expect(personRoles).toContain(role);
68
+ expect(role).not.toBe(IamRole.owner);
69
+ }
70
+ }
71
+ });
72
+
73
+ it("list nothing on organization, so an organization is never shared with a team", () => {
74
+ expect(hasTeamGrantableRoles(ApiResourceKind.organization)).toBe(false);
75
+ expect(getTeamGrantableRoles(ApiResourceKind.organization)).toEqual([]);
76
+ });
77
+
78
+ it("answer per role on a kind a team may be shared", () => {
79
+ expect(isRoleTeamGrantable(ApiResourceKind.agent, IamRole.viewer)).toBe(true);
80
+ expect(isRoleTeamGrantable(ApiResourceKind.agent, IamRole.owner)).toBe(false);
81
+ });
82
+ });
@@ -1,6 +1,20 @@
1
+ /**
2
+ * Which roles a caller may grant on a resource kind, read from the
3
+ * proto-generated authorization config, so a client offers exactly the
4
+ * grants the server's `ValidateGrantableRole` step accepts.
5
+ *
6
+ * Two grantees, two tables: a person may be granted any role in
7
+ * `GRANTABLE_ROLES`; a team (Enterprise and Cloud) only the roles in
8
+ * `TEAM_GRANTABLE_ROLES`, always a subset of the person's. Each table has
9
+ * the same three readers, so a caller asks the team question with the
10
+ * same shape it asks the person one.
11
+ */
1
12
  import type { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
2
13
  import { IamRole } from "@stigmer/protos/ai/stigmer/iam/v1/enum_pb";
3
- import { GRANTABLE_ROLES } from "./gen/authorization-config.js";
14
+ import {
15
+ GRANTABLE_ROLES,
16
+ TEAM_GRANTABLE_ROLES,
17
+ } from "./gen/authorization-config.js";
4
18
 
5
19
  const EMPTY_ROLES: readonly IamRole[] = Object.freeze([]);
6
20
 
@@ -40,3 +54,36 @@ export function isRoleGrantable(
40
54
  const roles = GRANTABLE_ROLES.get(kind);
41
55
  return roles !== undefined && roles.includes(role);
42
56
  }
57
+
58
+ /**
59
+ * Returns the roles a team may be granted on the given resource kind.
60
+ *
61
+ * An empty array means the kind cannot be shared with a team. Whether the
62
+ * connected edition serves teams at all is a separate question, answered
63
+ * by `isResourceAvailable(ApiResourceKind.team, mode)`.
64
+ */
65
+ export function getTeamGrantableRoles(
66
+ kind: ApiResourceKind,
67
+ ): readonly IamRole[] {
68
+ return TEAM_GRANTABLE_ROLES.get(kind) ?? EMPTY_ROLES;
69
+ }
70
+
71
+ /**
72
+ * Whether the given resource kind can be shared with a team at all.
73
+ */
74
+ export function hasTeamGrantableRoles(kind: ApiResourceKind): boolean {
75
+ const roles = TEAM_GRANTABLE_ROLES.get(kind);
76
+ return roles !== undefined && roles.length > 0;
77
+ }
78
+
79
+ /**
80
+ * Whether a team may be granted the given role on the given resource kind
81
+ * — the team arm of the backend's `ValidateGrantableRole` step.
82
+ */
83
+ export function isRoleTeamGrantable(
84
+ kind: ApiResourceKind,
85
+ role: IamRole,
86
+ ): boolean {
87
+ const roles = TEAM_GRANTABLE_ROLES.get(kind);
88
+ return roles !== undefined && roles.includes(role);
89
+ }
@@ -17,6 +17,7 @@ export const GRANTABLE_ROLES: ReadonlyMap<ApiResourceKind, readonly IamRole[]> =
17
17
  [ApiResourceKind.identity_provider, [IamRole.owner, IamRole.viewer]],
18
18
  [ApiResourceKind.oauth_app, [IamRole.owner, IamRole.viewer]],
19
19
  [ApiResourceKind.platform_client, [IamRole.owner, IamRole.viewer]],
20
+ [ApiResourceKind.team, [IamRole.member]],
20
21
  [ApiResourceKind.organization, [IamRole.owner, IamRole.admin, IamRole.member, IamRole.viewer]],
21
22
  [ApiResourceKind.agent, [IamRole.owner, IamRole.viewer]],
22
23
  [ApiResourceKind.session, [IamRole.owner, IamRole.viewer]],
@@ -34,3 +35,26 @@ export const GRANTABLE_ROLES: ReadonlyMap<ApiResourceKind, readonly IamRole[]> =
34
35
  [ApiResourceKind.schedule, [IamRole.owner, IamRole.viewer]],
35
36
  [ApiResourceKind.plugin, [IamRole.owner, IamRole.viewer]],
36
37
  ]);
38
+
39
+ /**
40
+ * Roles that can be granted on each resource kind to a team, so every
41
+ * member of the team holds the role.
42
+ *
43
+ * Source of truth: api_resource_kind.proto — team_grantable_roles in each
44
+ * kind's AuthorizationConfig, always a subset of grantable_roles.
45
+ *
46
+ * Kinds not in this map cannot be shared with a team. Teams are served by
47
+ * the Enterprise and Cloud editions.
48
+ */
49
+ export const TEAM_GRANTABLE_ROLES: ReadonlyMap<ApiResourceKind, readonly IamRole[]> = new Map([
50
+ [ApiResourceKind.agent, [IamRole.viewer]],
51
+ [ApiResourceKind.skill, [IamRole.viewer]],
52
+ [ApiResourceKind.mcp_server, [IamRole.viewer]],
53
+ [ApiResourceKind.agent_instance, [IamRole.viewer]],
54
+ [ApiResourceKind.agent_channel, [IamRole.viewer, IamRole.participant]],
55
+ [ApiResourceKind.workflow, [IamRole.viewer]],
56
+ [ApiResourceKind.workflow_instance, [IamRole.viewer]],
57
+ [ApiResourceKind.workflow_execution, [IamRole.viewer]],
58
+ [ApiResourceKind.schedule, [IamRole.viewer]],
59
+ [ApiResourceKind.plugin, [IamRole.viewer]],
60
+ ]);
package/src/gen/client.ts CHANGED
@@ -27,6 +27,7 @@ import { ScheduleClient } from "./schedule.js";
27
27
  import { SessionClient } from "./session.js";
28
28
  import { SkillClient } from "./skill.js";
29
29
  import { SubscriptionClient } from "./subscription.js";
30
+ import { TeamClient } from "./team.js";
30
31
  import { WorkflowClient } from "./workflow.js";
31
32
  import { WorkflowExecutionClient } from "./workflowexecution.js";
32
33
  import { WorkflowInstanceClient } from "./workflowinstance.js";
@@ -59,6 +60,7 @@ export class GeneratedClient {
59
60
  readonly session: SessionClient;
60
61
  readonly skill: SkillClient;
61
62
  readonly subscription: SubscriptionClient;
63
+ readonly team: TeamClient;
62
64
  readonly workflow: WorkflowClient;
63
65
  readonly workflowExecution: WorkflowExecutionClient;
64
66
  readonly workflowInstance: WorkflowInstanceClient;
@@ -90,6 +92,7 @@ export class GeneratedClient {
90
92
  this.session = new SessionClient(transport);
91
93
  this.skill = new SkillClient(transport);
92
94
  this.subscription = new SubscriptionClient(transport);
95
+ this.team = new TeamClient(transport);
93
96
  this.workflow = new WorkflowClient(transport);
94
97
  this.workflowExecution = new WorkflowExecutionClient(transport);
95
98
  this.workflowInstance = new WorkflowInstanceClient(transport);
@@ -149,6 +152,8 @@ export { SkillClient } from "./skill.js";
149
152
  export { type SkillInput } from "./skill.js";
150
153
  export { SubscriptionClient } from "./subscription.js";
151
154
  export { type SubscriptionInput } from "./subscription.js";
155
+ export { TeamClient } from "./team.js";
156
+ export { type TeamInput } from "./team.js";
152
157
  export { WorkflowClient } from "./workflow.js";
153
158
  export { type WorkflowInput, type WorkflowDocumentInput, type WorkflowTaskInput, type ExportInput, type FlowControlInput, type WorkflowBudgetInput } from "./workflow.js";
154
159
  export { WorkflowExecutionClient } from "./workflowexecution.js";
@@ -20,6 +20,7 @@ export const KIND_TIERS: ReadonlyMap<ApiResourceKind, ResourceTier> = new Map([
20
20
  [ApiResourceKind.identity_provider, ResourceTier.enterprise],
21
21
  [ApiResourceKind.oauth_app, ResourceTier.open_source],
22
22
  [ApiResourceKind.platform_client, ResourceTier.open_source],
23
+ [ApiResourceKind.team, ResourceTier.enterprise],
23
24
  [ApiResourceKind.organization, ResourceTier.open_source],
24
25
  [ApiResourceKind.platform, ResourceTier.enterprise],
25
26
  [ApiResourceKind.agent, ResourceTier.open_source],
@@ -0,0 +1,132 @@
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 { type DeleteResourceInput, type ResourceRef } from "./types.js";
6
+ import { create } from "@bufbuild/protobuf";
7
+ import { createClient, type Client, type Transport } from "@connectrpc/connect";
8
+ import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
9
+ import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
10
+ import { ApiResourceIdSchema, ApiResourceReferenceSchema, ApiResourceDeleteInputSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
11
+ import { ApiResourceMetadataSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
12
+ import { TeamSchema, type Team } from "@stigmer/protos/ai/stigmer/iam/team/v1/api_pb";
13
+ import { TeamCommandController } from "@stigmer/protos/ai/stigmer/iam/team/v1/command_pb";
14
+ import { ListTeamsByOrgInputSchema, TeamsSchema, type ListTeamsByOrgInput, type Teams } from "@stigmer/protos/ai/stigmer/iam/team/v1/io_pb";
15
+ import { TeamQueryController } from "@stigmer/protos/ai/stigmer/iam/team/v1/query_pb";
16
+ import { TeamSpecSchema } from "@stigmer/protos/ai/stigmer/iam/team/v1/spec_pb";
17
+
18
+ /** Provides operations on team resources. */
19
+ export class TeamClient {
20
+ private readonly command: Client<typeof TeamCommandController>;
21
+ private readonly query: Client<typeof TeamQueryController>;
22
+
23
+ constructor(transport: Transport) {
24
+ this.command = createClient(TeamCommandController, transport);
25
+ this.query = createClient(TeamQueryController, transport);
26
+ }
27
+
28
+ async create(input: TeamInput): Promise<Team> {
29
+ try {
30
+ return await this.command.create(buildTeamProto(input));
31
+ } catch (e) { throw wrapError(e); }
32
+ }
33
+
34
+ async update(input: TeamInput): Promise<Team> {
35
+ try {
36
+ return await this.command.update(buildTeamProto(input));
37
+ } catch (e) { throw wrapError(e); }
38
+ }
39
+
40
+ async delete(input: DeleteResourceInput): Promise<Team> {
41
+ try {
42
+ return await this.command.delete(create(ApiResourceDeleteInputSchema, {
43
+ resourceId: input.resourceId,
44
+ versionMessage: input.versionMessage,
45
+ force: input.force,
46
+ }));
47
+ } catch (e) { throw wrapError(e); }
48
+ }
49
+
50
+ async get(id: string): Promise<Team> {
51
+ try {
52
+ return await this.query.get(create(ApiResourceIdSchema, { value: id }));
53
+ } catch (e) { throw wrapError(e); }
54
+ }
55
+
56
+ async getByReference(ref: ResourceRef): Promise<Team> {
57
+ try {
58
+ return await this.query.getByReference(create(ApiResourceReferenceSchema, { ...ref, kind: ApiResourceKind.team }));
59
+ } catch (e) { throw wrapError(e); }
60
+ }
61
+
62
+ async listByOrg(input: ListTeamsByOrgInput): Promise<Teams> {
63
+ try {
64
+ return await this.query.listByOrg(input);
65
+ } catch (e) { throw wrapError(e); }
66
+ }
67
+ }
68
+
69
+ /** Input for creating/updating a Team. */
70
+ export interface TeamInput {
71
+ /**
72
+ * The resource's `metadata.id`, for exact update addressing when set
73
+ * from a loaded resource. Required for updates to platform-scoped
74
+ * (org-less) kinds, where the org+slug fallback cannot match. On
75
+ * create, the cloud server stamps its own id regardless; the OSS
76
+ * server honors a caller-supplied id (existing apply semantics).
77
+ */
78
+ id?: string;
79
+ name: string;
80
+ slug?: string;
81
+ org: string;
82
+ labels?: Record<string, string>;
83
+ visibility?: ApiResourceVisibility;
84
+ description?: string;
85
+ }
86
+
87
+ export function buildTeamProto(input: TeamInput): Team {
88
+ return Object.assign(create(TeamSchema), {
89
+ apiVersion: "iam.stigmer.ai/v1",
90
+ kind: "Team",
91
+ metadata: Object.assign(create(ApiResourceMetadataSchema), {
92
+ ...(input.id && { id: input.id }),
93
+ name: input.name,
94
+ org: input.org,
95
+ ...(input.slug && { slug: input.slug }),
96
+ ...(input.labels && { labels: input.labels }),
97
+ ...(input.visibility && { visibility: input.visibility }),
98
+ }),
99
+ spec: Object.assign(create(TeamSpecSchema), stripUndefined({
100
+ description: input.description,
101
+ })),
102
+ }) as Team;
103
+ }
104
+
105
+ /**
106
+ * Maps a fetched {@link Team} to a complete {@link TeamInput} for `update()`.
107
+ *
108
+ * The update RPC replaces the ENTIRE spec — spread this mapper's output
109
+ * and override only the fields you edit (spread nested objects the same
110
+ * way):
111
+ *
112
+ * await client.update({ ...toTeamUpdateInput(res), description: next });
113
+ *
114
+ * Proto3 defaults normalize to `undefined`; resource references keep
115
+ * `version` (pinned refs) and `kind`.
116
+ */
117
+ export function toTeamUpdateInput(resource: Team): TeamInput {
118
+ const meta = resource.metadata;
119
+ const spec = resource.spec ?? create(TeamSpecSchema);
120
+ return {
121
+ // Exact update addressing (id-first in the update pipeline) — for
122
+ // platform-scoped (org-less) kinds the org+slug fallback cannot
123
+ // match, so the id is the ONLY working address.
124
+ id: meta?.id || undefined,
125
+ name: meta?.name ?? "",
126
+ slug: meta?.slug || undefined,
127
+ org: meta?.org ?? "",
128
+ labels: meta?.labels && Object.keys(meta.labels).length > 0 ? { ...meta.labels } : undefined,
129
+ visibility: meta?.visibility || undefined,
130
+ description: spec.description || undefined,
131
+ };
132
+ }
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Who an IAM policy grants a role to: a person or a team, in one shape a
3
+ * client builds grants from and reads access lists back into.
4
+ *
5
+ * The wire spells a grantee as an `ApiResourceRef`: a person is
6
+ * `identity_account:<id>` with no relation qualifier, a team is
7
+ * `team:<id>#member` (every member of the team holds the grant). This
8
+ * module is the one place in the SDK that knows that spelling, so no caller
9
+ * writes the qualifier by hand and no caller can drop it.
10
+ *
11
+ * Reading goes through the same module: `granteeFromView` turns an access
12
+ * list entry back into a `Grantee` and answers `undefined` for anything it
13
+ * does not recognise (another kind, a team with a qualifier other than
14
+ * `member`), so a client never acts on a principal it would misname. A
15
+ * revoke built from the returned grantee names the exact row the list
16
+ * showed, because the server's revoke matches the qualifier exactly.
17
+ */
18
+ import { create } from "@bufbuild/protobuf";
19
+ import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
20
+ import type { ApiResourceRefView } from "@stigmer/protos/ai/stigmer/iam/iampolicy/v1/io_pb";
21
+ import {
22
+ type ApiResourceRef,
23
+ ApiResourceRefSchema,
24
+ } from "@stigmer/protos/ai/stigmer/iam/iampolicy/v1/spec_pb";
25
+
26
+ const PERSON_KIND = ApiResourceKind[ApiResourceKind.identity_account];
27
+ const TEAM_KIND = ApiResourceKind[ApiResourceKind.team];
28
+
29
+ /** The relation that makes every member of a team the grantee. */
30
+ const TEAM_MEMBERS_RELATION = "member";
31
+
32
+ /** A person or a team an IAM policy can grant a role to. */
33
+ export type Grantee =
34
+ | { readonly kind: "identity_account"; readonly id: string }
35
+ | { readonly kind: "team"; readonly id: string };
36
+
37
+ /** The kind of a {@link Grantee}. */
38
+ export type GranteeKind = Grantee["kind"];
39
+
40
+ /** A person, by identity account id (`ida_...`). */
41
+ export function personGrantee(id: string): Grantee {
42
+ return { kind: "identity_account", id };
43
+ }
44
+
45
+ /** A team, by team id (`tm_...`). */
46
+ export function teamGrantee(id: string): Grantee {
47
+ return { kind: "team", id };
48
+ }
49
+
50
+ /**
51
+ * The `ApiResourceRef` an IAM policy spec names the grantee with: a person
52
+ * unqualified, a team as its members.
53
+ */
54
+ export function granteeRef(grantee: Grantee): ApiResourceRef {
55
+ switch (grantee.kind) {
56
+ case "identity_account":
57
+ return create(ApiResourceRefSchema, { kind: PERSON_KIND, id: grantee.id });
58
+ case "team":
59
+ return create(ApiResourceRefSchema, {
60
+ kind: TEAM_KIND,
61
+ id: grantee.id,
62
+ relation: TEAM_MEMBERS_RELATION,
63
+ });
64
+ default: {
65
+ const unreachable: never = grantee;
66
+ return unreachable;
67
+ }
68
+ }
69
+ }
70
+
71
+ /**
72
+ * The grantee an access-list entry names, or `undefined` when the entry
73
+ * is not a person or a team's members (a structural principal, a kind this
74
+ * SDK does not know, or a team qualifier other than `member`).
75
+ */
76
+ export function granteeFromView(
77
+ view: Pick<ApiResourceRefView, "kind" | "id" | "relation">,
78
+ ): Grantee | undefined {
79
+ if (!view.id) return undefined;
80
+ if (view.kind === PERSON_KIND && view.relation === "") {
81
+ return personGrantee(view.id);
82
+ }
83
+ if (view.kind === TEAM_KIND && view.relation === TEAM_MEMBERS_RELATION) {
84
+ return teamGrantee(view.id);
85
+ }
86
+ return undefined;
87
+ }
88
+
89
+ /** A stable key for a grantee: its kind and id. */
90
+ export function granteeKey(grantee: Grantee): string {
91
+ return `${grantee.kind}:${grantee.id}`;
92
+ }