@vess-id/ai-identity 0.12.0 → 0.14.0-alpha.1

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 (56) hide show
  1. package/dist/index.d.mts +1252 -8
  2. package/dist/index.d.ts +12 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +611 -27
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +596 -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 +245 -6
  52. package/dist/types/permission-vc.d.ts.map +1 -1
  53. package/dist/types/tier.d.ts.map +1 -1
  54. package/dist/utils/freemail-domains.d.ts +13 -0
  55. package/dist/utils/freemail-domains.d.ts.map +1 -0
  56. 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,43 @@ 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;
969
+ /**
970
+ * Cedar policy bindings (複数) — 1 つの委任スコープに複数の policy が AND/OR
971
+ * で適用されるケース (例: calendarDomain 宛先制約 + timeWindow forbid)。
972
+ * 後方互換のため単数 `policy_ref` は維持し、発行時は `policy_refs[0]` を
973
+ * ミラーする。読み手は policy_refs を優先し、無ければ policy_ref を単要素配列に
974
+ * 正規化する。Cedar 評価では全 ref を 1 つの PolicySet に集約 (permit=OR,
975
+ * forbid=override で AND)。
976
+ */
977
+ policy_refs?: PolicyRef[];
877
978
  }
878
979
  /**
879
- * Permission VC Claims - the canonical credential claims format.
980
+ * Permission VC Claims v2 the pre-Cedar canonical credential claims format.
880
981
  *
881
982
  * This is what gets signed into the SD-JWT VC. All VC issuance paths
882
983
  * (VCService, RemoteVCIssuerService, PermissionVCManager) MUST produce
883
- * claims conforming to this interface.
984
+ * claims conforming to either this interface or {@link PermissionVcClaims_V3}.
884
985
  *
885
986
  * The Grant → VC normalization layer converts:
886
987
  * - GrantResource[] + actions[] → PermissionRule[]
887
988
  * - GrantConstraints → PermissionConstraints (per-rule)
888
989
  * - Grant metadata → top-level claims fields
990
+ *
991
+ * @remarks Phase 1 Step 2 renamed the original `PermissionVcClaims` to
992
+ * `PermissionVcClaims_V2`. The exported alias {@link PermissionVcClaims}
993
+ * is now a union of V2 + {@link PermissionVcClaims_V3}, preserving
994
+ * existing import sites (they will accept both shapes).
889
995
  */
