@vess-id/ai-identity 0.12.0 → 0.14.0-alpha.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 (54) hide show
  1. package/dist/index.d.mts +1230 -8
  2. package/dist/index.d.ts +11 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +571 -27
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +558 -27
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/policy/__tests__/cedar-engine.spec.d.ts +17 -0
  9. package/dist/policy/__tests__/cedar-engine.spec.d.ts.map +1 -0
  10. package/dist/policy/__tests__/cedar-entities.spec.d.ts +14 -0
  11. package/dist/policy/__tests__/cedar-entities.spec.d.ts.map +1 -0
  12. package/dist/policy/__tests__/decision-enum.spec.d.ts +16 -0
  13. package/dist/policy/__tests__/decision-enum.spec.d.ts.map +1 -0
  14. package/dist/policy/cedar-engine.d.ts +334 -0
  15. package/dist/policy/cedar-engine.d.ts.map +1 -0
  16. package/dist/policy/cedar-entities.d.ts +59 -0
  17. package/dist/policy/cedar-entities.d.ts.map +1 -0
  18. package/dist/policy/decision.d.ts +46 -0
  19. package/dist/policy/decision.d.ts.map +1 -0
  20. package/dist/policy/index.d.ts +15 -0
  21. package/dist/policy/index.d.ts.map +1 -0
  22. package/dist/registry/__tests__/action-registry-validation.spec.d.ts +13 -0
  23. package/dist/registry/__tests__/action-registry-validation.spec.d.ts.map +1 -0
  24. package/dist/registry/__tests__/action-risk-registry-driven.spec.d.ts +15 -0
  25. package/dist/registry/__tests__/action-risk-registry-driven.spec.d.ts.map +1 -0
  26. package/dist/registry/__tests__/action-risk.spec.d.ts +17 -0
  27. package/dist/registry/__tests__/action-risk.spec.d.ts.map +1 -0
  28. package/dist/registry/action-registry-json.d.ts +398 -0
  29. package/dist/registry/action-registry-json.d.ts.map +1 -1
  30. package/dist/registry/action-registry.d.ts +1 -1
  31. package/dist/registry/action-registry.d.ts.map +1 -1
  32. package/dist/registry/action-risk.d.ts +47 -0
  33. package/dist/registry/action-risk.d.ts.map +1 -0
  34. package/dist/registry/action-summary.d.ts.map +1 -1
  35. package/dist/types/__tests__/cedar-policy.spec.d.ts +8 -0
  36. package/dist/types/__tests__/cedar-policy.spec.d.ts.map +1 -0
  37. package/dist/types/__tests__/permission-vc-v3.spec.d.ts +9 -0
  38. package/dist/types/__tests__/permission-vc-v3.spec.d.ts.map +1 -0
  39. package/dist/types/__tests__/phase1-vc-factory.spec.d.ts +9 -0
  40. package/dist/types/__tests__/phase1-vc-factory.spec.d.ts.map +1 -0
  41. package/dist/types/__tests__/policy-ref.spec.d.ts +9 -0
  42. package/dist/types/__tests__/policy-ref.spec.d.ts.map +1 -0
  43. package/dist/types/cedar-policy.d.ts +60 -0
  44. package/dist/types/cedar-policy.d.ts.map +1 -0
  45. package/dist/types/grant.d.ts +69 -0
  46. package/dist/types/grant.d.ts.map +1 -1
  47. package/dist/types/index.d.ts +1 -0
  48. package/dist/types/index.d.ts.map +1 -1
  49. package/dist/types/jira.d.ts +57 -0
  50. package/dist/types/jira.d.ts.map +1 -1
  51. package/dist/types/permission-vc.d.ts +236 -6
  52. package/dist/types/permission-vc.d.ts.map +1 -1
  53. package/dist/types/tier.d.ts.map +1 -1
  54. package/package.json +2 -1
package/dist/index.d.mts CHANGED
@@ -842,13 +842,85 @@ interface PermissionConstraints {
842
842
  */
843
843
  targets?: TargetConstraint[];
844
844
  }
845
+ /**
846
+ * Inline policy mode — full Cedar policy embedded in the VC.
847
+ *
848
+ * Used for sub-agent re-delegation where the verifier cannot reach the
849
+ * Policy Registry over the network. The inline policy is authoritative;
850
+ * `policy_hash` is a sanity check for tamper-evidence.
851
+ *
852
+ * Spec refs:
853
+ * - docs/specs/2026-05-23-cedar-rar-permission-redesign.md §3.2
854
+ */
855
+ interface PolicyRefInline {
856
+ mode: 'inline';
857
+ /** Full Cedar policy source (PolicySet text, UTF-8). */
858
+ policy_inline: string;
859
+ /** sha256 of `policy_inline` (hex), prefixed `sha256-` for tamper-evidence. */
860
+ policy_hash: string;
861
+ /**
862
+ * Cedar schema fragment id. **Phase 1 unused** (Cedar wasm schema-less
863
+ * evaluation, Implementation plan §1.1). **Phase 2+ で per-policy schema
864
+ * 切替時に inline モードでは REQUIRED 化** (reference モードは Registry
865
+ * resolve で取得できるため optional のまま).
866
+ */
867
+ schema_id?: string;
868
+ }
869
+ /**
870
+ * Reference policy mode — policy lives in the Policy Registry.
871
+ *
872
+ * The verifier fetches `policy_uri` (must match the issuer's
873
+ * `/.well-known/policy-registry/:policy_id`), validates `policy_hash`,
874
+ * and evaluates the fetched Cedar policy.
875
+ *
876
+ * Spec refs:
877
+ * - docs/specs/2026-05-23-cedar-rar-permission-redesign.md §3.2
878
+ */
879
+ interface PolicyRefReference {
880
+ mode: 'reference';
881
+ /** Policy Registry id. Format: `pol_<project_id>_<uuidv7>`. */
882
+ policy_id: string;
883
+ /** Absolute URL to `/.well-known/policy-registry/:policy_id`. */
884
+ policy_uri: string;
885
+ /** sha256 of the served Cedar policy text (hex), prefixed `sha256-`. */
886
+ policy_hash: string;
887
+ /**
888
+ * Cedar schema fragment id. Phase 1 unused (Registry resolve で取得可能、
889
+ * schema-less evaluation を使う簡易構成)。Phase 2+ で per-policy schema を
890
+ * 導入したときも reference モードは引き続き OPTIONAL — VC payload に
891
+ * 同梱せず Registry 側で resolve する方針。
892
+ */
893
+ schema_id?: string;
894
+ }
895
+ /**
896
+ * Tagged union of policy reference shapes. Discriminator: `mode`.
897
+ *
898
+ * Use {@link isPolicyRefInline} / {@link isPolicyRefReference} for runtime
899
+ * narrowing.
900
+ */
901
+ type PolicyRef = PolicyRefInline | PolicyRefReference;
902
+ /** Type guard for {@link PolicyRefInline}. */
903
+ declare function isPolicyRefInline(ref: PolicyRef): ref is PolicyRefInline;
904
+ /** Type guard for {@link PolicyRefReference}. */
905
+ declare function isPolicyRefReference(ref: PolicyRef): ref is PolicyRefReference;
845
906
  /**
846
907
  * Permission Rule - the atomic unit of authorization.
847
908
  *
848
909
  * Each rule grants specific actions on specific resources for a specific provider.
849
910
  * Rules are evaluated independently during policy evaluation.
850
911
  *
851
- * OPA mapping:
912
+ * Phase 1 (Cedar + RAR redesign) extensions:
913
+ * - `effect` widened from `'allow'` only to the 3-valued
914
+ * `'allow' | 'deny' | 'require_approval'` (spec §5).
915
+ * Existing call-sites that only used `'allow'` remain source-compatible.
916
+ * - `priority` field added (optional, used for deterministic ordering when
917
+ * multiple rules match the same request).
918
+ * - `policy_ref` field added (optional in Phase 1 for backward-compat
919
+ * during migration; Phase 2+ will bump the schema to v3.1 and make it
920
+ * required — see spec §3.1 reconciliation note).
921
+ *
922
+ * OPA mapping (legacy `'allow'`-only path, still used while
923
+ * `CEDAR_POLICY_ENABLED != enforce`):
852
924
  * ```rego
853
925
  * allow {
854
926
  * some rule in input.credentials.delegates
@@ -864,8 +936,19 @@ interface PermissionConstraints {
864
936
  interface PermissionRule {
865
937
  /** Rule identifier (for audit trail and matched_rule_id) */
866
938
  id?: string;
867
- /** Effect: 'allow' only in MVP. Future: 'deny' for deny-override patterns. */
868
- effect: 'allow';
939
+ /**
940
+ * Effect. Phase 1 widens this beyond legacy `'allow'`-only:
941
+ * - `'allow'` — permit the action (legacy default).
942
+ * - `'deny'` — explicit deny (override precedence over allow).
943
+ * - `'require_approval'` — pause and request human approval.
944
+ */
945
+ effect: 'allow' | 'deny' | 'require_approval';
946
+ /**
947
+ * Optional priority for deterministic ordering when multiple rules match.
948
+ * Higher priority wins. Phase 1 evaluator behaviour is unchanged when
949
+ * `priority` is absent.
950
+ */
951
+ priority?: number;
869
952
  /** Service provider */
870
953
  provider: Provider | string;
871
954
  /** Target resource */
@@ -874,20 +957,34 @@ interface PermissionRule {
874
957
  actions: string[];
875
958
  /** Rule-level constraints */
876
959
  constraints?: PermissionConstraints;
960
+ /**
961
+ * Cedar policy binding (Phase 1).
962
+ *
963
+ * When present, the policy engine evaluates this delegate via the
964
+ * referenced / inlined Cedar policy in addition to the static constraint
965
+ * check. Optional in Phase 1 for backward-compat during migration; Phase
966
+ * 2+ will bump the schema to v3.1 and make it required.
967
+ */
968
+ policy_ref?: PolicyRef;
877
969
  }
878
970
  /**
879
- * Permission VC Claims - the canonical credential claims format.
971
+ * Permission VC Claims v2 the pre-Cedar canonical credential claims format.
880
972
  *
881
973
  * This is what gets signed into the SD-JWT VC. All VC issuance paths
882
974
  * (VCService, RemoteVCIssuerService, PermissionVCManager) MUST produce
883
- * claims conforming to this interface.
975
+ * claims conforming to either this interface or {@link PermissionVcClaims_V3}.
884
976
  *
885
977
  * The Grant → VC normalization layer converts:
886
978
  * - GrantResource[] + actions[] → PermissionRule[]
887
979
  * - GrantConstraints → PermissionConstraints (per-rule)
888
980
  * - Grant metadata → top-level claims fields
981
+ *
982
+ * @remarks Phase 1 Step 2 renamed the original `PermissionVcClaims` to
983
+ * `PermissionVcClaims_V2`. The exported alias {@link PermissionVcClaims}
984
+ * is now a union of V2 + {@link PermissionVcClaims_V3}, preserving
985
+ * existing import sites (they will accept both shapes).
889
986
  */
890
- interface PermissionVcClaims {
987
+ interface PermissionVcClaims_V2 {
891
988
  /** Schema version */
892
989
  v: '2';
893
990
  /** Credential type discriminator */
@@ -930,6 +1027,86 @@ interface PermissionVcClaims {
930
1027
  /** Delegated permission rules (the core authorization data) */
931
1028
  delegates: PermissionRule[];
932
1029
  }
1030
+ /**
1031
+ * Permission VC Claims v3 — Cedar + RAR Phase 1 schema.
1032
+ *
1033
+ * Inherits all V2 fields and adds two Phase-1-aware extensions:
1034
+ * - `cedar_schema_ref?` — pointer to the Cedar schema fragment the
1035
+ * delegates were authored against. **Phase 1 unused** (the SDK ships a
1036
+ * single global schema fragment generated by connector-plugin codegen,
1037
+ * per Implementation plan §1.1). Reserved for Phase 2+ per-policy schema
1038
+ * switching.
1039
+ * - `layer?` — chain hierarchy layer. **Phase 2+ only**; Phase 1 issuance
1040
+ * pins this to `'agent_permission'` via {@link buildPhase1VcClaims}.
1041
+ * Direct assignment is discouraged (ESLint rule planned in Step 5).
1042
+ *
1043
+ * Spec refs:
1044
+ * - docs/specs/2026-05-23-cedar-rar-permission-redesign.md §3.1
1045
+ * - docs/specs/2026-05-23-cedar-rar-implementation-plan-phase1.md Task 2.1 / 2.5
1046
+ */
1047
+ /**
1048
+ * Bug B 真因修正 (β, 2026-05-28) — VC=mandate semantic を invoke 時 Cedar も
1049
+ * 信じるため、approval の事実 (誰がいつ何を approve したか) を VC に焼き込む
1050
+ * signed self-attestation。SD-protected (`_sd` 経由 disclosure)、SD-JWT 署名で
1051
+ * 改竄不可。invoke 時 Cedar context.approval の最優先 source として採用。
1052
+ *
1053
+ * Forward compat: A2A AP2 Mandate (IntentMandate / CartMandate / PaymentMandate)
1054
+ * との projection は Phase 2 spec で別途定義。本 field 名は内部
1055
+ * ApprovalContext (snake_case) と一貫。
1056
+ *
1057
+ * Spec ref: docs/superpowers/plans/2026-05-28-bug-b-fix-beta-vc-embed-approval.md
1058
+ */
1059
+ interface VcApprovalClaim {
1060
+ /** `req_<uuid>` — 元 approval-request id (claimVC 元 request の id)。 */
1061
+ request_id: string;
1062
+ /** `outcome_<uuid>` — APPROVAL_OUTCOME audit event id (§11.1 join key)。 */
1063
+ outcome_id: string;
1064
+ /** approver の user id、または 'system' (auto-approve 経路)。最大 128 chars。 */
1065
+ granted_by: string;
1066
+ /** ISO-8601 timestamp of the approval action. */
1067
+ granted_at: string;
1068
+ }
1069
+ interface PermissionVcClaims_V3 extends Omit<PermissionVcClaims_V2, 'v'> {
1070
+ /** Schema version — v3 adds Cedar policy_ref support and chain hierarchy fields. */
1071
+ v: '3';
1072
+ /**
1073
+ * Cedar schema fragment reference (Phase 2+ per-policy schema switching).
1074
+ * Phase 1: unused; SDK uses connector-plugin codegen global schema.
1075
+ */
1076
+ cedar_schema_ref?: {
1077
+ /** e.g. `cedar_schema_2026_05_23_v1`. */
1078
+ schema_id: string;
1079
+ /** sha256 of the schema fragment (hex). */
1080
+ schema_hash: string;
1081
+ };
1082
+ /**
1083
+ * 4-layer chain (Org Policy → User Grant → Agent Permission → Sub-Agent Delegation).
1084
+ * Phase 1 では `buildPhase1VcClaims()` factory 経由で `'agent_permission'` が固定セットされる。
1085
+ * Phase 2+ では本フィールドを **required** に格上げする予定 (V3.1 schema)。
1086
+ * 直接代入は禁止 (Phase 1 では factory を使うこと、Phase 2+ では ESLint rule で強制)。
1087
+ * 詳細: design spec §3.1, §6.1 / Phase 1 plan Task 2.5。
1088
+ */
1089
+ layer?: 'org_policy' | 'user_grant' | 'agent_permission' | 'sub_agent_delegation';
1090
+ /**
1091
+ * Bug B 真因修正 (β, 2026-05-28) — approval メタを VC に焼き込む。
1092
+ * VC=mandate なので「この VC が発行されたこと自体が approve の証拠」だが、
1093
+ * invoke 時 Cedar に `context.approval.granted == true` を渡せるよう
1094
+ * back-ref を明示。本 field 不在 = base path (legacy 互換、Cedar は token-
1095
+ * ledger 経由 fallback)。{@link VcApprovalClaim} 参照。
1096
+ */
1097
+ approval?: VcApprovalClaim;
1098
+ }
1099
+ /**
1100
+ * Permission VC Claims (canonical union of v2 + v3).
1101
+ *
1102
+ * All existing import sites referencing `PermissionVcClaims` continue to
1103
+ * compile because:
1104
+ * - Code that only produced V2 still produces a value assignable to the
1105
+ * union.
1106
+ * - Code that consumes the union can narrow on `claims.v === '3'` to
1107
+ * access V3-only fields.
1108
+ */
1109
+ type PermissionVcClaims = PermissionVcClaims_V2 | PermissionVcClaims_V3;
933
1110
  /**
934
1111
  * Build synchronized grant_id / grant_ids fields for PermissionVcClaims.
935
1112
  * Guarantees grant_id === grant_ids[0].
@@ -1088,6 +1265,59 @@ declare function parseGrantAction(grantAction: string): {
1088
1265
  provider: string;
1089
1266
  action: string;
1090
1267
  };
1268
+ /**
1269
+ * The single layer value Phase 1 VC issuance is allowed to emit.
1270
+ *
1271
+ * companion design spec §3.1 defines a 4-layer enum
1272
+ * (`'org_policy' | 'user_grant' | 'agent_permission' | 'sub_agent_delegation'`),
1273
+ * but Phase 1 only issues at the `agent_permission` layer. The other 3
1274
+ * layers unlock in Phase 2+.
1275
+ *
1276
+ * Spec refs:
1277
+ * - docs/specs/2026-05-23-cedar-rar-implementation-plan-phase1.md Task 2.5 (rev 5)
1278
+ * - docs/specs/2026-05-23-cedar-rar-permission-redesign.md §3.1 Phase 1 layer 固定 note
1279
+ */
1280
+ declare const PHASE_1_VC_LAYER: "agent_permission";
1281
+ /** Literal type of {@link PHASE_1_VC_LAYER}. */
1282
+ type Phase1VcLayer = typeof PHASE_1_VC_LAYER;
1283
+ /**
1284
+ * Build a {@link PermissionVcClaims_V3} object with `layer` pinned to
1285
+ * {@link PHASE_1_VC_LAYER} (`'agent_permission'`).
1286
+ *
1287
+ * **This factory is mandatory for Phase 1 VC issuance.** Direct assignment
1288
+ * of `layer` on a V3 claims literal is discouraged and will be guarded by
1289
+ * an ESLint rule once Step 5 wires usage in
1290
+ * `packages/api/src/grant/services/remote-vc-issuer.service.ts`. Phase 2+
1291
+ * will relax or delete this factory when the other 3 layers unlock.
1292
+ *
1293
+ * The input `base` type explicitly omits `layer` so passing it is a
1294
+ * compile-time error — guaranteeing call-sites cannot accidentally
1295
+ * smuggle a non-Phase-1 layer value through.
1296
+ *
1297
+ * @example
1298
+ * ```ts
1299
+ * import { buildPhase1VcClaims } from '@vess-id/ai-identity'
1300
+ *
1301
+ * const claims = buildPhase1VcClaims({
1302
+ * v: '3',
1303
+ * type: 'PermissionCredential',
1304
+ * iss: userDid,
1305
+ * sub: agentDid,
1306
+ * iat: now,
1307
+ * exp: now + 3600,
1308
+ * jti,
1309
+ * project_id,
1310
+ * grant_ids,
1311
+ * grant_id,
1312
+ * session_id,
1313
+ * delegates,
1314
+ * })
1315
+ * // claims.layer is type-narrowed to 'agent_permission'
1316
+ * ```
1317
+ */
1318
+ declare function buildPhase1VcClaims(base: Omit<PermissionVcClaims_V3, 'layer'>): PermissionVcClaims_V3 & {
1319
+ layer: Phase1VcLayer;
1320
+ };
1091
1321
 
1092
1322
  /**
1093
1323
  * Grant(許可)関連の型定義
@@ -1345,6 +1575,27 @@ interface GrantConstraints {
1345
1575
  targets?: TargetConstraint[];
1346
1576
  /** 自動承認設定 */
1347
1577
  autoApprove?: AutoApproveConfig;
1578
+ /**
1579
+ * Cedar 一元化 Step 4 — data-in-policy 許可パターン (Cedar `like` wildcard).
1580
+ *
1581
+ * 例: `["*@vess.id", "*@vesslabs.ai"]` → 各 recipient.address に対し
1582
+ * `like "*@vess.id" || like "*@vesslabs.ai"` の Cedar permit rule が emit される.
1583
+ *
1584
+ * Spec: docs/specs/2026-05-24-cedar-unification-design.md §4.1 / §13 Step 4
1585
+ *
1586
+ * Phase 1 では primarily Gmail recipient address のために使う (recipient.address).
1587
+ * Phase 2+ で per-target-binding な格納先 (channel.id 等) に拡張する.
1588
+ */
1589
+ allow_patterns?: string[];
1590
+ /**
1591
+ * Cedar 一元化 Step 4 — data-in-policy 拒否パターン (Cedar `like` wildcard).
1592
+ *
1593
+ * 例: `["*@competitor.com"]` → 該当 recipient で Cedar `forbid` rule が emit される.
1594
+ * Cedar forbid-overrides-permit semantics により approval があっても denied.
1595
+ *
1596
+ * Spec: docs/specs/2026-05-24-cedar-unification-design.md §4.1 / §4.2 / §13 Step 4
1597
+ */
1598
+ deny_patterns?: string[];
1348
1599
  }
1349
1600
  /**
1350
1601
  * Grant作成リクエスト
@@ -1523,6 +1774,54 @@ declare function grantConstraintsToPermissionConstraints(constraints: GrantConst
1523
1774
  * ```
1524
1775
  */
1525
1776
  declare function grantToPermissionRules(resources: GrantResource[], actions: string[], constraints: GrantConstraints, grantId?: string): PermissionRule[];
1777
+ /**
1778
+ * ApprovalContext — Cedar 一元化 Step 3.5.
1779
+ *
1780
+ * Spec refs:
1781
+ * - docs/specs/2026-05-24-cedar-unification-design.md §6 (approvalContext
1782
+ * DTO + token ledger)
1783
+ * - docs/specs/2026-05-24-cedar-unification-design.md §7.2 (Cedar
1784
+ * context.approval shape)
1785
+ * - docs/specs/2026-05-24-cedar-unification-design.md §11.1
1786
+ * (`via_approval` event lifecycle)
1787
+ *
1788
+ * Carried in the body of the VC issuance API on the **retry path** (i.e.
1789
+ * after a user clicked 承認 in the approval UI). The server consumes the
1790
+ * single-use `token` against the approval-token ledger atomically and then
1791
+ * injects `{ granted: true, request_id, outcome_id }` into the Cedar
1792
+ * `context.approval` so a policy that previously returned `auth_required`
1793
+ * now returns `permit`.
1794
+ *
1795
+ * Identifier formats (canonical, enforced upstream):
1796
+ * - `request_id` : `'req_' + uuid`
1797
+ * - `outcome_id` : `'outcome_' + uuid`
1798
+ * - `token` : `'tok_' + uuid`
1799
+ * - `granted_at` : ISO-8601 timestamp
1800
+ * - `granted_by` : user id, or the literal `'system'` for auto-approve
1801
+ *
1802
+ * Replay protection invariant (spec §6):
1803
+ * The `token` is **single-use**. Once consumed by the ledger, a second
1804
+ * submission MUST be rejected as `denied_by_user` (ephemeral — does not
1805
+ * poison subsequent fresh requests; §5.1 OpenQ-D1 resolution).
1806
+ */
1807
+ interface ApprovalContext {
1808
+ /** `req_<uuid>` — the approval-request id embedded in the initial
1809
+ * `auth_required` audit event. Used to reverse-link the outcome to the
1810
+ * triggering invocation. */
1811
+ request_id: string;
1812
+ /** `outcome_<uuid>` — the approval_outcome event id (Step 6 surfaces this
1813
+ * as a first-class row, Step 3.5 only carries it through the ledger). */
1814
+ outcome_id: string;
1815
+ /** `tok_<uuid>` — single-use token. Consumed atomically. */
1816
+ token: string;
1817
+ /** True for 承認, false for 拒否. Step 3.5 only honors `true` (the `false`
1818
+ * path is handled by emitting `denied_by_user` directly in the UI). */
1819
+ granted: boolean;
1820
+ /** ISO-8601 timestamp of the approval action. */
1821
+ granted_at: string;
1822
+ /** user id or `'system'` for auto-approve. */
1823
+ granted_by: string;
1824
+ }
1526
1825
 
1527
1826
  /**
1528
1827
  * Receipt(証跡)関連の型定義
@@ -2212,6 +2511,63 @@ interface JiraIssue {
2212
2511
  };
2213
2512
  };
2214
2513
  }
2514
+ /**
2515
+ * Jira 課題リンク種別 (issueLinkType)
2516
+ *
2517
+ * 例: Blocks (inward: "is blocked by", outward: "blocks"),
2518
+ * Relates (inward/outward: "relates to"),
2519
+ * Cloners (inward: "is cloned by", outward: "clones")
2520
+ *
2521
+ * Jira REST API v3: GET /rest/api/3/issueLinkType で取得される。
2522
+ */
2523
+ interface JiraIssueLinkType {
2524
+ /** リンク種別の内部 ID */
2525
+ id: string;
2526
+ /** リンク種別の名前 (例: "Blocks") */
2527
+ name: string;
2528
+ /** リンク先 → 自分 方向の表示文字列 (例: "is blocked by") */
2529
+ inward: string;
2530
+ /** 自分 → リンク先 方向の表示文字列 (例: "blocks") */
2531
+ outward: string;
2532
+ /** REST API self URL */
2533
+ self?: string;
2534
+ }
2535
+ /**
2536
+ * Jira 課題間リンク (issueLink)
2537
+ *
2538
+ * Jira REST API v3 の課題 read で `fields.issuelinks[]` として返る形式に対応。
2539
+ * delete 時はこの `id` を渡す。
2540
+ */
2541
+ interface JiraIssueLink {
2542
+ /** リンクの内部 ID (delete 時に必要) */
2543
+ id: string;
2544
+ /** リンク種別 */
2545
+ type: JiraIssueLinkType;
2546
+ /** inward 方向のリンク先 (自分が「is blocked by other」のとき、other がここに入る) */
2547
+ inwardIssue?: {
2548
+ id: string;
2549
+ key: string;
2550
+ self?: string;
2551
+ fields?: {
2552
+ summary?: string;
2553
+ status?: JiraStatus;
2554
+ issuetype?: JiraIssueType;
2555
+ };
2556
+ };
2557
+ /** outward 方向のリンク先 (自分が「blocks other」のとき、other がここに入る) */
2558
+ outwardIssue?: {
2559
+ id: string;
2560
+ key: string;
2561
+ self?: string;
2562
+ fields?: {
2563
+ summary?: string;
2564
+ status?: JiraStatus;
2565
+ issuetype?: JiraIssueType;
2566
+ };
2567
+ };
2568
+ /** REST API self URL */
2569
+ self?: string;
2570
+ }
2215
2571
  /**
2216
2572
  * JIRA作業ログ
2217
2573
  */
@@ -2724,6 +3080,66 @@ interface ConfirmGrantSuggestionRequest {
2724
3080
  */
2725
3081
  declare const DEFAULT_CONSTRAINTS_BY_RISK: Record<SuggestionRiskLevel, SuggestedConstraints>;
2726
3082
 
3083
+ /**
3084
+ * Cedar-specific schema / policy / decision wire types.
3085
+ *
3086
+ * Phase 1 Step 2: Type-only declarations. The actual Cedar engine wrapper
3087
+ * lives in Step 1's lane (`packages/sdk/src/policy/cedar-engine.ts` — not
3088
+ * touched here). This module exposes the opaque handle types that other
3089
+ * services (PEP, decision audit, policy registry) use to communicate
3090
+ * *about* Cedar without depending on cedar-wasm internals.
3091
+ *
3092
+ * Spec refs:
3093
+ * - docs/specs/2026-05-23-cedar-rar-implementation-plan-phase1.md Task 2.2
3094
+ * - docs/specs/2026-05-23-cedar-rar-permission-redesign.md §3.3 (Cedar schema)
3095
+ */
3096
+ /**
3097
+ * Cedar schema (entity types + actions + context shapes).
3098
+ *
3099
+ * Opaque to AIdentity at the type level — the concrete JSON shape follows
3100
+ * the Cedar spec and is produced by `connector-plugin` codegen. Treat
3101
+ * instances as black-box payloads that round-trip through the Cedar engine.
3102
+ */
3103
+ interface CedarSchema {
3104
+ }
3105
+ /**
3106
+ * Opaque handle returned by the Cedar engine after parsing / compiling a
3107
+ * PolicySet. Implementations may store wasm pointers, validation state, etc.
3108
+ * Consumers MUST NOT introspect the shape.
3109
+ */
3110
+ interface CedarPolicySetHandle {
3111
+ }
3112
+ /**
3113
+ * Opaque handle returned by the Cedar engine after parsing / compiling a
3114
+ * Schema. See {@link CedarPolicySetHandle} for usage notes.
3115
+ */
3116
+ interface CedarSchemaHandle {
3117
+ }
3118
+ /**
3119
+ * 3-valued decision returned by the AIdentity Decision Service after the
3120
+ * 2-phase Cedar evaluation.
3121
+ *
3122
+ * Mapping:
3123
+ * - `Permit` → Cedar Permit && no constraints failed
3124
+ * - `Forbid` → Cedar Forbid OR no matching permit
3125
+ * - `RequireApproval` → AIdentity-specific intermediate state (e.g.,
3126
+ * high-risk action that needs human approval).
3127
+ * Cedar itself only emits Permit / Forbid; the
3128
+ * decision service derives `RequireApproval` from
3129
+ * annotated policies or constraint-level escalation.
3130
+ */
3131
+ type CedarDecisionValue = 'Permit' | 'Forbid' | 'RequireApproval';
3132
+ /**
3133
+ * Diagnostic information accompanying a Cedar decision. Surfaced to audit
3134
+ * logs and (in shadow mode) to legacy/Cedar parity checks.
3135
+ */
3136
+ interface CedarDecisionDiagnostic {
3137
+ /** IDs of the Cedar policies that matched the request (in evaluation order). */
3138
+ matched_policy_ids: string[];
3139
+ /** Cedar diagnostics passthrough (parse / validation errors, if any). */
3140
+ errors: string[];
3141
+ }
3142
+
2727
3143
  type UserTier = 'free' | 'pro' | 'team';
2728
3144
  interface TierLimits {
2729
3145
  maxProjects: number;
@@ -3920,7 +4336,7 @@ interface ActionMeta {
3920
4336
  input_schema?: JsonSchema;
3921
4337
  constraints?: Record<string, unknown>;
3922
4338
  effects?: string[];
3923
- risk?: RiskLevel;
4339
+ risk: RiskLevel;
3924
4340
  target_bindings?: TargetBindings;
3925
4341
  version: string;
3926
4342
  }
@@ -4276,6 +4692,11 @@ declare const ACTION_REGISTRY: {
4276
4692
  priority?: undefined;
4277
4693
  assigneeAccountId?: undefined;
4278
4694
  transitionId?: undefined;
4695
+ typeName?: undefined;
4696
+ inwardIssueKey?: undefined;
4697
+ outwardIssueKey?: undefined;
4698
+ commentBody?: undefined;
4699
+ linkId?: undefined;
4279
4700
  file_path?: undefined;
4280
4701
  content?: undefined;
4281
4702
  command?: undefined;
@@ -4372,6 +4793,11 @@ declare const ACTION_REGISTRY: {
4372
4793
  priority?: undefined;
4373
4794
  assigneeAccountId?: undefined;
4374
4795
  transitionId?: undefined;
4796
+ typeName?: undefined;
4797
+ inwardIssueKey?: undefined;
4798
+ outwardIssueKey?: undefined;
4799
+ commentBody?: undefined;
4800
+ linkId?: undefined;
4375
4801
  file_path?: undefined;
4376
4802
  content?: undefined;
4377
4803
  command?: undefined;
@@ -4471,6 +4897,11 @@ declare const ACTION_REGISTRY: {
4471
4897
  priority?: undefined;
4472
4898
  assigneeAccountId?: undefined;
4473
4899
  transitionId?: undefined;
4900
+ typeName?: undefined;
4901
+ inwardIssueKey?: undefined;
4902
+ outwardIssueKey?: undefined;
4903
+ commentBody?: undefined;
4904
+ linkId?: undefined;
4474
4905
  file_path?: undefined;
4475
4906
  content?: undefined;
4476
4907
  command?: undefined;
@@ -4580,6 +5011,11 @@ declare const ACTION_REGISTRY: {
4580
5011
  priority?: undefined;
4581
5012
  assigneeAccountId?: undefined;
4582
5013
  transitionId?: undefined;
5014
+ typeName?: undefined;
5015
+ inwardIssueKey?: undefined;
5016
+ outwardIssueKey?: undefined;
5017
+ commentBody?: undefined;
5018
+ linkId?: undefined;
4583
5019
  file_path?: undefined;
4584
5020
  content?: undefined;
4585
5021
  command?: undefined;
@@ -4686,6 +5122,11 @@ declare const ACTION_REGISTRY: {
4686
5122
  priority?: undefined;
4687
5123
  assigneeAccountId?: undefined;
4688
5124
  transitionId?: undefined;
5125
+ typeName?: undefined;
5126
+ inwardIssueKey?: undefined;
5127
+ outwardIssueKey?: undefined;
5128
+ commentBody?: undefined;
5129
+ linkId?: undefined;
4689
5130
  file_path?: undefined;
4690
5131
  content?: undefined;
4691
5132
  command?: undefined;
@@ -4789,6 +5230,11 @@ declare const ACTION_REGISTRY: {
4789
5230
  priority?: undefined;
4790
5231
  assigneeAccountId?: undefined;
4791
5232
  transitionId?: undefined;
5233
+ typeName?: undefined;
5234
+ inwardIssueKey?: undefined;
5235
+ outwardIssueKey?: undefined;
5236
+ commentBody?: undefined;
5237
+ linkId?: undefined;
4792
5238
  file_path?: undefined;
4793
5239
  content?: undefined;
4794
5240
  command?: undefined;
@@ -4895,6 +5341,11 @@ declare const ACTION_REGISTRY: {
4895
5341
  priority?: undefined;
4896
5342
  assigneeAccountId?: undefined;
4897
5343
  transitionId?: undefined;
5344
+ typeName?: undefined;
5345
+ inwardIssueKey?: undefined;
5346
+ outwardIssueKey?: undefined;
5347
+ commentBody?: undefined;
5348
+ linkId?: undefined;
4898
5349
  file_path?: undefined;
4899
5350
  content?: undefined;
4900
5351
  command?: undefined;
@@ -4997,6 +5448,11 @@ declare const ACTION_REGISTRY: {
4997
5448
  priority?: undefined;
4998
5449
  assigneeAccountId?: undefined;
4999
5450
  transitionId?: undefined;
5451
+ typeName?: undefined;
5452
+ inwardIssueKey?: undefined;
5453
+ outwardIssueKey?: undefined;
5454
+ commentBody?: undefined;
5455
+ linkId?: undefined;
5000
5456
  file_path?: undefined;
5001
5457
  content?: undefined;
5002
5458
  command?: undefined;
@@ -5109,6 +5565,11 @@ declare const ACTION_REGISTRY: {
5109
5565
  priority?: undefined;
5110
5566
  assigneeAccountId?: undefined;
5111
5567
  transitionId?: undefined;
5568
+ typeName?: undefined;
5569
+ inwardIssueKey?: undefined;
5570
+ outwardIssueKey?: undefined;
5571
+ commentBody?: undefined;
5572
+ linkId?: undefined;
5112
5573
  file_path?: undefined;
5113
5574
  content?: undefined;
5114
5575
  command?: undefined;
@@ -5224,6 +5685,11 @@ declare const ACTION_REGISTRY: {
5224
5685
  priority?: undefined;
5225
5686
  assigneeAccountId?: undefined;
5226
5687
  transitionId?: undefined;
5688
+ typeName?: undefined;
5689
+ inwardIssueKey?: undefined;
5690
+ outwardIssueKey?: undefined;
5691
+ commentBody?: undefined;
5692
+ linkId?: undefined;
5227
5693
  file_path?: undefined;
5228
5694
  content?: undefined;
5229
5695
  command?: undefined;
@@ -5323,6 +5789,11 @@ declare const ACTION_REGISTRY: {
5323
5789
  priority?: undefined;
5324
5790
  assigneeAccountId?: undefined;
5325
5791
  transitionId?: undefined;
5792
+ typeName?: undefined;
5793
+ inwardIssueKey?: undefined;
5794
+ outwardIssueKey?: undefined;
5795
+ commentBody?: undefined;
5796
+ linkId?: undefined;
5326
5797
  file_path?: undefined;
5327
5798
  content?: undefined;
5328
5799
  command?: undefined;
@@ -5441,6 +5912,11 @@ declare const ACTION_REGISTRY: {
5441
5912
  priority?: undefined;
5442
5913
  assigneeAccountId?: undefined;
5443
5914
  transitionId?: undefined;
5915
+ typeName?: undefined;
5916
+ inwardIssueKey?: undefined;
5917
+ outwardIssueKey?: undefined;
5918
+ commentBody?: undefined;
5919
+ linkId?: undefined;
5444
5920
  file_path?: undefined;
5445
5921
  content?: undefined;
5446
5922
  command?: undefined;
@@ -5545,6 +6021,11 @@ declare const ACTION_REGISTRY: {
5545
6021
  priority?: undefined;
5546
6022
  assigneeAccountId?: undefined;
5547
6023
  transitionId?: undefined;
6024
+ typeName?: undefined;
6025
+ inwardIssueKey?: undefined;
6026
+ outwardIssueKey?: undefined;
6027
+ commentBody?: undefined;
6028
+ linkId?: undefined;
5548
6029
  file_path?: undefined;
5549
6030
  content?: undefined;
5550
6031
  command?: undefined;
@@ -5644,6 +6125,11 @@ declare const ACTION_REGISTRY: {
5644
6125
  priority?: undefined;
5645
6126
  assigneeAccountId?: undefined;
5646
6127
  transitionId?: undefined;
6128
+ typeName?: undefined;
6129
+ inwardIssueKey?: undefined;
6130
+ outwardIssueKey?: undefined;
6131
+ commentBody?: undefined;
6132
+ linkId?: undefined;
5647
6133
  file_path?: undefined;
5648
6134
  content?: undefined;
5649
6135
  command?: undefined;
@@ -5759,6 +6245,11 @@ declare const ACTION_REGISTRY: {
5759
6245
  priority?: undefined;
5760
6246
  assigneeAccountId?: undefined;
5761
6247
  transitionId?: undefined;
6248
+ typeName?: undefined;
6249
+ inwardIssueKey?: undefined;
6250
+ outwardIssueKey?: undefined;
6251
+ commentBody?: undefined;
6252
+ linkId?: undefined;
5762
6253
  file_path?: undefined;
5763
6254
  content?: undefined;
5764
6255
  command?: undefined;
@@ -5870,6 +6361,11 @@ declare const ACTION_REGISTRY: {
5870
6361
  priority?: undefined;
5871
6362
  assigneeAccountId?: undefined;
5872
6363
  transitionId?: undefined;
6364
+ typeName?: undefined;
6365
+ inwardIssueKey?: undefined;
6366
+ outwardIssueKey?: undefined;
6367
+ commentBody?: undefined;
6368
+ linkId?: undefined;
5873
6369
  file_path?: undefined;
5874
6370
  content?: undefined;
5875
6371
  command?: undefined;
@@ -5980,6 +6476,11 @@ declare const ACTION_REGISTRY: {
5980
6476
  priority?: undefined;
5981
6477
  assigneeAccountId?: undefined;
5982
6478
  transitionId?: undefined;
6479
+ typeName?: undefined;
6480
+ inwardIssueKey?: undefined;
6481
+ outwardIssueKey?: undefined;
6482
+ commentBody?: undefined;
6483
+ linkId?: undefined;
5983
6484
  file_path?: undefined;
5984
6485
  content?: undefined;
5985
6486
  command?: undefined;
@@ -6083,6 +6584,11 @@ declare const ACTION_REGISTRY: {
6083
6584
  priority?: undefined;
6084
6585
  assigneeAccountId?: undefined;
6085
6586
  transitionId?: undefined;
6587
+ typeName?: undefined;
6588
+ inwardIssueKey?: undefined;
6589
+ outwardIssueKey?: undefined;
6590
+ commentBody?: undefined;
6591
+ linkId?: undefined;
6086
6592
  file_path?: undefined;
6087
6593
  content?: undefined;
6088
6594
  command?: undefined;
@@ -6237,6 +6743,11 @@ declare const ACTION_REGISTRY: {
6237
6743
  priority?: undefined;
6238
6744
  assigneeAccountId?: undefined;
6239
6745
  transitionId?: undefined;
6746
+ typeName?: undefined;
6747
+ inwardIssueKey?: undefined;
6748
+ outwardIssueKey?: undefined;
6749
+ commentBody?: undefined;
6750
+ linkId?: undefined;
6240
6751
  file_path?: undefined;
6241
6752
  content?: undefined;
6242
6753
  command?: undefined;
@@ -6402,6 +6913,11 @@ declare const ACTION_REGISTRY: {
6402
6913
  priority?: undefined;
6403
6914
  assigneeAccountId?: undefined;
6404
6915
  transitionId?: undefined;
6916
+ typeName?: undefined;
6917
+ inwardIssueKey?: undefined;
6918
+ outwardIssueKey?: undefined;
6919
+ commentBody?: undefined;
6920
+ linkId?: undefined;
6405
6921
  file_path?: undefined;
6406
6922
  content?: undefined;
6407
6923
  command?: undefined;
@@ -6512,6 +7028,11 @@ declare const ACTION_REGISTRY: {
6512
7028
  priority?: undefined;
6513
7029
  assigneeAccountId?: undefined;
6514
7030
  transitionId?: undefined;
7031
+ typeName?: undefined;
7032
+ inwardIssueKey?: undefined;
7033
+ outwardIssueKey?: undefined;
7034
+ commentBody?: undefined;
7035
+ linkId?: undefined;
6515
7036
  file_path?: undefined;
6516
7037
  content?: undefined;
6517
7038
  command?: undefined;
@@ -6610,6 +7131,11 @@ declare const ACTION_REGISTRY: {
6610
7131
  priority?: undefined;
6611
7132
  assigneeAccountId?: undefined;
6612
7133
  transitionId?: undefined;
7134
+ typeName?: undefined;
7135
+ inwardIssueKey?: undefined;
7136
+ outwardIssueKey?: undefined;
7137
+ commentBody?: undefined;
7138
+ linkId?: undefined;
6613
7139
  file_path?: undefined;
6614
7140
  content?: undefined;
6615
7141
  command?: undefined;
@@ -6710,6 +7236,11 @@ declare const ACTION_REGISTRY: {
6710
7236
  priority?: undefined;
6711
7237
  assigneeAccountId?: undefined;
6712
7238
  transitionId?: undefined;
7239
+ typeName?: undefined;
7240
+ inwardIssueKey?: undefined;
7241
+ outwardIssueKey?: undefined;
7242
+ commentBody?: undefined;
7243
+ linkId?: undefined;
6713
7244
  file_path?: undefined;
6714
7245
  content?: undefined;
6715
7246
  command?: undefined;
@@ -6812,6 +7343,11 @@ declare const ACTION_REGISTRY: {
6812
7343
  priority?: undefined;
6813
7344
  assigneeAccountId?: undefined;
6814
7345
  transitionId?: undefined;
7346
+ typeName?: undefined;
7347
+ inwardIssueKey?: undefined;
7348
+ outwardIssueKey?: undefined;
7349
+ commentBody?: undefined;
7350
+ linkId?: undefined;
6815
7351
  file_path?: undefined;
6816
7352
  content?: undefined;
6817
7353
  command?: undefined;
@@ -6916,6 +7452,11 @@ declare const ACTION_REGISTRY: {
6916
7452
  priority?: undefined;
6917
7453
  assigneeAccountId?: undefined;
6918
7454
  transitionId?: undefined;
7455
+ typeName?: undefined;
7456
+ inwardIssueKey?: undefined;
7457
+ outwardIssueKey?: undefined;
7458
+ commentBody?: undefined;
7459
+ linkId?: undefined;
6919
7460
  file_path?: undefined;
6920
7461
  content?: undefined;
6921
7462
  command?: undefined;
@@ -7023,6 +7564,11 @@ declare const ACTION_REGISTRY: {
7023
7564
  priority?: undefined;
7024
7565
  assigneeAccountId?: undefined;
7025
7566
  transitionId?: undefined;
7567
+ typeName?: undefined;
7568
+ inwardIssueKey?: undefined;
7569
+ outwardIssueKey?: undefined;
7570
+ commentBody?: undefined;
7571
+ linkId?: undefined;
7026
7572
  file_path?: undefined;
7027
7573
  content?: undefined;
7028
7574
  command?: undefined;
@@ -7122,6 +7668,11 @@ declare const ACTION_REGISTRY: {
7122
7668
  priority?: undefined;
7123
7669
  assigneeAccountId?: undefined;
7124
7670
  transitionId?: undefined;
7671
+ typeName?: undefined;
7672
+ inwardIssueKey?: undefined;
7673
+ outwardIssueKey?: undefined;
7674
+ commentBody?: undefined;
7675
+ linkId?: undefined;
7125
7676
  file_path?: undefined;
7126
7677
  content?: undefined;
7127
7678
  command?: undefined;
@@ -7241,6 +7792,11 @@ declare const ACTION_REGISTRY: {
7241
7792
  startAt?: undefined;
7242
7793
  issueIdOrKey?: undefined;
7243
7794
  transitionId?: undefined;
7795
+ typeName?: undefined;
7796
+ inwardIssueKey?: undefined;
7797
+ outwardIssueKey?: undefined;
7798
+ commentBody?: undefined;
7799
+ linkId?: undefined;
7244
7800
  file_path?: undefined;
7245
7801
  content?: undefined;
7246
7802
  command?: undefined;
@@ -7356,6 +7912,11 @@ declare const ACTION_REGISTRY: {
7356
7912
  projectKey?: undefined;
7357
7913
  issueTypeName?: undefined;
7358
7914
  transitionId?: undefined;
7915
+ typeName?: undefined;
7916
+ inwardIssueKey?: undefined;
7917
+ outwardIssueKey?: undefined;
7918
+ commentBody?: undefined;
7919
+ linkId?: undefined;
7359
7920
  file_path?: undefined;
7360
7921
  content?: undefined;
7361
7922
  command?: undefined;
@@ -7455,6 +8016,11 @@ declare const ACTION_REGISTRY: {
7455
8016
  priority?: undefined;
7456
8017
  assigneeAccountId?: undefined;
7457
8018
  transitionId?: undefined;
8019
+ typeName?: undefined;
8020
+ inwardIssueKey?: undefined;
8021
+ outwardIssueKey?: undefined;
8022
+ commentBody?: undefined;
8023
+ linkId?: undefined;
7458
8024
  file_path?: undefined;
7459
8025
  content?: undefined;
7460
8026
  command?: undefined;
@@ -7557,6 +8123,11 @@ declare const ACTION_REGISTRY: {
7557
8123
  priority?: undefined;
7558
8124
  assigneeAccountId?: undefined;
7559
8125
  transitionId?: undefined;
8126
+ typeName?: undefined;
8127
+ inwardIssueKey?: undefined;
8128
+ outwardIssueKey?: undefined;
8129
+ commentBody?: undefined;
8130
+ linkId?: undefined;
7560
8131
  file_path?: undefined;
7561
8132
  content?: undefined;
7562
8133
  command?: undefined;
@@ -7659,6 +8230,11 @@ declare const ACTION_REGISTRY: {
7659
8230
  issueTypeName?: undefined;
7660
8231
  priority?: undefined;
7661
8232
  assigneeAccountId?: undefined;
8233
+ typeName?: undefined;
8234
+ inwardIssueKey?: undefined;
8235
+ outwardIssueKey?: undefined;
8236
+ commentBody?: undefined;
8237
+ linkId?: undefined;
7662
8238
  file_path?: undefined;
7663
8239
  content?: undefined;
7664
8240
  command?: undefined;
@@ -7766,6 +8342,11 @@ declare const ACTION_REGISTRY: {
7766
8342
  priority?: undefined;
7767
8343
  assigneeAccountId?: undefined;
7768
8344
  transitionId?: undefined;
8345
+ typeName?: undefined;
8346
+ inwardIssueKey?: undefined;
8347
+ outwardIssueKey?: undefined;
8348
+ commentBody?: undefined;
8349
+ linkId?: undefined;
7769
8350
  file_path?: undefined;
7770
8351
  content?: undefined;
7771
8352
  command?: undefined;
@@ -7796,6 +8377,224 @@ declare const ACTION_REGISTRY: {
7796
8377
  secondary?: undefined;
7797
8378
  };
7798
8379
  version: string;
8380
+ } | {
8381
+ action: string;
8382
+ resource_type: string;
8383
+ required_relations: string[];
8384
+ required_scopes: string[];
8385
+ capability: string;
8386
+ input_schema: {
8387
+ type: string;
8388
+ properties: {
8389
+ typeName: {
8390
+ type: string;
8391
+ minLength: number;
8392
+ description: string;
8393
+ };
8394
+ inwardIssueKey: {
8395
+ type: string;
8396
+ minLength: number;
8397
+ };
8398
+ outwardIssueKey: {
8399
+ type: string;
8400
+ minLength: number;
8401
+ };
8402
+ commentBody: {
8403
+ type: string;
8404
+ };
8405
+ channel?: undefined;
8406
+ text?: undefined;
8407
+ thread_ts?: undefined;
8408
+ username?: undefined;
8409
+ icon_emoji?: undefined;
8410
+ blocks?: undefined;
8411
+ userId?: undefined;
8412
+ latest?: undefined;
8413
+ oldest?: undefined;
8414
+ limit?: undefined;
8415
+ inclusive?: undefined;
8416
+ cursor?: undefined;
8417
+ ts?: undefined;
8418
+ title?: undefined;
8419
+ body?: undefined;
8420
+ labels?: undefined;
8421
+ assignees?: undefined;
8422
+ state?: undefined;
8423
+ sort?: undefined;
8424
+ direction?: undefined;
8425
+ per_page?: undefined;
8426
+ page?: undefined;
8427
+ issue_number?: undefined;
8428
+ query?: undefined;
8429
+ maxResults?: undefined;
8430
+ messageId?: undefined;
8431
+ to?: undefined;
8432
+ subject?: undefined;
8433
+ cc?: undefined;
8434
+ bcc?: undefined;
8435
+ threadId?: undefined;
8436
+ inReplyTo?: undefined;
8437
+ references?: undefined;
8438
+ messageIds?: undefined;
8439
+ calendarId?: undefined;
8440
+ timeMin?: undefined;
8441
+ timeMax?: undefined;
8442
+ eventId?: undefined;
8443
+ summary?: undefined;
8444
+ description?: undefined;
8445
+ start?: undefined;
8446
+ end?: undefined;
8447
+ attendees?: undefined;
8448
+ location?: undefined;
8449
+ recent?: undefined;
8450
+ projectKeyOrId?: undefined;
8451
+ type?: undefined;
8452
+ boardId?: undefined;
8453
+ sprintId?: undefined;
8454
+ jql?: undefined;
8455
+ startAt?: undefined;
8456
+ issueIdOrKey?: undefined;
8457
+ projectKey?: undefined;
8458
+ issueTypeName?: undefined;
8459
+ priority?: undefined;
8460
+ assigneeAccountId?: undefined;
8461
+ transitionId?: undefined;
8462
+ linkId?: undefined;
8463
+ file_path?: undefined;
8464
+ content?: undefined;
8465
+ command?: undefined;
8466
+ working_directory?: undefined;
8467
+ env_profile?: undefined;
8468
+ timeout_seconds?: undefined;
8469
+ };
8470
+ required: string[];
8471
+ additionalProperties: boolean;
8472
+ };
8473
+ constraints: {
8474
+ rate_bucket: string;
8475
+ };
8476
+ effects: string[];
8477
+ risk: string;
8478
+ target_bindings: {
8479
+ resource_id: {
8480
+ source: "param";
8481
+ param: string;
8482
+ derive: "project_key";
8483
+ required?: undefined;
8484
+ key?: undefined;
8485
+ multi?: undefined;
8486
+ separator?: undefined;
8487
+ default?: undefined;
8488
+ fallback_param?: undefined;
8489
+ };
8490
+ secondary?: undefined;
8491
+ };
8492
+ version: string;
8493
+ } | {
8494
+ action: string;
8495
+ resource_type: string;
8496
+ required_relations: string[];
8497
+ required_scopes: string[];
8498
+ capability: string;
8499
+ input_schema: {
8500
+ type: string;
8501
+ properties: {
8502
+ linkId: {
8503
+ type: string;
8504
+ minLength: number;
8505
+ description: string;
8506
+ };
8507
+ channel?: undefined;
8508
+ text?: undefined;
8509
+ thread_ts?: undefined;
8510
+ username?: undefined;
8511
+ icon_emoji?: undefined;
8512
+ blocks?: undefined;
8513
+ userId?: undefined;
8514
+ latest?: undefined;
8515
+ oldest?: undefined;
8516
+ limit?: undefined;
8517
+ inclusive?: undefined;
8518
+ cursor?: undefined;
8519
+ ts?: undefined;
8520
+ title?: undefined;
8521
+ body?: undefined;
8522
+ labels?: undefined;
8523
+ assignees?: undefined;
8524
+ state?: undefined;
8525
+ sort?: undefined;
8526
+ direction?: undefined;
8527
+ per_page?: undefined;
8528
+ page?: undefined;
8529
+ issue_number?: undefined;
8530
+ query?: undefined;
8531
+ maxResults?: undefined;
8532
+ messageId?: undefined;
8533
+ to?: undefined;
8534
+ subject?: undefined;
8535
+ cc?: undefined;
8536
+ bcc?: undefined;
8537
+ threadId?: undefined;
8538
+ inReplyTo?: undefined;
8539
+ references?: undefined;
8540
+ messageIds?: undefined;
8541
+ calendarId?: undefined;
8542
+ timeMin?: undefined;
8543
+ timeMax?: undefined;
8544
+ eventId?: undefined;
8545
+ summary?: undefined;
8546
+ description?: undefined;
8547
+ start?: undefined;
8548
+ end?: undefined;
8549
+ attendees?: undefined;
8550
+ location?: undefined;
8551
+ recent?: undefined;
8552
+ projectKeyOrId?: undefined;
8553
+ type?: undefined;
8554
+ boardId?: undefined;
8555
+ sprintId?: undefined;
8556
+ jql?: undefined;
8557
+ startAt?: undefined;
8558
+ issueIdOrKey?: undefined;
8559
+ projectKey?: undefined;
8560
+ issueTypeName?: undefined;
8561
+ priority?: undefined;
8562
+ assigneeAccountId?: undefined;
8563
+ transitionId?: undefined;
8564
+ typeName?: undefined;
8565
+ inwardIssueKey?: undefined;
8566
+ outwardIssueKey?: undefined;
8567
+ commentBody?: undefined;
8568
+ file_path?: undefined;
8569
+ content?: undefined;
8570
+ command?: undefined;
8571
+ working_directory?: undefined;
8572
+ env_profile?: undefined;
8573
+ timeout_seconds?: undefined;
8574
+ };
8575
+ required: string[];
8576
+ additionalProperties: boolean;
8577
+ };
8578
+ constraints: {
8579
+ rate_bucket: string;
8580
+ };
8581
+ effects: string[];
8582
+ risk: string;
8583
+ target_bindings: {
8584
+ resource_id: {
8585
+ source: "param";
8586
+ param: string;
8587
+ required?: undefined;
8588
+ key?: undefined;
8589
+ multi?: undefined;
8590
+ separator?: undefined;
8591
+ default?: undefined;
8592
+ fallback_param?: undefined;
8593
+ derive?: undefined;
8594
+ };
8595
+ secondary?: undefined;
8596
+ };
8597
+ version: string;
7799
8598
  } | {
7800
8599
  action: string;
7801
8600
  resource_type: string;
@@ -7865,6 +8664,11 @@ declare const ACTION_REGISTRY: {
7865
8664
  priority?: undefined;
7866
8665
  assigneeAccountId?: undefined;
7867
8666
  transitionId?: undefined;
8667
+ typeName?: undefined;
8668
+ inwardIssueKey?: undefined;
8669
+ outwardIssueKey?: undefined;
8670
+ commentBody?: undefined;
8671
+ linkId?: undefined;
7868
8672
  content?: undefined;
7869
8673
  command?: undefined;
7870
8674
  working_directory?: undefined;
@@ -7966,6 +8770,11 @@ declare const ACTION_REGISTRY: {
7966
8770
  priority?: undefined;
7967
8771
  assigneeAccountId?: undefined;
7968
8772
  transitionId?: undefined;
8773
+ typeName?: undefined;
8774
+ inwardIssueKey?: undefined;
8775
+ outwardIssueKey?: undefined;
8776
+ commentBody?: undefined;
8777
+ linkId?: undefined;
7969
8778
  command?: undefined;
7970
8779
  working_directory?: undefined;
7971
8780
  env_profile?: undefined;
@@ -8077,6 +8886,11 @@ declare const ACTION_REGISTRY: {
8077
8886
  priority?: undefined;
8078
8887
  assigneeAccountId?: undefined;
8079
8888
  transitionId?: undefined;
8889
+ typeName?: undefined;
8890
+ inwardIssueKey?: undefined;
8891
+ outwardIssueKey?: undefined;
8892
+ commentBody?: undefined;
8893
+ linkId?: undefined;
8080
8894
  file_path?: undefined;
8081
8895
  content?: undefined;
8082
8896
  };
@@ -8761,6 +9575,414 @@ interface SignRequestArgs {
8761
9575
  */
8762
9576
  declare function signRequest(key: InternalHmacSignerKey, args: SignRequestArgs): string;
8763
9577
 
9578
+ /**
9579
+ * CedarEngine — minimal wrapper around `@cedar-policy/cedar-wasm/nodejs`.
9580
+ *
9581
+ * Phase 1 Step 1 scope (server-side / Node-runtime only):
9582
+ * - preparseSchema : ingest Cedar schema text → opaque SchemaHandle
9583
+ * - preparsePolicySet: ingest Cedar PolicySet text → opaque PolicySetHandle
9584
+ * - evaluate : run statefulIsAuthorized against preparsed handles
9585
+ *
9586
+ * Browser callers receive `CedarEngineUnavailableError` because the
9587
+ * `/nodejs` subpath depends on Node `fs` to instantiate the wasm.
9588
+ *
9589
+ * Performance notes (companion design spec Appendix C, PoC 2026-05-23):
9590
+ * - statefulIsAuthorized + preparsed cache: p50 0.067ms / p99 0.076ms
9591
+ * (~9x faster than re-parsing every call). The wasm caches preparsed
9592
+ * handles internally keyed by string name/id, so the opaque handles
9593
+ * we expose are thin wrappers around an auto-generated id.
9594
+ *
9595
+ * Concurrency / TOCTOU (Cedar design spec rev 5/6, fix C3):
9596
+ * - `createCedarEngine()` caches the in-flight Promise (not the resolved
9597
+ * engine). Two parallel callers therefore share the same load — no
9598
+ * duplicated dynamic import of the 4.1 MB wasm.
9599
+ * - On load failure the cached promise is cleared so the next caller can
9600
+ * retry. This avoids permanently poisoning the module after a transient
9601
+ * failure (e.g. wasm streaming compile blip).
9602
+ *
9603
+ * Design ref: docs/specs/2026-05-23-cedar-rar-permission-redesign.md
9604
+ * Plan ref: docs/specs/2026-05-23-cedar-rar-implementation-plan-phase1.md
9605
+ */
9606
+ /**
9607
+ * Decision domain exposed by the wrapper. Cedar's wasm uses lowercase
9608
+ * `'allow' | 'deny'`; we normalize to the spec's casing so callers can
9609
+ * pattern-match on a single canonical form across the codebase.
9610
+ */
9611
+ type CedarDecision = 'Allow' | 'Deny';
9612
+ /**
9613
+ * Structured error returned for evaluation-time problems (policy execution
9614
+ * errors). Parse / schema errors are surfaced at preparse time as thrown
9615
+ * `CedarParseError`s instead.
9616
+ */
9617
+ interface CedarError {
9618
+ /** Policy id that errored, if attributable. */
9619
+ policyId?: string;
9620
+ /** Human-readable message from Cedar. */
9621
+ message: string;
9622
+ /** Optional structured diagnostic code from Cedar. */
9623
+ code?: string;
9624
+ }
9625
+ /**
9626
+ * Phase 2-1-H — structured policy validation error surfaced by
9627
+ * `CedarParseError.validationErrors` (and re-exported as a public type
9628
+ * so API / UI callers don't have to re-implement source-location math).
9629
+ *
9630
+ * One `PolicyValidationError` entry corresponds to one cedar-wasm
9631
+ * diagnostic (top-level `errors[]` entries + their `related[]`
9632
+ * descendants are flattened into a single list, since callers always
9633
+ * want to render every diagnostic — the related chain is metadata about
9634
+ * the top-level failure, not a separate parse).
9635
+ *
9636
+ * Fields:
9637
+ * - `code` — machine-readable classification, snake_case. Phase 1
9638
+ * surface: `'parse_error'` (default). Future cedar-wasm releases
9639
+ * ship structured codes; the classifier here uses message-pattern
9640
+ * heuristics until then (see `classifyCedarErrorMessage`).
9641
+ * - `message` — cedar-wasm's human-readable English. UI is
9642
+ * responsible for i18n / templating; we don't translate here.
9643
+ * - `line` / `column` — 1-based caret. Computed from the byte
9644
+ * `start` offset in cedar-wasm's `sourceLocations[]` against the
9645
+ * ORIGINAL policy text, so the caret matches what the user sees
9646
+ * in the textarea / editor.
9647
+ * - `context` — the offending byte slice (max 200 chars, truncated
9648
+ * with an ellipsis). Lets UIs render an inline highlight without
9649
+ * a second round trip.
9650
+ * - `offset` — 0-based byte offset (for editors that prefer offsets
9651
+ * to line/column; line/column is provided as a convenience).
9652
+ */
9653
+ interface PolicyValidationError {
9654
+ /**
9655
+ * Machine-readable code, snake_case. Currently a small set:
9656
+ * - `'parse_error'` — syntax / grammar failure (default)
9657
+ * - `'unexpected_end_of_input'` — incomplete policy
9658
+ * - `'unexpected_token'` — token didn't match expected production
9659
+ * - `'unknown_extension'` — referenced an unknown extension fn
9660
+ * - `'unknown'` — fallback when no heuristic matches
9661
+ * Callers that switch on this string MUST default to a generic
9662
+ * branch — the set will grow as cedar-wasm exposes structured codes.
9663
+ */
9664
+ code: string;
9665
+ /** Cedar's human-readable English diagnostic. */
9666
+ message: string;
9667
+ /** 1-based line in the original policy text where the error starts. */
9668
+ line?: number;
9669
+ /** 1-based column in the line (counts UTF-16 code units, matching JS String). */
9670
+ column?: number;
9671
+ /**
9672
+ * The raw policy slice that triggered the error, truncated to 200
9673
+ * chars with a trailing ellipsis when longer. Useful for UIs to
9674
+ * highlight the offending span without re-computing offsets.
9675
+ */
9676
+ context?: string;
9677
+ /** 0-based byte offset into the policy text (when known). */
9678
+ offset?: number;
9679
+ }
9680
+ /**
9681
+ * Opaque handle to a Cedar schema that has been parsed and cached
9682
+ * inside the wasm. Returned by `preparseSchema`; pass to `evaluate`.
9683
+ *
9684
+ * The wasm caches by string name, so the handle carries the auto-generated
9685
+ * id. Callers must treat the type as opaque.
9686
+ */
9687
+ interface SchemaHandle {
9688
+ readonly __cedar: 'schema';
9689
+ readonly name: string;
9690
+ }
9691
+ /** Opaque handle to a Cedar PolicySet. Returned by `preparsePolicySet`. */
9692
+ interface PolicySetHandle {
9693
+ readonly __cedar: 'policySet';
9694
+ readonly id: string;
9695
+ }
9696
+ /**
9697
+ * A Cedar entity in the JSON shape expected by the wasm.
9698
+ *
9699
+ * We keep this as `Record<string, unknown>` rather than importing the
9700
+ * detailed `EntityJson` type from `@cedar-policy/cedar-wasm` because the
9701
+ * SDK is consumed by browser bundlers; pulling in the d.ts would force
9702
+ * the wasm typings into browser builds (the runtime is still lazy-loaded).
9703
+ * Callers cast as needed; runtime validation is delegated to the wasm.
9704
+ */
9705
+ type CedarEntity = Record<string, unknown>;
9706
+ interface CedarEvaluateRequest {
9707
+ /** Cedar entity-uid expression, e.g. `Agent::"agent-1"`. */
9708
+ principal: string;
9709
+ /** Cedar entity-uid expression, e.g. `Action::"gmail.message.send"`. */
9710
+ action: string;
9711
+ /** Cedar entity-uid expression, e.g. `GmailThread::"thread-1"`. */
9712
+ resource: string;
9713
+ /** Free-form context dict (must match the schema's context shape). */
9714
+ context: Record<string, unknown>;
9715
+ }
9716
+ interface EvaluateInput {
9717
+ policySetHandle: PolicySetHandle;
9718
+ schemaHandle?: SchemaHandle;
9719
+ entities: ReadonlyArray<CedarEntity>;
9720
+ request: CedarEvaluateRequest;
9721
+ }
9722
+ interface EvaluateResult {
9723
+ decision: CedarDecision;
9724
+ /** Policy ids that determined the decision (Cedar's `diagnostics.reason`). */
9725
+ reasons: string[];
9726
+ /** Evaluation-time errors, if any. Empty array on success. */
9727
+ errors: CedarError[];
9728
+ }
9729
+ interface CedarEngine {
9730
+ preparseSchema(schemaText: string): SchemaHandle;
9731
+ preparsePolicySet(cedarText: string): PolicySetHandle;
9732
+ evaluate(input: EvaluateInput): EvaluateResult;
9733
+ }
9734
+ /**
9735
+ * Thrown when the Cedar wasm module cannot be loaded — typically because
9736
+ * the wrapper is running in a browser (the `/nodejs` subpath requires Node
9737
+ * `fs`), but also raised for any unexpected load-time failure.
9738
+ */
9739
+ declare class CedarEngineUnavailableError extends Error {
9740
+ readonly name = "CedarEngineUnavailableError";
9741
+ constructor(cause: unknown);
9742
+ }
9743
+ /**
9744
+ * Thrown by `preparseSchema` / `preparsePolicySet` when Cedar reports a
9745
+ * structured `{ type: 'failure', errors: [...] }` answer. Callers (e.g.
9746
+ * the Policy Registry lint) can inspect `errors` for diagnostics.
9747
+ *
9748
+ * Phase 2-1-H — `validationErrors` is a parallel, richer view of the
9749
+ * same failures with line / column / context derived against the
9750
+ * original policy text. The legacy `errors` field is preserved as-is
9751
+ * so call sites that only need the message text don't need to change.
9752
+ */
9753
+ declare class CedarParseError extends Error {
9754
+ readonly name = "CedarParseError";
9755
+ readonly errors: CedarError[];
9756
+ /**
9757
+ * Structured diagnostics with `{ code, message, line, column, context,
9758
+ * offset }`. Always non-empty when the throw is from cedar-wasm; may
9759
+ * be empty when constructed from a non-cedar-wasm path (e.g. when an
9760
+ * upstream caller wraps an unexpected throw).
9761
+ */
9762
+ readonly validationErrors: PolicyValidationError[];
9763
+ constructor(message: string, errors: CedarError[], validationErrors?: PolicyValidationError[]);
9764
+ }
9765
+ interface CedarDetailedError {
9766
+ message: string;
9767
+ code?: string | null;
9768
+ /**
9769
+ * Source spans reported by cedar-wasm's miette-backed diagnostic
9770
+ * pipeline. `start` / `end` are 0-based byte offsets into the policy
9771
+ * text. `label` is a short hint about what was expected. We type only
9772
+ * the subset we use; cedar-wasm may include additional fields.
9773
+ */
9774
+ sourceLocations?: ReadonlyArray<{
9775
+ start?: number;
9776
+ end?: number;
9777
+ label?: string | null;
9778
+ }> | null;
9779
+ /** Cascaded diagnostics — same shape as the top-level error. */
9780
+ related?: ReadonlyArray<CedarDetailedError> | null;
9781
+ }
9782
+ /**
9783
+ * Create (or reuse) the singleton Cedar engine.
9784
+ *
9785
+ * - First call performs the dynamic import of cedar-wasm.
9786
+ * - Subsequent calls return the cached Promise — TOCTOU-safe.
9787
+ * - If the in-flight load rejects, the cache is cleared so retries work.
9788
+ */
9789
+ declare function createCedarEngine(): Promise<CedarEngine>;
9790
+ /**
9791
+ * Phase 2-1-H — flatten cedar-wasm's `{ message, sourceLocations[],
9792
+ * related[] }` tree into a list of `PolicyValidationError` entries
9793
+ * with line/column derived against the original policy text.
9794
+ *
9795
+ * `related[]` entries are walked recursively and emitted as siblings
9796
+ * of the top-level error (cedar-wasm uses `related` for "and also..."
9797
+ * style cascade diagnostics — UIs typically render all of them, not
9798
+ * just the head).
9799
+ *
9800
+ * If cedar-wasm returns no `sourceLocations`, we still emit an entry
9801
+ * (without line/column) so the caller always sees at least one error
9802
+ * per failure path.
9803
+ *
9804
+ * @internal — Phase 2-1-H heuristic implementation. Exported for cross-package
9805
+ * reuse (API + agentd / remote-mcp future surfaces) and unit tests, but NOT a
9806
+ * stable public API. Will be replaced once cedar-wasm exposes structured
9807
+ * diagnostic codes upstream (tracked as Phase 2-2-I). Semver of `@vess-id/ai-identity`
9808
+ * may remove or rename this function without a major bump.
9809
+ */
9810
+ declare function buildValidationErrors(errors: ReadonlyArray<CedarDetailedError>, sourceText: string): PolicyValidationError[];
9811
+ /**
9812
+ * Heuristic classifier mapping cedar-wasm's English message text to a
9813
+ * stable snake_case code. cedar-wasm@4.11.0 does not yet expose a
9814
+ * structured `code` field (the `code` slot in `CedarDetailedError` is
9815
+ * always `null` for parse failures), so we match on substring patterns
9816
+ * that have proven stable across recent releases.
9817
+ *
9818
+ * If `cedarCode` is supplied (future cedar-wasm release) it wins.
9819
+ *
9820
+ * Returned codes (must stay in sync with the JSDoc on
9821
+ * `PolicyValidationError.code`):
9822
+ * - `parse_error` — generic parse failure (fallback)
9823
+ * - `unexpected_end_of_input` — incomplete policy
9824
+ * - `unexpected_token` — token didn't match expected production
9825
+ * - `unknown_extension` — referenced unknown extension fn
9826
+ * - `unknown` — message didn't match any pattern
9827
+ *
9828
+ * @internal — Phase 2-1-H heuristic implementation, same caveat as
9829
+ * `buildValidationErrors`. Will be replaced once cedar-wasm exposes structured
9830
+ * diagnostic codes upstream (Phase 2-2-I).
9831
+ */
9832
+ declare function classifyCedarErrorMessage(message: string, cedarCode?: string): string;
9833
+
9834
+ /**
9835
+ * buildCedarEntities — Cedar entity-list builder (Cedar unification Step 1).
9836
+ *
9837
+ * Spec ref:
9838
+ * - docs/specs/2026-05-24-cedar-unification-design.md §7.1
9839
+ * Phase 1 採用方針: entity attribute と context の **二重 bind**。本 helper は
9840
+ * entity 側のみを組み立て、`context.action.risk_level` は呼び出し側
9841
+ * (`CedarDecisionService.buildCedarEvaluateRequest`) が context にも別途
9842
+ * 注入する。これは Cedar 4.11.0 が schema-less な entity attribute 直参照を
9843
+ * policy text 内では制限するため、policy 内では `context.action.risk_level`
9844
+ * 経由を Phase 1 で採用するという rev 3 C1 で確定した設計判断による。
9845
+ *
9846
+ * Action entity の `attrs.risk_level` は本 helper の責務、
9847
+ * `context.action.risk_level` は CedarDecisionService の責務。
9848
+ * Phase 2+ で Cedar schema 導入時に context 側を撤去し entity 直参照に統一する。
9849
+ */
9850
+
9851
+ /**
9852
+ * Principal or resource descriptor accepted by {@link buildCedarEntities}.
9853
+ * `type` is the Cedar entity-type name (e.g., `Agent`, `User`, `GmailThread`).
9854
+ * `attrs` defaults to `{}` if omitted. `parents` is always `[]` in Phase 1
9855
+ * (entity hierarchy is reserved for Phase 2 schema work).
9856
+ */
9857
+ interface CedarEntityDescriptor {
9858
+ type: string;
9859
+ id: string;
9860
+ attrs?: Record<string, unknown>;
9861
+ }
9862
+ /**
9863
+ * Input contract for {@link buildCedarEntities}. `action` is the dotted
9864
+ * action name (e.g., `'gmail.message.send'`); the helper looks up the
9865
+ * Phase 1 risk level via {@link resolveActionRisk} and binds it as
9866
+ * `Action::"<id>".attrs.risk_level`.
9867
+ *
9868
+ * Context (including `context.action.risk_level`, `context.approval.granted`,
9869
+ * `context.environment.*`) is **not** built here — the caller (typically
9870
+ * `CedarDecisionService`) builds context separately because the same entities
9871
+ * are reused across Phase A / Phase B (approval=false / approval=true)
9872
+ * evaluations.
9873
+ */
9874
+ interface CedarEntitiesInput {
9875
+ principal: CedarEntityDescriptor;
9876
+ action: string;
9877
+ resource: CedarEntityDescriptor;
9878
+ }
9879
+ /**
9880
+ * Build the Cedar entity list (principal + action + resource) for a single
9881
+ * authorization evaluation.
9882
+ *
9883
+ * Returns exactly 3 entities, in stable order [principal, action, resource].
9884
+ * The Action entity gets `attrs.risk_level` populated from
9885
+ * {@link resolveActionRisk}. principal / resource pass through `attrs`
9886
+ * unchanged (defaulting to `{}` when omitted).
9887
+ *
9888
+ * Entity hierarchy (`parents`) is intentionally empty in Phase 1 — Phase 2
9889
+ * will introduce schema-driven parents (e.g., GmailThread → GmailLabel).
9890
+ */
9891
+ declare function buildCedarEntities(input: CedarEntitiesInput): CedarEntity[];
9892
+
9893
+ /**
9894
+ * Decision 7-value enum — A2A / AP2 aligned (Cedar unification Step 1).
9895
+ *
9896
+ * Spec ref:
9897
+ * - docs/specs/2026-05-24-cedar-unification-design.md §3
9898
+ * - decision #9 (Locked Decisions §2): A2A 互換 7 値、後方互換破壊 OK
9899
+ *
9900
+ * HTTP mapping (spec §3, line 169):
9901
+ * - `permit` → 200
9902
+ * - `auth_required` → 202 (replaces legacy `RequireApproval`)
9903
+ * - `input_required` → reserved for Phase 2+
9904
+ * - `denied` → 403 (explicit forbid policy match)
9905
+ * - `denied_default` → 403 (no permit policy matched)
9906
+ * - `denied_by_user` → 403 (HITL UI rejection)
9907
+ * - `indeterminate` → 500 (Cedar evaluation error, fail-closed)
9908
+ *
9909
+ * Phase 1 Step 1 scope: SDK enum + runtime guard only.
9910
+ * Step 2 (API layer) will rewire `CedarDecisionService` to emit these values
9911
+ * and replace the legacy 3-value `CedarDecisionValue` (`Permit | Forbid |
9912
+ * RequireApproval`) over the wire. Both types coexist during the transition.
9913
+ */
9914
+ /**
9915
+ * The 7 decision states a permission evaluator may emit. Lowercase + snake_case
9916
+ * to match A2A protocol naming conventions.
9917
+ */
9918
+ type Decision = 'permit' | 'auth_required' | 'input_required' | 'denied' | 'denied_default' | 'denied_by_user' | 'indeterminate';
9919
+ /**
9920
+ * Frozen ordered tuple of every {@link Decision} value. Useful for `it.each`
9921
+ * test enumeration, exhaustiveness assertions, and audit-log validation.
9922
+ *
9923
+ * The order is **stable** and is the canonical iteration order (permit first,
9924
+ * then approval gate, then input gate, then the 3 denied variants, then the
9925
+ * fail-closed indeterminate). Do not rely on alphabetic order.
9926
+ */
9927
+ declare const DECISION_VALUES: readonly ["permit", "auth_required", "input_required", "denied", "denied_default", "denied_by_user", "indeterminate"];
9928
+ /**
9929
+ * Runtime type guard for {@link Decision}. Returns `true` only if `value` is
9930
+ * one of the 7 canonical literals. Use this when validating wire payloads
9931
+ * (audit log rows, HTTP bodies, IPC) before narrowing to `Decision`.
9932
+ *
9933
+ * Legacy 3-value capitalized literals (`Permit`, `Forbid`, `RequireApproval`)
9934
+ * are **not** accepted; callers that still need to handle the old wire format
9935
+ * must do their own translation (Step 2 will provide the migration helper).
9936
+ */
9937
+ declare function isDecision(value: unknown): value is Decision;
9938
+
9939
+ /**
9940
+ * Action risk-level resolver — registry-driven (OpenQ-5 root fix).
9941
+ *
9942
+ * Spec refs:
9943
+ * - docs/specs/2026-05-27-action-risk-registry-driven.md §3
9944
+ * - docs/specs/2026-05-24-cedar-unification-design.md §7.2 (original Phase 1
9945
+ * suffix heuristic, now retained only as a fallback)
9946
+ *
9947
+ * Resolution order:
9948
+ * 1. If the action exists in ACTION_REGISTRY and declares a `risk`, return
9949
+ * that value — ACTION_REGISTRY is the single source of truth (matching
9950
+ * CLAUDE.md). This is what Cedar `context.action.risk_level` binds to,
9951
+ * so a developer's hand-curated `risk: 'high'` is now authoritative.
9952
+ * 2. Otherwise (unknown / not-yet-registered action) fall back to the
9953
+ * deterministic suffix heuristic below:
9954
+ * - write/send/delete-class suffixes → 'high'
9955
+ * - read/list/get-class suffixes → 'low'
9956
+ * - everything else → 'medium' (fail-safe)
9957
+ *
9958
+ * The suffix heuristic classifies by the **last dotted segment** of the
9959
+ * action name (e.g., `gmail.message.send` → `send` → 'high').
9960
+ *
9961
+ * Lookup is case-insensitive: input is lowercased before the registry Map
9962
+ * lookup (registry keys are all lowercase), so `gmail.message.TRASH` still
9963
+ * hits the registry `high` instead of mis-falling-back to the suffix value.
9964
+ */
9965
+ type ActionRisk = 'low' | 'medium' | 'high';
9966
+ /**
9967
+ * Resolve the risk level for a dotted action name.
9968
+ *
9969
+ * Registry-driven: a registered action returns its declared `risk`
9970
+ * (authoritative); unknown actions fall back to the suffix heuristic.
9971
+ *
9972
+ * Examples:
9973
+ * resolveActionRisk('os.secret.read') → 'high' (registry)
9974
+ * resolveActionRisk('gmail.message.trash') → 'high' (registry)
9975
+ * resolveActionRisk('jira.issue.transition') → 'high' (registry)
9976
+ * resolveActionRisk('unknown.connector.send') → 'high' (suffix fallback)
9977
+ * resolveActionRisk('unknown.connector.read') → 'low' (suffix fallback)
9978
+ * resolveActionRisk('unknown.connector.sync') → 'medium'(suffix fallback)
9979
+ *
9980
+ * Defensive defaults:
9981
+ * - empty / falsy input → 'medium' (fail-safe; never throws)
9982
+ * - unknown suffix → 'medium'
9983
+ */
9984
+ declare function resolveActionRisk(action: string | undefined | null): ActionRisk;
9985
+
8764
9986
  declare const version = "0.0.1";
8765
9987
 
8766
- export { type ABACPolicyEngine, ACTION_PARAMS_MAX_SIZE, ACTION_PREFIXES, ACTION_REGISTRY, AIdentityClient, type AIdentityConfig, AIdentityError, type APIAgent, type APICredential, APIVCManager, type AbacDecision, type AbacInput, type AcceptInvitationRequest, type AckEventResponse, type ActionInputSchema, type ActionMapping, type ActionMeta, type ActionParamDisplay, type ActionRegistry, type ActionRiskLevel, type Agent, type AgentCreateOptions, type AgentDIDConfig, AgentDIDManager, AgentManager, AgentStatus, AgentType, type AgentWithId, AllowAllAbac, type AnyProvider, type ApiKeyValidationResult, type AuditEvent, type AuditQuery, AuthProvider, type AuthState, AuthenticationError, type AutoApproveConfig, type BindingSource, type BuildKbJwtPayloadArgs, type BuildKbJwtPayloadDeps, CANONICAL_PROVIDERS, type CanonicalProvider, type CapabilityMeta, type CheckGrantPermissionRequest, type CheckGrantPermissionResult, type CheckPermissionInput, type CheckPermissionResult, type CollectContextRequest, type ConfirmGrantSuggestionRequest, type ConnectorAction, type ConnectorConfig, type ConnectorExecutionContext, type ConnectorResponse, type ConnectorResponseMetadata, type ConnectorTokenConfig, type ConstraintEvaluationResult, ConstraintEvaluator, type ConstraintEvaluatorOptions, type ConstraintViolation, type ConstraintWarning, type ContextBindingSource, type ContextProvider, type CreateGrantRequest, type CreateInvitationRequest, type CreateReceiptRequest, type CredentialRef, CredentialStatus, type CredentialStore, CredentialType, DEFAULT_CONSTRAINTS_BY_RISK, type DIDDocument, type DataAccessVC, type DecisionTrace, type DelegationVC, DeviceEnrollManager, type DeviceEnrollPollResult, type DeviceEnrollServerSideParams, type DeviceEnrollStartParams, type DeviceEnrollStartResult, type DisclosureFields, DummyCreds, DummyVpVerifier, type EmployeeVPRequest, type EvaluationContext, type ExternalActionRequest, FilesystemKeyStorage, GATEWAY_ERROR_CODE, GatewayClient, GatewayError, type GatewayErrorCode, type GatewayEvent, type GetEventsOptions, type GetEventsResponse, type GitHubConfig, type GoogleConfig, type Grant, type GrantConstraints, type GrantResource, GrantResourceType, GrantScope, GrantStatus, type GrantUsage, type IConnectorService, type IStateStore, type Intent, type IntentEvaluationResult, type IntentObligation, type IntentResource, type InternalHmacSignerKey, InvalidVPError, type Invitation, type InvitationRole, InvitationStatus, type IssueSDJWTVCRequest, type IssueSDJWTVCResult, type JiraBoard, type JiraConfig, type JiraIssue, type JiraIssueType, type JiraProject, type JiraSprint, type JiraStatus, type JiraUser, type JiraWorklog, type JsonSchema, JsonStateStore, KB_JWT_DEFAULT_LIFETIME_SECONDS, type KbJwtPayload, KeyManager, type KeyPairGenerationResult, type KeyStorageConfig, type KeyStorageProvider, LEGACY_RESOURCE_TYPE_MAP, MIN_SIGNER_KEY_BYTES, MemoryKeyStorage, NetworkError, type NormalizeIntentRequest, type NormalizedIntent, type OAuthAuthorizeRequest, type OAuthCallbackParams, type OAuthConnection, OAuthProvider, type OAuthToken, type OrganizationConfig, type OrganizationPermission, type OrganizationPolicy, type OrganizationVC, PROVIDER_ALIASES, type ParamBindingSource, type ParsedResourceType, type ParsedSignature, type PermissionConstraints, type PermissionMode, type PermissionResource, type PermissionRule, type PermissionTimeConstraint, type PermissionVcClaims, type PlanDelegationInput, type PlanDelegationResult, type PolicyCondition, type PolicyEvaluationResult, type PolicyInput, type PolicyRule, type PolicyTarget, type Provider, REAUTH_REQUIRED_ACTION, RESOURCE_TYPES, type ReBACChecker, type Receipt, type ReceiptListResult, type ReceiptOutcome, type ReceiptSearchQuery, ReceiptStatus, type Relation, type ResolvedTargets, type ResourceIdBinding, type ResourceRef, type ResourceScope, type ResourceType, type RiskAssessmentResult, type RiskFactor, type RiskLevel, SDJwtClient, SIGNATURE_HEADER, SIGNATURE_VERSION_PREFIX, ScopeUnmatchedError, type SecondaryBinding, type SignRequestArgs, SimpleRebac, type SlackConfig, StandardActionCategory, type SuggestGrantRequest, type SuggestedAction, type SuggestedConstraints, type SuggestedGrant, type SuggestedResource, type SuggestionRiskLevel, TIER_LIMITS, type TargetBindings, type TargetConstraint, TargetResolver, type TierLimits, type TimeWindowCheckResult, type TimeWindowConstraint, type ToolDefinition, type ToolInvocation, ToolManager, type ToolPermissionRequest, type ToolPermissionVC, type UnifiedResourceType, type UpdateGrantRequest, type UserIdentity, type UserIdentityConfig, type UserIdentityCreateOptions, UserIdentityManager, UserKeyPairManager, type UserTier, VALID_MCP_ACTIONS, VALID_MCP_TOOLS, VCExpiredError, VCManager, VCRevokedError, VCStatus, type VCTemplate, VCType, VPManager, type VPRequest, type VerifiablePresentation, type VerificationMethod, type VerifiedVcClaims, type VerifyInvitationResponse, type VerifyReceiptRequest, type VerifyReceiptResult, type VerifySDJWTVCResult, type VpVerifier, WRITE_ACTION_NAMES, type WeeklyReportData, type WeeklyReportSummary, buildCanonicalString, buildGrantIdFields, buildKbJwtPayload, canonicalizeAction, checkPermissionWithVP, configure, createAjv, createDidJwk, credentialStatusToVCStatus, defaultConstraintEvaluator, evaluateConstraints, extractProjectKey, extractPublicKey, extractPublicKeyFromDid, formatSignatureHeader, generateActionParamsDisplay, generateActionSummary, generateKeyPair, generateNonce, getActionAliases, getAllActionForms, getAllValidMcpActionNames, getClient, getDefaultDisclosureFields, getKeyIdFromDid, getRequiredRelations, getRequiredScopes, getTierLimits, getValidMcpActionNames, grantConstraintsToPermissionConstraints, grantToPermissionRules, indexActions, indexCapabilities, isActionEquivalent, isCanonicalProvider, isUnlimited, isValidDidJwk, isValidProvider, isWriteAction, loadActionRegistryFromFile, loadActionRegistryFromObject, normalizeDomain, normalizeMcpActionName, parseGrantAction, parseGrantResourceType, parseSignatureHeader, planDelegationForVC, publicKeysMatch, readVcExpSeconds, resolveActionsFromSelection, resolveProvider, resolveResourceType, resolveUserTier, sha256Hex, signJWT, signRequest, validateRegistryObject, vcStatusToCredentialStatus, verifyJWT, version };
9988
+ export { type ABACPolicyEngine, ACTION_PARAMS_MAX_SIZE, ACTION_PREFIXES, ACTION_REGISTRY, AIdentityClient, type AIdentityConfig, AIdentityError, type APIAgent, type APICredential, APIVCManager, type AbacDecision, type AbacInput, type AcceptInvitationRequest, type AckEventResponse, type ActionInputSchema, type ActionMapping, type ActionMeta, type ActionParamDisplay, type ActionRegistry, type ActionRisk, type ActionRiskLevel, type Agent, type AgentCreateOptions, type AgentDIDConfig, AgentDIDManager, AgentManager, AgentStatus, AgentType, type AgentWithId, AllowAllAbac, type AnyProvider, type ApiKeyValidationResult, type ApprovalContext, type AuditEvent, type AuditQuery, AuthProvider, type AuthState, AuthenticationError, type AutoApproveConfig, type BindingSource, type BuildKbJwtPayloadArgs, type BuildKbJwtPayloadDeps, CANONICAL_PROVIDERS, type CanonicalProvider, type CapabilityMeta, type CedarDecision, type CedarDecisionDiagnostic, type CedarDecisionValue, type CedarEngine, CedarEngineUnavailableError, type CedarEntitiesInput, type CedarEntity, type CedarEntityDescriptor, type CedarError, type CedarEvaluateRequest, CedarParseError, type CedarPolicySetHandle, type CedarSchema, type CedarSchemaHandle, type CheckGrantPermissionRequest, type CheckGrantPermissionResult, type CheckPermissionInput, type CheckPermissionResult, type CollectContextRequest, type ConfirmGrantSuggestionRequest, type ConnectorAction, type ConnectorConfig, type ConnectorExecutionContext, type ConnectorResponse, type ConnectorResponseMetadata, type ConnectorTokenConfig, type ConstraintEvaluationResult, ConstraintEvaluator, type ConstraintEvaluatorOptions, type ConstraintViolation, type ConstraintWarning, type ContextBindingSource, type ContextProvider, type CreateGrantRequest, type CreateInvitationRequest, type CreateReceiptRequest, type CredentialRef, CredentialStatus, type CredentialStore, CredentialType, DECISION_VALUES, DEFAULT_CONSTRAINTS_BY_RISK, type DIDDocument, type DataAccessVC, type Decision, type DecisionTrace, type DelegationVC, DeviceEnrollManager, type DeviceEnrollPollResult, type DeviceEnrollServerSideParams, type DeviceEnrollStartParams, type DeviceEnrollStartResult, type DisclosureFields, DummyCreds, DummyVpVerifier, type EmployeeVPRequest, type EvaluateInput, type EvaluateResult, type EvaluationContext, type ExternalActionRequest, FilesystemKeyStorage, GATEWAY_ERROR_CODE, GatewayClient, GatewayError, type GatewayErrorCode, type GatewayEvent, type GetEventsOptions, type GetEventsResponse, type GitHubConfig, type GoogleConfig, type Grant, type GrantConstraints, type GrantResource, GrantResourceType, GrantScope, GrantStatus, type GrantUsage, type IConnectorService, type IStateStore, type Intent, type IntentEvaluationResult, type IntentObligation, type IntentResource, type InternalHmacSignerKey, InvalidVPError, type Invitation, type InvitationRole, InvitationStatus, type IssueSDJWTVCRequest, type IssueSDJWTVCResult, type JiraBoard, type JiraConfig, type JiraIssue, type JiraIssueLink, type JiraIssueLinkType, type JiraIssueType, type JiraProject, type JiraSprint, type JiraStatus, type JiraUser, type JiraWorklog, type JsonSchema, JsonStateStore, KB_JWT_DEFAULT_LIFETIME_SECONDS, type KbJwtPayload, KeyManager, type KeyPairGenerationResult, type KeyStorageConfig, type KeyStorageProvider, LEGACY_RESOURCE_TYPE_MAP, MIN_SIGNER_KEY_BYTES, MemoryKeyStorage, NetworkError, type NormalizeIntentRequest, type NormalizedIntent, type OAuthAuthorizeRequest, type OAuthCallbackParams, type OAuthConnection, OAuthProvider, type OAuthToken, type OrganizationConfig, type OrganizationPermission, type OrganizationPolicy, type OrganizationVC, PHASE_1_VC_LAYER, PROVIDER_ALIASES, type ParamBindingSource, type ParsedResourceType, type ParsedSignature, type PermissionConstraints, type PermissionMode, type PermissionResource, type PermissionRule, type PermissionTimeConstraint, type PermissionVcClaims, type PermissionVcClaims_V2, type PermissionVcClaims_V3, type Phase1VcLayer, type PlanDelegationInput, type PlanDelegationResult, type PolicyCondition, type PolicyEvaluationResult, type PolicyInput, type PolicyRef, type PolicyRefInline, type PolicyRefReference, type PolicyRule, type PolicySetHandle, type PolicyTarget, type PolicyValidationError, type Provider, REAUTH_REQUIRED_ACTION, RESOURCE_TYPES, type ReBACChecker, type Receipt, type ReceiptListResult, type ReceiptOutcome, type ReceiptSearchQuery, ReceiptStatus, type Relation, type ResolvedTargets, type ResourceIdBinding, type ResourceRef, type ResourceScope, type ResourceType, type RiskAssessmentResult, type RiskFactor, type RiskLevel, SDJwtClient, SIGNATURE_HEADER, SIGNATURE_VERSION_PREFIX, type SchemaHandle, ScopeUnmatchedError, type SecondaryBinding, type SignRequestArgs, SimpleRebac, type SlackConfig, StandardActionCategory, type SuggestGrantRequest, type SuggestedAction, type SuggestedConstraints, type SuggestedGrant, type SuggestedResource, type SuggestionRiskLevel, TIER_LIMITS, type TargetBindings, type TargetConstraint, TargetResolver, type TierLimits, type TimeWindowCheckResult, type TimeWindowConstraint, type ToolDefinition, type ToolInvocation, ToolManager, type ToolPermissionRequest, type ToolPermissionVC, type UnifiedResourceType, type UpdateGrantRequest, type UserIdentity, type UserIdentityConfig, type UserIdentityCreateOptions, UserIdentityManager, UserKeyPairManager, type UserTier, VALID_MCP_ACTIONS, VALID_MCP_TOOLS, VCExpiredError, VCManager, VCRevokedError, VCStatus, type VCTemplate, VCType, VPManager, type VPRequest, type VcApprovalClaim, type VerifiablePresentation, type VerificationMethod, type VerifiedVcClaims, type VerifyInvitationResponse, type VerifyReceiptRequest, type VerifyReceiptResult, type VerifySDJWTVCResult, type VpVerifier, WRITE_ACTION_NAMES, type WeeklyReportData, type WeeklyReportSummary, buildCanonicalString, buildCedarEntities, buildGrantIdFields, buildKbJwtPayload, buildPhase1VcClaims, buildValidationErrors, canonicalizeAction, checkPermissionWithVP, classifyCedarErrorMessage, configure, createAjv, createCedarEngine, createDidJwk, credentialStatusToVCStatus, defaultConstraintEvaluator, evaluateConstraints, extractProjectKey, extractPublicKey, extractPublicKeyFromDid, formatSignatureHeader, generateActionParamsDisplay, generateActionSummary, generateKeyPair, generateNonce, getActionAliases, getAllActionForms, getAllValidMcpActionNames, getClient, getDefaultDisclosureFields, getKeyIdFromDid, getRequiredRelations, getRequiredScopes, getTierLimits, getValidMcpActionNames, grantConstraintsToPermissionConstraints, grantToPermissionRules, indexActions, indexCapabilities, isActionEquivalent, isCanonicalProvider, isDecision, isPolicyRefInline, isPolicyRefReference, isUnlimited, isValidDidJwk, isValidProvider, isWriteAction, loadActionRegistryFromFile, loadActionRegistryFromObject, normalizeDomain, normalizeMcpActionName, parseGrantAction, parseGrantResourceType, parseSignatureHeader, planDelegationForVC, publicKeysMatch, readVcExpSeconds, resolveActionRisk, resolveActionsFromSelection, resolveProvider, resolveResourceType, resolveUserTier, sha256Hex, signJWT, signRequest, validateRegistryObject, vcStatusToCredentialStatus, verifyJWT, version };