890
- interface PermissionVcClaims {
996
+ interface PermissionVcClaims_V2 {
891
997
  /** Schema version */
892
998
  v: '2';
893
999
  /** Credential type discriminator */
@@ -930,6 +1036,86 @@ interface PermissionVcClaims {
930
1036
  /** Delegated permission rules (the core authorization data) */
931
1037
  delegates: PermissionRule[];
932
1038
  }
1039
+ /**
1040
+ * Permission VC Claims v3 — Cedar + RAR Phase 1 schema.
1041
+ *
1042
+ * Inherits all V2 fields and adds two Phase-1-aware extensions:
1043
+ * - `cedar_schema_ref?` — pointer to the Cedar schema fragment the
1044
+ * delegates were authored against. **Phase 1 unused** (the SDK ships a
1045
+ * single global schema fragment generated by connector-plugin codegen,
1046
+ * per Implementation plan §1.1). Reserved for Phase 2+ per-policy schema
1047
+ * switching.
1048
+ * - `layer?` — chain hierarchy layer. **Phase 2+ only**; Phase 1 issuance
1049
+ * pins this to `'agent_permission'` via {@link buildPhase1VcClaims}.
1050
+ * Direct assignment is discouraged (ESLint rule planned in Step 5).
1051
+ *
1052
+ * Spec refs:
1053
+ * - docs/specs/2026-05-23-cedar-rar-permission-redesign.md §3.1
1054
+ * - docs/specs/2026-05-23-cedar-rar-implementation-plan-phase1.md Task 2.1 / 2.5
1055
+ */
1056
+ /**
1057
+ * Bug B 真因修正 (β, 2026-05-28) — VC=mandate semantic を invoke 時 Cedar も
1058
+ * 信じるため、approval の事実 (誰がいつ何を approve したか) を VC に焼き込む
1059
+ * signed self-attestation。SD-protected (`_sd` 経由 disclosure)、SD-JWT 署名で
1060
+ * 改竄不可。invoke 時 Cedar context.approval の最優先 source として採用。
1061
+ *
1062
+ * Forward compat: A2A AP2 Mandate (IntentMandate / CartMandate / PaymentMandate)
1063
+ * との projection は Phase 2 spec で別途定義。本 field 名は内部
1064
+ * ApprovalContext (snake_case) と一貫。
1065
+ *
1066
+ * Spec ref: docs/superpowers/plans/2026-05-28-bug-b-fix-beta-vc-embed-approval.md
1067
+ */
1068
+ interface VcApprovalClaim {
1069
+ /** `req_<uuid>` — 元 approval-request id (claimVC 元 request の id)。 */
1070
+ request_id: string;
1071
+ /** `outcome_<uuid>` — APPROVAL_OUTCOME audit event id (§11.1 join key)。 */
1072
+ outcome_id: string;
1073
+ /** approver の user id、または 'system' (auto-approve 経路)。最大 128 chars。 */
1074
+ granted_by: string;
1075
+ /** ISO-8601 timestamp of the approval action. */
1076
+ granted_at: string;
1077
+ }
1078
+ interface PermissionVcClaims_V3 extends Omit<PermissionVcClaims_V2, 'v'> {
1079
+ /** Schema version — v3 adds Cedar policy_ref support and chain hierarchy fields. */
1080
+ v: '3';
1081
+ /**
1082
+ * Cedar schema fragment reference (Phase 2+ per-policy schema switching).
1083
+ * Phase 1: unused; SDK uses connector-plugin codegen global schema.
1084
+ */
1085
+ cedar_schema_ref?: {
1086
+ /** e.g. `cedar_schema_2026_05_23_v1`. */
1087
+ schema_id: string;
1088
+ /** sha256 of the schema fragment (hex). */
1089
+ schema_hash: string;
1090
+ };
1091
+ /**
1092
+ * 4-layer chain (Org Policy → User Grant → Agent Permission → Sub-Agent Delegation).
1093
+ * Phase 1 では `buildPhase1VcClaims()` factory 経由で `'agent_permission'` が固定セットされる。
1094
+ * Phase 2+ では本フィールドを **required** に格上げする予定 (V3.1 schema)。
1095
+ * 直接代入は禁止 (Phase 1 では factory を使うこと、Phase 2+ では ESLint rule で強制)。
1096
+ * 詳細: design spec §3.1, §6.1 / Phase 1 plan Task 2.5。
1097
+ */
1098
+ layer?: 'org_policy' | 'user_grant' | 'agent_permission' | 'sub_agent_delegation';
1099
+ /**
1100
+ * Bug B 真因修正 (β, 2026-05-28) — approval メタを VC に焼き込む。
1101
+ * VC=mandate なので「この VC が発行されたこと自体が approve の証拠」だが、
1102
+ * invoke 時 Cedar に `context.approval.granted == true` を渡せるよう
1103
+ * back-ref を明示。本 field 不在 = base path (legacy 互換、Cedar は token-
1104
+ * ledger 経由 fallback)。{@link VcApprovalClaim} 参照。
1105
+ */
1106
+ approval?: VcApprovalClaim;
1107
+ }
1108
+ /**
1109
+ * Permission VC Claims (canonical union of v2 + v3).
1110
+ *
1111
+ * All existing import sites referencing `PermissionVcClaims` continue to
1112
+ * compile because:
1113
+ * - Code that only produced V2 still produces a value assignable to the
1114
+ * union.
1115
+ * - Code that consumes the union can narrow on `claims.v === '3'` to
1116
+ * access V3-only fields.
1117
+ */
1118
+ type PermissionVcClaims = PermissionVcClaims_V2 | PermissionVcClaims_V3;
933
1119
  /**
934
1120
  * Build synchronized grant_id / grant_ids fields for PermissionVcClaims.
935
1121
  * Guarantees grant_id === grant_ids[0].
@@ -1088,6 +1274,59 @@ declare function parseGrantAction(grantAction: string): {
1088
1274
  provider: string;
1089
1275
  action: string;
1090
1276
  };
1277
+ /**
1278
+ * The single layer value Phase 1 VC issuance is allowed to emit.
1279
+ *
1280
+ * companion design spec §3.1 defines a 4-layer enum
1281
+ * (`'org_policy' | 'user_grant' | 'agent_permission' | 'sub_agent_delegation'`),
1282
+ * but Phase 1 only issues at the `agent_permission` layer. The other 3
1283
+ * layers unlock in Phase 2+.
1284
+ *
1285
+ * Spec refs:
1286
+ * - docs/specs/2026-05-23-cedar-rar-implementation-plan-phase1.md Task 2.5 (rev 5)
1287
+ * - docs/specs/2026-05-23-cedar-rar-permission-redesign.md §3.1 Phase 1 layer 固定 note
1288
+ */
1289
+ declare const PHASE_1_VC_LAYER: "agent_permission";
1290
+ /** Literal type of {@link PHASE_1_VC_LAYER}. */
1291
+ type Phase1VcLayer = typeof PHASE_1_VC_LAYER;
1292
+ /**
1293
+ * Build a {@link PermissionVcClaims_V3} object with `layer` pinned to
1294
+ * {@link PHASE_1_VC_LAYER} (`'agent_permission'`).
1295
+ *
1296
+ * **This factory is mandatory for Phase 1 VC issuance.** Direct assignment
1297
+ * of `layer` on a V3 claims literal is discouraged and will be guarded by
1298
+ * an ESLint rule once Step 5 wires usage in
1299
+ * `packages/api/src/grant/services/remote-vc-issuer.service.ts`. Phase 2+
1300
+ * will relax or delete this factory when the other 3 layers unlock.
1301
+ *
1302
+ * The input `base` type explicitly omits `layer` so passing it is a
1303
+ * compile-time error — guaranteeing call-sites cannot accidentally
1304
+ * smuggle a non-Phase-1 layer value through.
1305
+ *
1306
+ * @example
1307
+ * ```ts
1308
+ * import { buildPhase1VcClaims } from '@vess-id/ai-identity'
1309
+ *
1310
+ * const claims = buildPhase1VcClaims({
1311
+ * v: '3',
1312
+ * type: 'PermissionCredential',
1313
+ * iss: userDid,
1314
+ * sub: agentDid,
1315
+ * iat: now,
1316
+ * exp: now + 3600,
1317
+ * jti,
1318
+ * project_id,
1319
+ * grant_ids,
1320
+ * grant_id,
1321
+ * session_id,
1322
+ * delegates,
1323
+ * })
1324
+ * // claims.layer is type-narrowed to 'agent_permission'
1325
+ * ```
1326
+ */
1327
+ declare function buildPhase1VcClaims(base: Omit<PermissionVcClaims_V3, 'layer'>): PermissionVcClaims_V3 & {
1328
+ layer: Phase1VcLayer;
1329
+ };
1091
1330
 
1092
1331
  /**
1093
1332
  * Grant(許可)関連の型定義
@@ -1345,6 +1584,27 @@ interface GrantConstraints {
1345
1584
  targets?: TargetConstraint[];
1346
1585
  /** 自動承認設定 */
1347
1586
  autoApprove?: AutoApproveConfig;
1587
+ /**
1588
+ * Cedar 一元化 Step 4 — data-in-policy 許可パターン (Cedar `like` wildcard).
1589
+ *
1590
+ * 例: `["*@vess.id", "*@vesslabs.ai"]` → 各 recipient.address に対し
1591
+ * `like "*@vess.id" || like "*@vesslabs.ai"` の Cedar permit rule が emit される.
1592
+ *
1593
+ * Spec: docs/specs/2026-05-24-cedar-unification-design.md §4.1 / §13 Step 4
1594
+ *
1595
+ * Phase 1 では primarily Gmail recipient address のために使う (recipient.address).
1596
+ * Phase 2+ で per-target-binding な格納先 (channel.id 等) に拡張する.
1597
+ */
1598
+ allow_patterns?: string[];
1599
+ /**
1600
+ * Cedar 一元化 Step 4 — data-in-policy 拒否パターン (Cedar `like` wildcard).
1601
+ *
1602
+ * 例: `["*@competitor.com"]` → 該当 recipient で Cedar `forbid` rule が emit される.
1603
+ * Cedar forbid-overrides-permit semantics により approval があっても denied.
1604
+ *
1605
+ * Spec: docs/specs/2026-05-24-cedar-unification-design.md §4.1 / §4.2 / §13 Step 4
1606
+ */
1607
+ deny_patterns?: string[];
1348
1608
  }
1349
1609
  /**
1350
1610
  * Grant作成リクエスト
@@ -1523,6 +1783,54 @@ declare function grantConstraintsToPermissionConstraints(constraints: GrantConst
1523
1783
  * ```
1524
1784
  */
1525
1785
  declare function grantToPermissionRules(resources: GrantResource[], actions: string[], constraints: GrantConstraints, grantId?: string): PermissionRule[];
1786
+ /**
1787
+ * ApprovalContext — Cedar 一元化 Step 3.5.
1788
+ *
1789
+ * Spec refs:
1790
+ * - docs/specs/2026-05-24-cedar-unification-design.md §6 (approvalContext
1791
+ * DTO + token ledger)
1792
+ * - docs/specs/2026-05-24-cedar-unification-design.md §7.2 (Cedar
1793
+ * context.approval shape)
1794
+ * - docs/specs/2026-05-24-cedar-unification-design.md §11.1
1795
+ * (`via_approval` event lifecycle)
1796
+ *
1797
+ * Carried in the body of the VC issuance API on the **retry path** (i.e.
1798
+ * after a user clicked 承認 in the approval UI). The server consumes the
1799
+ * single-use `token` against the approval-token ledger atomically and then
1800
+ * injects `{ granted: true, request_id, outcome_id }` into the Cedar
1801
+ * `context.approval` so a policy that previously returned `auth_required`
1802
+ * now returns `permit`.
1803
+ *
1804
+ * Identifier formats (canonical, enforced upstream):
1805
+ * - `request_id` : `'req_' + uuid`
1806
+ * - `outcome_id` : `'outcome_' + uuid`
1807
+ * - `token` : `'tok_' + uuid`
1808
+ * - `granted_at` : ISO-8601 timestamp
1809
+ * - `granted_by` : user id, or the literal `'system'` for auto-approve
1810
+ *
1811
+ * Replay protection invariant (spec §6):
1812
+ * The `token` is **single-use**. Once consumed by the ledger, a second
1813
+ * submission MUST be rejected as `denied_by_user` (ephemeral — does not
1814
+ * poison subsequent fresh requests; §5.1 OpenQ-D1 resolution).
1815
+ */
1816
+ interface ApprovalContext {
1817
+ /** `req_<uuid>` — the approval-request id embedded in the initial
1818
+ * `auth_required` audit event. Used to reverse-link the outcome to the
1819
+ * triggering invocation. */
1820
+ request_id: string;
1821
+ /** `outcome_<uuid>` — the approval_outcome event id (Step 6 surfaces this
1822
+ * as a first-class row, Step 3.5 only carries it through the ledger). */
1823
+ outcome_id: string;
1824
+ /** `tok_<uuid>` — single-use token. Consumed atomically. */
1825
+ token: string;
1826
+ /** True for 承認, false for 拒否. Step 3.5 only honors `true` (the `false`
1827
+ * path is handled by emitting `denied_by_user` directly in the UI). */
1828
+ granted: boolean;
1829
+ /** ISO-8601 timestamp of the approval action. */
1830
+ granted_at: string;
1831
+ /** user id or `'system'` for auto-approve. */
1832
+ granted_by: string;
1833
+ }
1526
1834
 
1527
1835
  /**
1528
1836
  * Receipt(証跡)関連の型定義
@@ -2212,6 +2520,63 @@ interface JiraIssue {
2212
2520
  };
2213
2521
  };
2214
2522
  }
2523
+ /**
2524
+ * Jira 課題リンク種別 (issueLinkType)
2525
+ *
2526
+ * 例: Blocks (inward: "is blocked by", outward: "blocks"),
2527
+ * Relates (inward/outward: "relates to"),
2528
+ * Cloners (inward: "is cloned by", outward: "clones")
2529
+ *
2530
+ * Jira REST API v3: GET /rest/api/3/issueLinkType で取得される。
2531
+ */
2532
+ interface JiraIssueLinkType {
2533
+ /** リンク種別の内部 ID */
2534
+ id: string;
2535
+ /** リンク種別の名前 (例: "Blocks") */
2536
+ name: string;
2537
+ /** リンク先 → 自分 方向の表示文字列 (例: "is blocked by") */
2538
+ inward: string;
2539
+ /** 自分 → リンク先 方向の表示文字列 (例: "blocks") */
2540
+ outward: string;
2541
+ /** REST API self URL */
2542
+ self?: string;
2543
+ }
2544
+ /**
2545
+ * Jira 課題間リンク (issueLink)
2546
+ *
2547
+ * Jira REST API v3 の課題 read で `fields.issuelinks[]` として返る形式に対応。
2548
+ * delete 時はこの `id` を渡す。
2549
+ */
2550
+ interface JiraIssueLink {
2551
+ /** リンクの内部 ID (delete 時に必要) */
2552
+ id: string;
2553
+ /** リンク種別 */
2554
+ type: JiraIssueLinkType;
2555
+ /** inward 方向のリンク先 (自分が「is blocked by other」のとき、other がここに入る) */
2556
+ inwardIssue?: {
2557
+ id: string;
2558
+ key: string;
2559
+ self?: string;
2560
+ fields?: {
2561
+ summary?: string;
2562
+ status?: JiraStatus;
2563
+ issuetype?: JiraIssueType;
2564
+ };
2565
+ };
2566
+ /** outward 方向のリンク先 (自分が「blocks other」のとき、other がここに入る) */
2567
+ outwardIssue?: {
2568
+ id: string;
2569
+ key: string;
2570
+ self?: string;
2571
+ fields?: {
2572
+ summary?: string;
2573
+ status?: JiraStatus;
2574
+ issuetype?: JiraIssueType;
2575
+ };
2576
+ };
2577
+ /** REST API self URL */
2578
+ self?: string;
2579
+ }
2215
2580
  /**
2216
2581
  * JIRA作業ログ
2217
2582
  */
@@ -2724,6 +3089,66 @@ interface ConfirmGrantSuggestionRequest {
2724
3089
  */
2725
3090
  declare const DEFAULT_CONSTRAINTS_BY_RISK: Record<SuggestionRiskLevel, SuggestedConstraints>;
2726
3091
 
3092
+ /**
3093
+ * Cedar-specific schema / policy / decision wire types.
3094
+ *
3095
+ * Phase 1 Step 2: Type-only declarations. The actual Cedar engine wrapper
3096
+ * lives in Step 1's lane (`packages/sdk/src/policy/cedar-engine.ts` — not
3097
+ * touched here). This module exposes the opaque handle types that other
3098
+ * services (PEP, decision audit, policy registry) use to communicate
3099
+ * *about* Cedar without depending on cedar-wasm internals.
3100
+ *
3101
+ * Spec refs:
3102
+ * - docs/specs/2026-05-23-cedar-rar-implementation-plan-phase1.md Task 2.2
3103
+ * - docs/specs/2026-05-23-cedar-rar-permission-redesign.md §3.3 (Cedar schema)
3104
+ */
3105
+ /**
3106
+ * Cedar schema (entity types + actions + context shapes).
3107
+ *
3108
+ * Opaque to AIdentity at the type level — the concrete JSON shape follows
3109
+ * the Cedar spec and is produced by `connector-plugin` codegen. Treat
3110
+ * instances as black-box payloads that round-trip through the Cedar engine.
3111
+ */
3112
+ interface CedarSchema {
3113
+ }
3114
+ /**
3115
+ * Opaque handle returned by the Cedar engine after parsing / compiling a
3116
+ * PolicySet. Implementations may store wasm pointers, validation state, etc.
3117
+ * Consumers MUST NOT introspect the shape.
3118
+ */
3119
+ interface CedarPolicySetHandle {
3120
+ }
3121
+ /**
3122
+ * Opaque handle returned by the Cedar engine after parsing / compiling a
3123
+ * Schema. See {@link CedarPolicySetHandle} for usage notes.
3124
+ */
3125
+ interface CedarSchemaHandle {
3126
+ }
3127
+ /**
3128
+ * 3-valued decision returned by the AIdentity Decision Service after the
3129
+ * 2-phase Cedar evaluation.
3130
+ *
3131
+ * Mapping:
3132
+ * - `Permit` → Cedar Permit && no constraints failed
3133
+ * - `Forbid` → Cedar Forbid OR no matching permit
3134
+ * - `RequireApproval` → AIdentity-specific intermediate state (e.g.,
3135
+ * high-risk action that needs human approval).
3136
+ * Cedar itself only emits Permit / Forbid; the
3137
+ * decision service derives `RequireApproval` from
3138
+ * annotated policies or constraint-level escalation.
3139
+ */
3140
+ type CedarDecisionValue = 'Permit' | 'Forbid' | 'RequireApproval';
3141
+ /**
3142
+ * Diagnostic information accompanying a Cedar decision. Surfaced to audit
3143
+ * logs and (in shadow mode) to legacy/Cedar parity checks.
3144
+ */
3145
+ interface CedarDecisionDiagnostic {
3146
+ /** IDs of the Cedar policies that matched the request (in evaluation order). */
3147
+ matched_policy_ids: string[];
3148
+ /** Cedar diagnostics passthrough (parse / validation errors, if any). */
3149
+ errors: string[];
3150
+ }
3151
+
2727
3152
  type UserTier = 'free' | 'pro' | 'team';
2728
3153
  interface TierLimits {
2729
3154
  maxProjects: number;
@@ -3920,7 +4345,7 @@ interface ActionMeta {
3920
4345
  input_schema?: JsonSchema;
3921
4346
  constraints?: Record<string, unknown>;
3922
4347
  effects?: string[];
3923
- risk?: RiskLevel;
4348
+ risk: RiskLevel;
3924
4349
  target_bindings?: TargetBindings;
3925
4350
  version: string;
3926
4351
  }
@@ -4276,6 +4701,11 @@ declare const ACTION_REGISTRY: {
4276
4701
  priority?: undefined;
4277
4702
  assigneeAccountId?: undefined;
4278
4703
  transitionId?: undefined;
4704
+ typeName?: undefined;
4705
+ inwardIssueKey?: undefined;
4706
+ outwardIssueKey?: undefined;
4707
+ commentBody?: undefined;
4708
+ linkId?: undefined;
4279
4709
  file_path?: undefined;
4280
4710
  content?: undefined;
4281
4711
  command?: undefined;
@@ -4372,6 +4802,11 @@ declare const ACTION_REGISTRY: {
4372
4802
  priority?: undefined;
4373
4803
  assigneeAccountId?: undefined;
4374
4804
  transitionId?: undefined;
4805
+ typeName?: undefined;
4806
+ inwardIssueKey?: undefined;
4807
+ outwardIssueKey?: undefined;
4808
+ commentBody?: undefined;
4809
+ linkId?: undefined;
4375
4810
  file_path?: undefined;
4376
4811
  content?: undefined;
4377
4812
  command?: undefined;
@@ -4471,6 +4906,11 @@ declare const ACTION_REGISTRY: {
4471
4906
  priority?: undefined;
4472
4907
  assigneeAccountId?: undefined;
4473
4908
  transitionId?: undefined;
4909
+ typeName?: undefined;
4910
+ inwardIssueKey?: undefined;
4911
+ outwardIssueKey?: undefined;
4912
+ commentBody?: undefined;
4913
+ linkId?: undefined;
4474
4914
  file_path?: undefined;
4475
4915
  content?: undefined;
4476
4916
  command?: undefined;
@@ -4580,6 +5020,11 @@ declare const ACTION_REGISTRY: {
4580
5020
  priority?: undefined;
4581
5021
  assigneeAccountId?: undefined;
4582
5022
  transitionId?: undefined;
5023
+ typeName?: undefined;
5024
+ inwardIssueKey?: undefined;
5025
+ outwardIssueKey?: undefined;
5026
+ commentBody?: undefined;
5027
+ linkId?: undefined;
4583
5028
  file_path?: undefined;
4584
5029
  content?: undefined;
4585
5030
  command?: undefined;
@@ -4686,6 +5131,11 @@ declare const ACTION_REGISTRY: {
4686
5131
  priority?: undefined;
4687
5132
  assigneeAccountId?: undefined;
4688
5133
  transitionId?: undefined;
5134
+ typeName?: undefined;
5135
+ inwardIssueKey?: undefined;
5136
+ outwardIssueKey?: undefined;
5137
+ commentBody?: undefined;
5138
+ linkId?: undefined;
4689
5139
  file_path?: undefined;
4690
5140
  content?: undefined;
4691
5141
  command?: undefined;
@@ -4789,6 +5239,11 @@ declare const ACTION_REGISTRY: {
4789
5239
  priority?: undefined;
4790
5240
  assigneeAccountId?: undefined;
4791
5241
  transitionId?: undefined;
5242
+ typeName?: undefined;
5243
+ inwardIssueKey?: undefined;
5244
+ outwardIssueKey?: undefined;
5245
+ commentBody?: undefined;
5246
+ linkId?: undefined;
4792
5247
  file_path?: undefined;
4793
5248
  content?: undefined;
4794
5249
  command?: undefined;
@@ -4895,6 +5350,11 @@ declare const ACTION_REGISTRY: {
4895
5350
  priority?: undefined;
4896
5351
  assigneeAccountId?: undefined;
4897
5352
  transitionId?: undefined;
5353
+ typeName?: undefined;
5354
+ inwardIssueKey?: undefined;
5355
+ outwardIssueKey?: undefined;
5356
+ commentBody?: undefined;
5357
+ linkId?: undefined;
4898
5358
  file_path?: undefined;
4899
5359
  content?: undefined;
4900
5360
  command?: undefined;
@@ -4997,6 +5457,11 @@ declare const ACTION_REGISTRY: {
4997
5457
  priority?: undefined;
4998
5458
  assigneeAccountId?: undefined;
4999
5459
  transitionId?: undefined;
5460
+ typeName?: undefined;
5461
+ inwardIssueKey?: undefined;
5462
+ outwardIssueKey?: undefined;
5463
+ commentBody?: undefined;
5464
+ linkId?: undefined;
5000
5465
  file_path?: undefined;
5001
5466
  content?: undefined;
5002
5467
  command?: undefined;
@@ -5109,6 +5574,11 @@ declare const ACTION_REGISTRY: {
5109
5574
  priority?: undefined;
5110
5575
  assigneeAccountId?: undefined;
5111
5576
  transitionId?: undefined;
5577
+ typeName?: undefined;
5578
+ inwardIssueKey?: undefined;
5579
+ outwardIssueKey?: undefined;
5580
+ commentBody?: undefined;
5581
+ linkId?: undefined;
5112
5582
  file_path?: undefined;
5113
5583
  content?: undefined;
5114
5584
  command?: undefined;
@@ -5224,6 +5694,11 @@ declare const ACTION_REGISTRY: {
5224
5694
  priority?: undefined;
5225
5695
  assigneeAccountId?: undefined;
5226
5696
  transitionId?: undefined;
5697
+ typeName?: undefined;
5698
+ inwardIssueKey?: undefined;
5699
+ outwardIssueKey?: undefined;
5700
+ commentBody?: undefined;
5701
+ linkId?: undefined;
5227
5702
  file_path?: undefined;
5228
5703
  content?: undefined;
5229
5704
  command?: undefined;
@@ -5323,6 +5798,11 @@ declare const ACTION_REGISTRY: {
5323
5798
  priority?: undefined;
5324
5799
  assigneeAccountId?: undefined;
5325
5800
  transitionId?: undefined;
5801
+ typeName?: undefined;
5802
+ inwardIssueKey?: undefined;
5803
+ outwardIssueKey?: undefined;
5804
+ commentBody?: undefined;
5805
+ linkId?: undefined;
5326
5806
  file_path?: undefined;
5327
5807
  content?: undefined;
5328
5808
  command?: undefined;
@@ -5441,6 +5921,11 @@ declare const ACTION_REGISTRY: {
5441
5921
  priority?: undefined;
5442
5922
  assigneeAccountId?: undefined;
5443
5923
  transitionId?: undefined;
5924
+ typeName?: undefined;
5925
+ inwardIssueKey?: undefined;
5926
+ outwardIssueKey?: undefined;
5927
+ commentBody?: undefined;
5928
+ linkId?: undefined;
5444
5929
  file_path?: undefined;
5445
5930
  content?: undefined;
5446
5931
  command?: undefined;
@@ -5545,6 +6030,11 @@ declare const ACTION_REGISTRY: {
5545
6030
  priority?: undefined;
5546
6031
  assigneeAccountId?: undefined;
5547
6032
  transitionId?: undefined;
6033
+ typeName?: undefined;
6034
+ inwardIssueKey?: undefined;
6035
+ outwardIssueKey?: undefined;
6036
+ commentBody?: undefined;
6037
+ linkId?: undefined;
5548
6038
  file_path?: undefined;
5549
6039
  content?: undefined;
5550
6040
  command?: undefined;
@@ -5644,6 +6134,11 @@ declare const ACTION_REGISTRY: {
5644
6134
  priority?: undefined;
5645
6135
  assigneeAccountId?: undefined;
5646
6136
  transitionId?: undefined;
6137
+ typeName?: undefined;
6138
+ inwardIssueKey?: undefined;
6139
+ outwardIssueKey?: undefined;
6140
+ commentBody?: undefined;
6141
+ linkId?: undefined;
5647
6142
  file_path?: undefined;
5648
6143
  content?: undefined;
5649
6144
  command?: undefined;
@@ -5759,6 +6254,11 @@ declare const ACTION_REGISTRY: {
5759
6254
  priority?: undefined;
5760
6255
  assigneeAccountId?: undefined;
5761
6256
  transitionId?: undefined;
6257
+ typeName?: undefined;
6258
+ inwardIssueKey?: undefined;
6259
+ outwardIssueKey?: undefined;
6260
+ commentBody?: undefined;
6261
+ linkId?: undefined;
5762
6262
  file_path?: undefined;
5763
6263
  content?: undefined;
5764
6264
  command?: undefined;
@@ -5870,6 +6370,11 @@ declare const ACTION_REGISTRY: {
5870
6370
  priority?: undefined;
5871
6371
  assigneeAccountId?: undefined;
5872
6372
  transitionId?: undefined;
6373
+ typeName?: undefined;
6374
+ inwardIssueKey?: undefined;
6375
+ outwardIssueKey?: undefined;
6376
+ commentBody?: undefined;
6377
+ linkId?: undefined;
5873
6378
  file_path?: undefined;
5874
6379
  content?: undefined;
5875
6380
  command?: undefined;
@@ -5980,6 +6485,11 @@ declare const ACTION_REGISTRY: {
5980
6485
  priority?: undefined;
5981
6486
  assigneeAccountId?: undefined;
5982
6487
  transitionId?: undefined;
6488
+ typeName?: undefined;
6489
+ inwardIssueKey?: undefined;
6490
+ outwardIssueKey?: undefined;
6491
+ commentBody?: undefined;
6492
+ linkId?: undefined;
5983
6493
  file_path?: undefined;
5984
6494
  content?: undefined;
5985
6495
  command?: undefined;
@@ -6083,6 +6593,11 @@ declare const ACTION_REGISTRY: {
6083
6593
  priority?: undefined;
6084
6594
  assigneeAccountId?: undefined;
6085
6595
  transitionId?: undefined;
6596
+ typeName?: undefined;
6597
+ inwardIssueKey?: undefined;
6598
+ outwardIssueKey?: undefined;
6599
+ commentBody?: undefined;
6600
+ linkId?: undefined;
6086
6601
  file_path?: undefined;
6087
6602
  content?: undefined;
6088
6603
  command?: undefined;
@@ -6237,6 +6752,11 @@ declare const ACTION_REGISTRY: {
6237
6752
  priority?: undefined;
6238
6753
  assigneeAccountId?: undefined;
6239
6754
  transitionId?: undefined;
6755
+ typeName?: undefined;
6756
+ inwardIssueKey?: undefined;
6757
+ outwardIssueKey?: undefined;
6758
+ commentBody?: undefined;
6759
+ linkId?: undefined;
6240
6760
  file_path?: undefined;
6241
6761
  content?: undefined;
6242
6762
  command?: undefined;
@@ -6402,6 +6922,11 @@ declare const ACTION_REGISTRY: {
6402
6922
  priority?: undefined;
6403
6923
  assigneeAccountId?: undefined;
6404
6924
  transitionId?: undefined;
6925
+ typeName?: undefined;
6926
+ inwardIssueKey?: undefined;
6927
+ outwardIssueKey?: undefined;
6928
+ commentBody?: undefined;
6929
+ linkId?: undefined;
6405
6930
  file_path?: undefined;
6406
6931
  content?: undefined;
6407
6932
  command?: undefined;
@@ -6512,6 +7037,11 @@ declare const ACTION_REGISTRY: {
6512
7037
  priority?: undefined;
6513
7038
  assigneeAccountId?: undefined;
6514
7039
  transitionId?: undefined;
7040
+ typeName?: undefined;
7041
+ inwardIssueKey?: undefined;
7042
+ outwardIssueKey?: undefined;
7043
+ commentBody?: undefined;
7044
+ linkId?: undefined;
6515
7045
  file_path?: undefined;
6516
7046
  content?: undefined;
6517
7047
  command?: undefined;
@@ -6610,6 +7140,11 @@ declare const ACTION_REGISTRY: {
6610
7140
  priority?: undefined;
6611
7141
  assigneeAccountId?: undefined;
6612
7142
  transitionId?: undefined;
7143
+ typeName?: undefined;
7144
+ inwardIssueKey?: undefined;
7145
+ outwardIssueKey?: undefined;
7146
+ commentBody?: undefined;
7147
+ linkId?: undefined;
6613
7148
  file_path?: undefined;
6614
7149
  content?: undefined;
6615
7150
  command?: undefined;
@@ -6710,6 +7245,11 @@ declare const ACTION_REGISTRY: {
6710
7245
  priority?: undefined;
6711
7246
  assigneeAccountId?: undefined;
6712
7247
  transitionId?: undefined;
7248
+ typeName?: undefined;
7249
+ inwardIssueKey?: undefined;
7250
+ outwardIssueKey?: undefined;
7251
+ commentBody?: undefined;
7252
+ linkId?: undefined;
6713
7253
  file_path?: undefined;
6714
7254
  content?: undefined;
6715
7255
  command?: undefined;
@@ -6812,6 +7352,11 @@ declare const ACTION_REGISTRY: {
6812
7352
  priority?: undefined;
6813
7353
  assigneeAccountId?: undefined;
6814
7354
  transitionId?: undefined;
7355
+ typeName?: undefined;
7356
+ inwardIssueKey?: undefined;
7357
+ outwardIssueKey?: undefined;
7358
+ commentBody?: undefined;
7359
+ linkId?: undefined;
6815
7360
  file_path?: undefined;
6816
7361
  content?: undefined;
6817
7362
  command?: undefined;
@@ -6916,6 +7461,11 @@ declare const ACTION_REGISTRY: {
6916
7461
  priority?: undefined;
6917
7462
  assigneeAccountId?: undefined;
6918
7463
  transitionId?: undefined;
7464
+ typeName?: undefined;
7465
+ inwardIssueKey?: undefined;
7466
+ outwardIssueKey?: undefined;
7467
+ commentBody?: undefined;
7468
+ linkId?: undefined;
6919
7469
  file_path?: undefined;
6920
7470
  content?: undefined;
6921
7471
  command?: undefined;
@@ -7023,6 +7573,11 @@ declare const ACTION_REGISTRY: {
7023
7573
  priority?: undefined;
7024
7574
  assigneeAccountId?: undefined;
7025
7575
  transitionId?: undefined;
7576
+ typeName?: undefined;
7577
+ inwardIssueKey?: undefined;
7578
+ outwardIssueKey?: undefined;
7579
+ commentBody?: undefined;
7580
+ linkId?: undefined;
7026
7581
  file_path?: undefined;
7027
7582
  content?: undefined;
7028
7583
  command?: undefined;
@@ -7122,6 +7677,11 @@ declare const ACTION_REGISTRY: {
7122
7677
  priority?: undefined;
7123
7678
  assigneeAccountId?: undefined;
7124
7679
  transitionId?: undefined;
7680
+ typeName?: undefined;
7681
+ inwardIssueKey?: undefined;
7682
+ outwardIssueKey?: undefined;
7683
+ commentBody?: undefined;
7684
+ linkId?: undefined;
7125
7685
  file_path?: undefined;
7126
7686
  content?: undefined;
7127
7687
  command?: undefined;
@@ -7241,6 +7801,11 @@ declare const ACTION_REGISTRY: {
7241
7801
  startAt?: undefined;
7242
7802
  issueIdOrKey?: undefined;
7243
7803
  transitionId?: undefined;
7804
+ typeName?: undefined;
7805
+ inwardIssueKey?: undefined;
7806
+ outwardIssueKey?: undefined;
7807
+ commentBody?: undefined;
7808
+ linkId?: undefined;
7244
7809
  file_path?: undefined;
7245
7810
  content?: undefined;
7246
7811
  command?: undefined;
@@ -7356,6 +7921,11 @@ declare const ACTION_REGISTRY: {
7356
7921
  projectKey?: undefined;
7357
7922
  issueTypeName?: undefined;
7358
7923
  transitionId?: undefined;
7924
+ typeName?: undefined;
7925
+ inwardIssueKey?: undefined;
7926
+ outwardIssueKey?: undefined;
7927
+ commentBody?: undefined;
7928
+ linkId?: undefined;
7359
7929
  file_path?: undefined;
7360
7930
  content?: undefined;
7361
7931
  command?: undefined;
@@ -7455,6 +8025,11 @@ declare const ACTION_REGISTRY: {
7455
8025
  priority?: undefined;
7456
8026
  assigneeAccountId?: undefined;
7457
8027
  transitionId?: undefined;
8028
+ typeName?: undefined;
8029
+ inwardIssueKey?: undefined;
8030
+ outwardIssueKey?: undefined;
8031
+ commentBody?: undefined;
8032
+ linkId?: undefined;
7458
8033
  file_path?: undefined;
7459
8034
  content?: undefined;
7460
8035
  command?: undefined;
@@ -7557,6 +8132,11 @@ declare const ACTION_REGISTRY: {
7557
8132
  priority?: undefined;
7558
8133
  assigneeAccountId?: undefined;
7559
8134
  transitionId?: undefined;
8135
+ typeName?: undefined;
8136
+ inwardIssueKey?: undefined;
8137
+ outwardIssueKey?: undefined;
8138
+ commentBody?: undefined;
8139
+ linkId?: undefined;
7560
8140
  file_path?: undefined;
7561
8141
  content?: undefined;
7562
8142
  command?: undefined;
@@ -7659,6 +8239,11 @@ declare const ACTION_REGISTRY: {
7659
8239
  issueTypeName?: undefined;
7660
8240
  priority?: undefined;
7661
8241
  assigneeAccountId?: undefined;
8242
+ typeName?: undefined;
8243
+ inwardIssueKey?: undefined;
8244
+ outwardIssueKey?: undefined;
8245
+ commentBody?: undefined;
8246
+ linkId?: undefined;
7662
8247
  file_path?: undefined;
7663
8248
  content?: undefined;
7664
8249
  command?: undefined;
@@ -7766,6 +8351,11 @@ declare const ACTION_REGISTRY: {
7766
8351
  priority?: undefined;
7767
8352
  assigneeAccountId?: undefined;
7768
8353
  transitionId?: undefined;
8354
+ typeName?: undefined;
8355
+ inwardIssueKey?: undefined;
8356
+ outwardIssueKey?: undefined;
8357
+ commentBody?: undefined;
8358
+ linkId?: undefined;
7769
8359
  file_path?: undefined;
7770
8360
  content?: undefined;
7771
8361
  command?: undefined;
@@ -7796,6 +8386,224 @@ declare const ACTION_REGISTRY: {
7796
8386
  secondary?: undefined;
7797
8387
  };
7798
8388
  version: string;
8389
+ } | {
8390
+ action: string;
8391
+ resource_type: string;
8392
+ required_relations: string[];
8393
+ required_scopes: string[];
8394
+ capability: string;
8395
+ input_schema: {
8396
+ type: string;
8397
+ properties: {
8398
+ typeName: {
8399
+ type: string;
8400
+ minLength: number;
8401
+ description: string;
8402
+ };
8403
+ inwardIssueKey: {
8404
+ type: string;
8405
+ minLength: number;
8406
+ };
8407
+ outwardIssueKey: {
8408
+ type: string;
8409
+ minLength: number;
8410
+ };
8411
+ commentBody: {
8412
+ type: string;
8413
+ };
8414
+ channel?: undefined;
8415
+ text?: undefined;
8416
+ thread_ts?: undefined;
8417
+ username?: undefined;
8418
+ icon_emoji?: undefined;
8419
+ blocks?: undefined;
8420
+ userId?: undefined;
8421
+ latest?: undefined;
8422
+ oldest?: undefined;
8423
+ limit?: undefined;
8424
+ inclusive?: undefined;
8425
+ cursor?: undefined;
8426
+ ts?: undefined;
8427
+ title?: undefined;
8428
+ body?: undefined;
8429
+ labels?: undefined;
8430
+ assignees?: undefined;
8431
+ state?: undefined;
8432
+ sort?: undefined;
8433
+ direction?: undefined;
8434
+ per_page?: undefined;
8435
+ page?: undefined;
8436
+ issue_number?: undefined;
8437
+ query?: undefined;
8438
+ maxResults?: undefined;
8439
+ messageId?: undefined;
8440
+ to?: undefined;
8441
+ subject?: undefined;
8442
+ cc?: undefined;
8443
+ bcc?: undefined;
8444
+ threadId?: undefined;
8445
+ inReplyTo?: undefined;
8446
+ references?: undefined;
8447
+ messageIds?: undefined;
8448
+ calendarId?: undefined;
8449
+ timeMin?: undefined;
8450
+ timeMax?: undefined;
8451
+ eventId?: undefined;
8452
+ summary?: undefined;
8453
+ description?: undefined;
8454
+ start?: undefined;
8455
+ end?: undefined;
8456
+ attendees?: undefined;
8457
+ location?: undefined;
8458
+ recent?: undefined;
8459
+ projectKeyOrId?: undefined;
8460
+ type?: undefined;
8461
+ boardId?: undefined;
8462
+ sprintId?: undefined;
8463
+ jql?: undefined;
8464
+ startAt?: undefined;
8465
+ issueIdOrKey?: undefined;
8466
+ projectKey?: undefined;
8467
+ issueTypeName?: undefined;
8468
+ priority?: undefined;
8469
+ assigneeAccountId?: undefined;
8470
+ transitionId?: undefined;
8471
+ linkId?: undefined;
8472
+ file_path?: undefined;
8473
+ content?: undefined;
8474
+ command?: undefined;
8475
+ working_directory?: undefined;
8476
+ env_profile?: undefined;
8477
+ timeout_seconds?: undefined;
8478
+ };
8479
+ required: string[];
8480
+ additionalProperties: boolean;
8481
+ };
8482
+ constraints: {
8483
+ rate_bucket: string;
8484
+ };
8485
+ effects: string[];
8486
+ risk: string;
8487
+ target_bindings: {
8488
+ resource_id: {
8489
+ source: "param";
8490
+ param: string;
8491
+ derive: "project_key";
8492
+ required?: undefined;
8493
+ key?: undefined;
8494
+ multi?: undefined;
8495
+ separator?: undefined;
8496
+ default?: undefined;
8497
+ fallback_param?: undefined;
8498
+ };
8499
+ secondary?: undefined;
8500
+ };
8501
+ version: string;
8502
+ } | {
8503
+ action: string;
8504
+ resource_type: string;
8505
+ required_relations: string[];
8506
+ required_scopes: string[];
8507
+ capability: string;
8508
+ input_schema: {
8509
+ type: string;
8510
+ properties: {
8511
+ linkId: {
8512
+ type: string;
8513
+ minLength: number;
8514
+ description: string;
8515
+ };
8516
+ channel?: undefined;
8517
+ text?: undefined;
8518
+ thread_ts?: undefined;
8519
+ username?: undefined;
8520
+ icon_emoji?: undefined;
8521
+ blocks?: undefined;
8522
+ userId?: undefined;
8523
+ latest?: undefined;
8524
+ oldest?: undefined;
8525
+ limit?: undefined;
8526
+ inclusive?: undefined;
8527
+ cursor?: undefined;
8528
+ ts?: undefined;
8529
+ title?: undefined;
8530
+ body?: undefined;
8531
+ labels?: undefined;
8532
+ assignees?: undefined;
8533
+ state?: undefined;
8534
+ sort?: undefined;
8535
+ direction?: undefined;
8536
+ per_page?: undefined;
8537
+ page?: undefined;
8538
+ issue_number?: undefined;
8539
+ query?: undefined;
8540
+ maxResults?: undefined;
8541
+ messageId?: undefined;
8542
+ to?: undefined;
8543
+ subject?: undefined;
8544
+ cc?: undefined;
8545
+ bcc?: undefined;
8546
+ threadId?: undefined;
8547
+ inReplyTo?: undefined;
8548
+ references?: undefined;
8549
+ messageIds?: undefined;
8550
+ calendarId?: undefined;
8551
+ timeMin?: undefined;
8552
+ timeMax?: undefined;
8553
+ eventId?: undefined;
8554
+ summary?: undefined;
8555
+ description?: undefined;
8556
+ start?: undefined;
8557
+ end?: undefined;
8558
+ attendees?: undefined;
8559
+ location?: undefined;
8560
+ recent?: undefined;
8561
+ projectKeyOrId?: undefined;
8562
+ type?: undefined;
8563
+ boardId?: undefined;
8564
+ sprintId?: undefined;
8565
+ jql?: undefined;
8566
+ startAt?: undefined;
8567
+ issueIdOrKey?: undefined;
8568
+ projectKey?: undefined;
8569
+ issueTypeName?: undefined;
8570
+ priority?: undefined;
8571
+ assigneeAccountId?: undefined;
8572
+ transitionId?: undefined;
8573
+ typeName?: undefined;
8574
+ inwardIssueKey?: undefined;
8575
+ outwardIssueKey?: undefined;
8576
+ commentBody?: undefined;
8577
+ file_path?: undefined;
8578
+ content?: undefined;
8579
+ command?: undefined;
8580
+ working_directory?: undefined;
8581
+ env_profile?: undefined;
8582
+ timeout_seconds?: undefined;
8583
+ };
8584
+ required: string[];
8585
+ additionalProperties: boolean;
8586
+ };
8587
+ constraints: {
8588
+ rate_bucket: string;
8589
+ };
8590
+ effects: string[];
8591
+ risk: string;
8592
+ target_bindings: {
8593
+ resource_id: {
8594
+ source: "param";
8595
+ param: string;
8596
+ required?: undefined;
8597
+ key?: undefined;
8598
+ multi?: undefined;
8599
+ separator?: undefined;
8600
+ default?: undefined;
8601
+ fallback_param?: undefined;
8602
+ derive?: undefined;
8603
+ };
8604
+ secondary?: undefined;
8605
+ };
8606
+ version: string;
7799
8607
  } | {
7800
8608
  action: string;
7801
8609
  resource_type: string;
@@ -7865,6 +8673,11 @@ declare const ACTION_REGISTRY: {
7865
8673
  priority?: undefined;
7866
8674
  assigneeAccountId?: undefined;
7867
8675
  transitionId?: undefined;
8676
+ typeName?: undefined;
8677
+ inwardIssueKey?: undefined;
8678
+ outwardIssueKey?: undefined;
8679
+ commentBody?: undefined;
8680
+ linkId?: undefined;
7868
8681
  content?: undefined;
7869
8682
  command?: undefined;
7870
8683
  working_directory?: undefined;
@@ -7966,6 +8779,11 @@ declare const ACTION_REGISTRY: {
7966
8779
  priority?: undefined;
7967
8780
  assigneeAccountId?: undefined;
7968
8781
  transitionId?: undefined;
8782
+ typeName?: undefined;
8783
+ inwardIssueKey?: undefined;
8784
+ outwardIssueKey?: undefined;
8785
+ commentBody?: undefined;
8786
+ linkId?: undefined;
7969
8787
  command?: undefined;
7970
8788
  working_directory?: undefined;
7971
8789
  env_profile?: undefined;
@@ -8077,6 +8895,11 @@ declare const ACTION_REGISTRY: {
8077
8895
  priority?: undefined;
8078
8896
  assigneeAccountId?: undefined;
8079
8897
  transitionId?: undefined;
8898
+ typeName?: undefined;
8899
+ inwardIssueKey?: undefined;
8900
+ outwardIssueKey?: undefined;
8901
+ commentBody?: undefined;
8902
+ linkId?: undefined;
8080
8903
  file_path?: undefined;
8081
8904
  content?: undefined;
8082
8905
  };
@@ -8605,6 +9428,19 @@ declare function resolveUserTier(tier: string | undefined | null): UserTier;
8605
9428
  */
8606
9429
  declare function getTierLimits(tier: string | undefined | null): TierLimits;
8607
9430
 
9431
+ /**
9432
+ * フリーメール / コンシューマ向けメールドメインのリスト。
9433
+ * grant の internalDomains で「ドメイン全体ワイルドカード (*@<freemail>)」を
9434
+ * 許可することを禁止するために使う (個別アドレス x@gmail.com は許可)。
9435
+ * 理由: *@gmail.com を「社内ドメイン」として自動許可すると、全 Gmail ユーザー
9436
+ * 宛が無条件許可になり危険。
9437
+ *
9438
+ * 網羅性は完璧でなくてよい (主要なもの)。後から追加可能な Set 構造。
9439
+ */
9440
+ declare const FREEMAIL_DOMAINS: ReadonlySet<string>;
9441
+ /** ドメインがフリーメールか判定 (小文字化して比較)。 */
9442
+ declare function isFreemailDomain(domain: string): boolean;
9443
+
8608
9444
  /**
8609
9445
  * P1-A14a-1 / Threat Model S4 — canonical-string + signature-header
8610
9446
  * helpers for HMAC body signing of internal HTTP requests.
@@ -8761,6 +9597,414 @@ interface SignRequestArgs {
8761
9597
  */
8762
9598
  declare function signRequest(key: InternalHmacSignerKey, args: SignRequestArgs): string;
8763
9599
 
9600
+ /**
9601
+ * CedarEngine — minimal wrapper around `@cedar-policy/cedar-wasm/nodejs`.
9602
+ *
9603
+ * Phase 1 Step 1 scope (server-side / Node-runtime only):
9604
+ * - preparseSchema : ingest Cedar schema text → opaque SchemaHandle
9605
+ * - preparsePolicySet: ingest Cedar PolicySet text → opaque PolicySetHandle
9606
+ * - evaluate : run statefulIsAuthorized against preparsed handles
9607
+ *
9608
+ * Browser callers receive `CedarEngineUnavailableError` because the
9609
+ * `/nodejs` subpath depends on Node `fs` to instantiate the wasm.
9610
+ *
9611
+ * Performance notes (companion design spec Appendix C, PoC 2026-05-23):
9612
+ * - statefulIsAuthorized + preparsed cache: p50 0.067ms / p99 0.076ms
9613
+ * (~9x faster than re-parsing every call). The wasm caches preparsed
9614
+ * handles internally keyed by string name/id, so the opaque handles
9615
+ * we expose are thin wrappers around an auto-generated id.
9616
+ *
9617
+ * Concurrency / TOCTOU (Cedar design spec rev 5/6, fix C3):
9618
+ * - `createCedarEngine()` caches the in-flight Promise (not the resolved
9619
+ * engine). Two parallel callers therefore share the same load — no
9620
+ * duplicated dynamic import of the 4.1 MB wasm.
9621
+ * - On load failure the cached promise is cleared so the next caller can
9622
+ * retry. This avoids permanently poisoning the module after a transient
9623
+ * failure (e.g. wasm streaming compile blip).
9624
+ *
9625
+ * Design ref: docs/specs/2026-05-23-cedar-rar-permission-redesign.md
9626
+ * Plan ref: docs/specs/2026-05-23-cedar-rar-implementation-plan-phase1.md
9627
+ */
9628
+ /**
9629
+ * Decision domain exposed by the wrapper. Cedar's wasm uses lowercase
9630
+ * `'allow' | 'deny'`; we normalize to the spec's casing so callers can
9631
+ * pattern-match on a single canonical form across the codebase.
9632
+ */
9633
+ type CedarDecision = 'Allow' | 'Deny';
9634
+ /**
9635
+ * Structured error returned for evaluation-time problems (policy execution
9636
+ * errors). Parse / schema errors are surfaced at preparse time as thrown
9637
+ * `CedarParseError`s instead.
9638
+ */
9639
+ interface CedarError {
9640
+ /** Policy id that errored, if attributable. */
9641
+ policyId?: string;
9642
+ /** Human-readable message from Cedar. */
9643
+ message: string;
9644
+ /** Optional structured diagnostic code from Cedar. */
9645
+ code?: string;
9646
+ }
9647
+ /**
9648
+ * Phase 2-1-H — structured policy validation error surfaced by
9649
+ * `CedarParseError.validationErrors` (and re-exported as a public type
9650
+ * so API / UI callers don't have to re-implement source-location math).
9651
+ *
9652
+ * One `PolicyValidationError` entry corresponds to one cedar-wasm
9653
+ * diagnostic (top-level `errors[]` entries + their `related[]`
9654
+ * descendants are flattened into a single list, since callers always
9655
+ * want to render every diagnostic — the related chain is metadata about
9656
+ * the top-level failure, not a separate parse).
9657
+ *
9658
+ * Fields:
9659
+ * - `code` — machine-readable classification, snake_case. Phase 1
9660
+ * surface: `'parse_error'` (default). Future cedar-wasm releases
9661
+ * ship structured codes; the classifier here uses message-pattern
9662
+ * heuristics until then (see `classifyCedarErrorMessage`).
9663
+ * - `message` — cedar-wasm's human-readable English. UI is
9664
+ * responsible for i18n / templating; we don't translate here.
9665
+ * - `line` / `column` — 1-based caret. Computed from the byte
9666
+ * `start` offset in cedar-wasm's `sourceLocations[]` against the
9667
+ * ORIGINAL policy text, so the caret matches what the user sees
9668
+ * in the textarea / editor.
9669
+ * - `context` — the offending byte slice (max 200 chars, truncated
9670
+ * with an ellipsis). Lets UIs render an inline highlight without
9671
+ * a second round trip.
9672
+ * - `offset` — 0-based byte offset (for editors that prefer offsets
9673
+ * to line/column; line/column is provided as a convenience).
9674
+ */
9675
+ interface PolicyValidationError {
9676
+ /**
9677
+ * Machine-readable code, snake_case. Currently a small set:
9678
+ * - `'parse_error'` — syntax / grammar failure (default)
9679
+ * - `'unexpected_end_of_input'` — incomplete policy
9680
+ * - `'unexpected_token'` — token didn't match expected production
9681
+ * - `'unknown_extension'` — referenced an unknown extension fn
9682
+ * - `'unknown'` — fallback when no heuristic matches
9683
+ * Callers that switch on this string MUST default to a generic
9684
+ * branch — the set will grow as cedar-wasm exposes structured codes.
9685
+ */
9686
+ code: string;
9687
+ /** Cedar's human-readable English diagnostic. */
9688
+ message: string;
9689
+ /** 1-based line in the original policy text where the error starts. */
9690
+ line?: number;
9691
+ /** 1-based column in the line (counts UTF-16 code units, matching JS String). */
9692
+ column?: number;
9693
+ /**
9694
+ * The raw policy slice that triggered the error, truncated to 200
9695
+ * chars with a trailing ellipsis when longer. Useful for UIs to
9696
+ * highlight the offending span without re-computing offsets.
9697
+ */
9698
+ context?: string;
9699
+ /** 0-based byte offset into the policy text (when known). */
9700
+ offset?: number;
9701
+ }
9702
+ /**
9703
+ * Opaque handle to a Cedar schema that has been parsed and cached
9704
+ * inside the wasm. Returned by `preparseSchema`; pass to `evaluate`.
9705
+ *
9706
+ * The wasm caches by string name, so the handle carries the auto-generated
9707
+ * id. Callers must treat the type as opaque.
9708
+ */
9709
+ interface SchemaHandle {
9710
+ readonly __cedar: 'schema';
9711
+ readonly name: string;
9712
+ }
9713
+ /** Opaque handle to a Cedar PolicySet. Returned by `preparsePolicySet`. */
9714
+ interface PolicySetHandle {
9715
+ readonly __cedar: 'policySet';
9716
+ readonly id: string;
9717
+ }
9718
+ /**
9719
+ * A Cedar entity in the JSON shape expected by the wasm.
9720
+ *
9721
+ * We keep this as `Record<string, unknown>` rather than importing the
9722
+ * detailed `EntityJson` type from `@cedar-policy/cedar-wasm` because the
9723
+ * SDK is consumed by browser bundlers; pulling in the d.ts would force
9724
+ * the wasm typings into browser builds (the runtime is still lazy-loaded).
9725
+ * Callers cast as needed; runtime validation is delegated to the wasm.
9726
+ */
9727
+ type CedarEntity = Record<string, unknown>;
9728
+ interface CedarEvaluateRequest {
9729
+ /** Cedar entity-uid expression, e.g. `Agent::"agent-1"`. */
9730
+ principal: string;
9731
+ /** Cedar entity-uid expression, e.g. `Action::"gmail.message.send"`. */
9732
+ action: string;
9733
+ /** Cedar entity-uid expression, e.g. `GmailThread::"thread-1"`. */
9734
+ resource: string;
9735
+ /** Free-form context dict (must match the schema's context shape). */
9736
+ context: Record<string, unknown>;
9737
+ }
9738
+ interface EvaluateInput {
9739
+ policySetHandle: PolicySetHandle;
9740
+ schemaHandle?: SchemaHandle;
9741
+ entities: ReadonlyArray<CedarEntity>;
9742
+ request: CedarEvaluateRequest;
9743
+ }
9744
+ interface EvaluateResult {
9745
+ decision: CedarDecision;
9746
+ /** Policy ids that determined the decision (Cedar's `diagnostics.reason`). */
9747
+ reasons: string[];
9748
+ /** Evaluation-time errors, if any. Empty array on success. */
9749
+ errors: CedarError[];
9750
+ }
9751
+ interface CedarEngine {
9752
+ preparseSchema(schemaText: string): SchemaHandle;
9753
+ preparsePolicySet(cedarText: string): PolicySetHandle;
9754
+ evaluate(input: EvaluateInput): EvaluateResult;
9755
+ }
9756
+ /**
9757
+ * Thrown when the Cedar wasm module cannot be loaded — typically because
9758
+ * the wrapper is running in a browser (the `/nodejs` subpath requires Node
9759
+ * `fs`), but also raised for any unexpected load-time failure.
9760
+ */
9761
+ declare class CedarEngineUnavailableError extends Error {
9762
+ readonly name = "CedarEngineUnavailableError";
9763
+ constructor(cause: unknown);
9764
+ }
9765
+ /**
9766
+ * Thrown by `preparseSchema` / `preparsePolicySet` when Cedar reports a
9767
+ * structured `{ type: 'failure', errors: [...] }` answer. Callers (e.g.
9768
+ * the Policy Registry lint) can inspect `errors` for diagnostics.
9769
+ *
9770
+ * Phase 2-1-H — `validationErrors` is a parallel, richer view of the
9771
+ * same failures with line / column / context derived against the
9772
+ * original policy text. The legacy `errors` field is preserved as-is
9773
+ * so call sites that only need the message text don't need to change.
9774
+ */
9775
+ declare class CedarParseError extends Error {
9776
+ readonly name = "CedarParseError";
9777
+ readonly errors: CedarError[];
9778
+ /**
9779
+ * Structured diagnostics with `{ code, message, line, column, context,
9780
+ * offset }`. Always non-empty when the throw is from cedar-wasm; may
9781
+ * be empty when constructed from a non-cedar-wasm path (e.g. when an
9782
+ * upstream caller wraps an unexpected throw).
9783
+ */
9784
+ readonly validationErrors: PolicyValidationError[];
9785
+ constructor(message: string, errors: CedarError[], validationErrors?: PolicyValidationError[]);
9786
+ }
9787
+ interface CedarDetailedError {
9788
+ message: string;
9789
+ code?: string | null;
9790
+ /**
9791
+ * Source spans reported by cedar-wasm's miette-backed diagnostic
9792
+ * pipeline. `start` / `end` are 0-based byte offsets into the policy
9793
+ * text. `label` is a short hint about what was expected. We type only
9794
+ * the subset we use; cedar-wasm may include additional fields.
9795
+ */
9796
+ sourceLocations?: ReadonlyArray<{
9797
+ start?: number;
9798
+ end?: number;
9799
+ label?: string | null;
9800
+ }> | null;
9801
+ /** Cascaded diagnostics — same shape as the top-level error. */
9802
+ related?: ReadonlyArray<CedarDetailedError> | null;
9803
+ }
9804
+ /**
9805
+ * Create (or reuse) the singleton Cedar engine.
9806
+ *
9807
+ * - First call performs the dynamic import of cedar-wasm.
9808
+ * - Subsequent calls return the cached Promise — TOCTOU-safe.
9809
+ * - If the in-flight load rejects, the cache is cleared so retries work.
9810
+ */
9811
+ declare function createCedarEngine(): Promise<CedarEngine>;
9812
+ /**
9813
+ * Phase 2-1-H — flatten cedar-wasm's `{ message, sourceLocations[],
9814
+ * related[] }` tree into a list of `PolicyValidationError` entries
9815
+ * with line/column derived against the original policy text.
9816
+ *
9817
+ * `related[]` entries are walked recursively and emitted as siblings
9818
+ * of the top-level error (cedar-wasm uses `related` for "and also..."
9819
+ * style cascade diagnostics — UIs typically render all of them, not
9820
+ * just the head).
9821
+ *
9822
+ * If cedar-wasm returns no `sourceLocations`, we still emit an entry
9823
+ * (without line/column) so the caller always sees at least one error
9824
+ * per failure path.
9825
+ *
9826
+ * @internal — Phase 2-1-H heuristic implementation. Exported for cross-package
9827
+ * reuse (API + agentd / remote-mcp future surfaces) and unit tests, but NOT a
9828
+ * stable public API. Will be replaced once cedar-wasm exposes structured
9829
+ * diagnostic codes upstream (tracked as Phase 2-2-I). Semver of `@vess-id/ai-identity`
9830
+ * may remove or rename this function without a major bump.
9831
+ */
9832
+ declare function buildValidationErrors(errors: ReadonlyArray<CedarDetailedError>, sourceText: string): PolicyValidationError[];
9833
+ /**
9834
+ * Heuristic classifier mapping cedar-wasm's English message text to a
9835
+ * stable snake_case code. cedar-wasm@4.11.0 does not yet expose a
9836
+ * structured `code` field (the `code` slot in `CedarDetailedError` is
9837
+ * always `null` for parse failures), so we match on substring patterns
9838
+ * that have proven stable across recent releases.
9839
+ *
9840
+ * If `cedarCode` is supplied (future cedar-wasm release) it wins.
9841
+ *
9842
+ * Returned codes (must stay in sync with the JSDoc on
9843
+ * `PolicyValidationError.code`):
9844
+ * - `parse_error` — generic parse failure (fallback)
9845
+ * - `unexpected_end_of_input` — incomplete policy
9846
+ * - `unexpected_token` — token didn't match expected production
9847
+ * - `unknown_extension` — referenced unknown extension fn
9848
+ * - `unknown` — message didn't match any pattern
9849
+ *
9850
+ * @internal — Phase 2-1-H heuristic implementation, same caveat as
9851
+ * `buildValidationErrors`. Will be replaced once cedar-wasm exposes structured
9852
+ * diagnostic codes upstream (Phase 2-2-I).
9853
+ */
9854
+ declare function classifyCedarErrorMessage(message: string, cedarCode?: string): string;
9855
+
9856
+ /**
9857
+ * buildCedarEntities — Cedar entity-list builder (Cedar unification Step 1).
9858
+ *
9859
+ * Spec ref:
9860
+ * - docs/specs/2026-05-24-cedar-unification-design.md §7.1
9861
+ * Phase 1 採用方針: entity attribute と context の **二重 bind**。本 helper は
9862
+ * entity 側のみを組み立て、`context.action.risk_level` は呼び出し側
9863
+ * (`CedarDecisionService.buildCedarEvaluateRequest`) が context にも別途
9864
+ * 注入する。これは Cedar 4.11.0 が schema-less な entity attribute 直参照を
9865
+ * policy text 内では制限するため、policy 内では `context.action.risk_level`
9866
+ * 経由を Phase 1 で採用するという rev 3 C1 で確定した設計判断による。
9867
+ *
9868
+ * Action entity の `attrs.risk_level` は本 helper の責務、
9869
+ * `context.action.risk_level` は CedarDecisionService の責務。
9870
+ * Phase 2+ で Cedar schema 導入時に context 側を撤去し entity 直参照に統一する。
9871
+ */
9872
+
9873
+ /**
9874
+ * Principal or resource descriptor accepted by {@link buildCedarEntities}.
9875
+ * `type` is the Cedar entity-type name (e.g., `Agent`, `User`, `GmailThread`).
9876
+ * `attrs` defaults to `{}` if omitted. `parents` is always `[]` in Phase 1
9877
+ * (entity hierarchy is reserved for Phase 2 schema work).
9878
+ */
9879
+ interface CedarEntityDescriptor {
9880
+ type: string;
9881
+ id: string;
9882
+ attrs?: Record<string, unknown>;
9883
+ }
9884
+ /**
9885
+ * Input contract for {@link buildCedarEntities}. `action` is the dotted
9886
+ * action name (e.g., `'gmail.message.send'`); the helper looks up the
9887
+ * Phase 1 risk level via {@link resolveActionRisk} and binds it as
9888
+ * `Action::"<id>".attrs.risk_level`.
9889
+ *
9890
+ * Context (including `context.action.risk_level`, `context.approval.granted`,
9891
+ * `context.environment.*`) is **not** built here — the caller (typically
9892
+ * `CedarDecisionService`) builds context separately because the same entities
9893
+ * are reused across Phase A / Phase B (approval=false / approval=true)
9894
+ * evaluations.
9895
+ */
9896
+ interface CedarEntitiesInput {
9897
+ principal: CedarEntityDescriptor;
9898
+ action: string;
9899
+ resource: CedarEntityDescriptor;
9900
+ }
9901
+ /**
9902
+ * Build the Cedar entity list (principal + action + resource) for a single
9903
+ * authorization evaluation.
9904
+ *
9905
+ * Returns exactly 3 entities, in stable order [principal, action, resource].
9906
+ * The Action entity gets `attrs.risk_level` populated from
9907
+ * {@link resolveActionRisk}. principal / resource pass through `attrs`
9908
+ * unchanged (defaulting to `{}` when omitted).
9909
+ *
9910
+ * Entity hierarchy (`parents`) is intentionally empty in Phase 1 — Phase 2
9911
+ * will introduce schema-driven parents (e.g., GmailThread → GmailLabel).
9912
+ */
9913
+ declare function buildCedarEntities(input: CedarEntitiesInput): CedarEntity[];
9914
+
9915
+ /**
9916
+ * Decision 7-value enum — A2A / AP2 aligned (Cedar unification Step 1).
9917
+ *
9918
+ * Spec ref:
9919
+ * - docs/specs/2026-05-24-cedar-unification-design.md §3
9920
+ * - decision #9 (Locked Decisions §2): A2A 互換 7 値、後方互換破壊 OK
9921
+ *
9922
+ * HTTP mapping (spec §3, line 169):
9923
+ * - `permit` → 200
9924
+ * - `auth_required` → 202 (replaces legacy `RequireApproval`)
9925
+ * - `input_required` → reserved for Phase 2+
9926
+ * - `denied` → 403 (explicit forbid policy match)
9927
+ * - `denied_default` → 403 (no permit policy matched)
9928
+ * - `denied_by_user` → 403 (HITL UI rejection)
9929
+ * - `indeterminate` → 500 (Cedar evaluation error, fail-closed)
9930
+ *
9931
+ * Phase 1 Step 1 scope: SDK enum + runtime guard only.
9932
+ * Step 2 (API layer) will rewire `CedarDecisionService` to emit these values
9933
+ * and replace the legacy 3-value `CedarDecisionValue` (`Permit | Forbid |
9934
+ * RequireApproval`) over the wire. Both types coexist during the transition.
9935
+ */
9936
+ /**
9937
+ * The 7 decision states a permission evaluator may emit. Lowercase + snake_case
9938
+ * to match A2A protocol naming conventions.
9939
+ */
9940
+ type Decision = 'permit' | 'auth_required' | 'input_required' | 'denied' | 'denied_default' | 'denied_by_user' | 'indeterminate';
9941
+ /**
9942
+ * Frozen ordered tuple of every {@link Decision} value. Useful for `it.each`
9943
+ * test enumeration, exhaustiveness assertions, and audit-log validation.
9944
+ *
9945
+ * The order is **stable** and is the canonical iteration order (permit first,
9946
+ * then approval gate, then input gate, then the 3 denied variants, then the
9947
+ * fail-closed indeterminate). Do not rely on alphabetic order.
9948
+ */
9949
+ declare const DECISION_VALUES: readonly ["permit", "auth_required", "input_required", "denied", "denied_default", "denied_by_user", "indeterminate"];
9950
+ /**
9951
+ * Runtime type guard for {@link Decision}. Returns `true` only if `value` is
9952
+ * one of the 7 canonical literals. Use this when validating wire payloads
9953
+ * (audit log rows, HTTP bodies, IPC) before narrowing to `Decision`.
9954
+ *
9955
+ * Legacy 3-value capitalized literals (`Permit`, `Forbid`, `RequireApproval`)
9956
+ * are **not** accepted; callers that still need to handle the old wire format
9957
+ * must do their own translation (Step 2 will provide the migration helper).
9958
+ */
9959
+ declare function isDecision(value: unknown): value is Decision;
9960
+
9961
+ /**
9962
+ * Action risk-level resolver — registry-driven (OpenQ-5 root fix).
9963
+ *
9964
+ * Spec refs:
9965
+ * - docs/specs/2026-05-27-action-risk-registry-driven.md §3
9966
+ * - docs/specs/2026-05-24-cedar-unification-design.md §7.2 (original Phase 1
9967
+ * suffix heuristic, now retained only as a fallback)
9968
+ *
9969
+ * Resolution order:
9970
+ * 1. If the action exists in ACTION_REGISTRY and declares a `risk`, return
9971
+ * that value — ACTION_REGISTRY is the single source of truth (matching
9972
+ * CLAUDE.md). This is what Cedar `context.action.risk_level` binds to,
9973
+ * so a developer's hand-curated `risk: 'high'` is now authoritative.
9974
+ * 2. Otherwise (unknown / not-yet-registered action) fall back to the
9975
+ * deterministic suffix heuristic below:
9976
+ * - write/send/delete-class suffixes → 'high'
9977
+ * - read/list/get-class suffixes → 'low'
9978
+ * - everything else → 'medium' (fail-safe)
9979
+ *
9980
+ * The suffix heuristic classifies by the **last dotted segment** of the
9981
+ * action name (e.g., `gmail.message.send` → `send` → 'high').
9982
+ *
9983
+ * Lookup is case-insensitive: input is lowercased before the registry Map
9984
+ * lookup (registry keys are all lowercase), so `gmail.message.TRASH` still
9985
+ * hits the registry `high` instead of mis-falling-back to the suffix value.
9986
+ */
9987
+ type ActionRisk = 'low' | 'medium' | 'high';
9988
+ /**
9989
+ * Resolve the risk level for a dotted action name.
9990
+ *
9991
+ * Registry-driven: a registered action returns its declared `risk`
9992
+ * (authoritative); unknown actions fall back to the suffix heuristic.
9993
+ *
9994
+ * Examples:
9995
+ * resolveActionRisk('os.secret.read') → 'high' (registry)
9996
+ * resolveActionRisk('gmail.message.trash') → 'high' (registry)
9997
+ * resolveActionRisk('jira.issue.transition') → 'high' (registry)
9998
+ * resolveActionRisk('unknown.connector.send') → 'high' (suffix fallback)
9999
+ * resolveActionRisk('unknown.connector.read') → 'low' (suffix fallback)
10000
+ * resolveActionRisk('unknown.connector.sync') → 'medium'(suffix fallback)
10001
+ *
10002
+ * Defensive defaults:
10003
+ * - empty / falsy input → 'medium' (fail-safe; never throws)
10004
+ * - unknown suffix → 'medium'
10005
+ */
10006
+ declare function resolveActionRisk(action: string | undefined | null): ActionRisk;
10007
+
8764
10008
  declare const version = "0.0.1";
8765
10009
 
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 };
10010
+ 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, FREEMAIL_DOMAINS, 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, isFreemailDomain, 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 };