@heypointerhq/contracts 0.2.0 → 0.2.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.
package/README.md CHANGED
@@ -13,7 +13,7 @@ const walkthrough = WalkthroughSchema.parse(json); // throws on an invalid wal
13
13
  npm install @heypointerhq/contracts
14
14
  ```
15
15
 
16
- ESM only, types included, one runtime dependency (`zod`). Version 0.2.0. The packages are still `private` (not on a registry); until publishing is approved, install the tarball: `npm pack -w @heypointerhq/contracts`, then `npm install ./heypointer-contracts-0.2.0.tgz`. See [docs/PACKAGES.md](../../docs/PACKAGES.md).
16
+ ESM only, types included, one runtime dependency (`zod`). Version 0.2.1. Install it with `npm install @heypointerhq/contracts`. See [docs/PACKAGES.md](../../docs/PACKAGES.md).
17
17
 
18
18
  ## What is in it
19
19
 
@@ -36,10 +36,13 @@ A schema change is a contract change. Bump `CONTRACT_VERSION` in `src/index.ts`,
36
36
 
37
37
  | Version | Change |
38
38
  |---|---|
39
+ | 1.14.0 | New identifier prefixes: client ids `hpc_`, admin keys `hpk_a_`, guide keys `hpk_g_`, enrollment codes `hpe_`, invite tokens `hpi_`, reset tokens `hpr_` and device codes `hpd_` (MCP keys were already `hpk_m_`). Every pattern (`CLIENT_ID_PATTERN`, `KEY_SECRET_PATTERN`, `ADMIN_KEY_PATTERN`, `GUIDE_KEY_PATTERN`, `ENROLL_CODE_PATTERN`, `INVITE_TOKEN_PATTERN`, `RESET_TOKEN_PATTERN`, `DEVICE_CODE_PATTERN`) still accepts the old `gfc_`, `gfk_a_`, `gfk_g_`, `gfe_`, `gfi_`, `gfr_` and `gfd_` values, so nothing issued before stays invalid. Additive. |
40
+ | 1.13.0 | Choosable access for the hosted MCP endpoint: `McpScopeSchema` (`mcp:read`, `mcp:write`, `MCP_SCOPES`); `CreateKeyRequest.mcpScopes` (MCP keys only, must include `mcp:read`, default read only); `CreateKeyResponse` and `KeySummary` gain optional `expiresAt` (an MCP key stops working at that time; `null` for keys that do not expire) and `mcpScopes`. Additive. |
41
+ | 1.12.0 | A read-only key kind for the hosted MCP endpoint: `KeyScopeSchema` gains `mcp`, key secrets `hpk_m_` + 48 hex (`MCP_KEY_PATTERN`; `KEY_SECRET_PATTERN` now matches `hpk_m_` besides `hpk_a_` and `hpk_g_`). An MCP key works only on `POST /mcp`; every other route refuses it with 403. `POST /api/keys` accepts `scope: "mcp"`. Additive. |
39
42
  | 1.11.0 | Staff accounts as the public API shows them: `AccountUser.operator`, `SessionResponse.operator`, `InviteInfoResponse.kind: "operator"`, the `operator_2fa_required` error code, and `byStaff` and `description` on audit entries, so a tenant sees "HeyPointer staff viewed your flows" without a name. The operator routes and their schemas are not part of this package (they live in an internal package). |
40
- | 1.10.0 | Accounts and login: people sign in to the console with an email and password (OIDC providers later) and get a session cookie (`SESSION_COOKIE` `hp_session`, sent as `__Host-hp_session` over https; `SESSION_IDLE_MS` 12 hours, `SESSION_ABSOLUTE_MS` 7 days). Signup is invite-only: `POST /api/invites` (owners and admins; the first owner of a tenant is invited by the operator), invite links `gfi_` + 32 hex (`INVITE_TOKEN_PATTERN`, `INVITE_TTL_MS` 7 days), reset links `gfr_` + 32 hex (`RESET_TTL_MS` 1 hour). Users `usr_` + 12 hex, members with roles `owner`/`admin`/`member` (`MemberRoleSchema`). A request that changes state with the cookie must send `X-HeyPointer-CSRF` (`CSRF_HEADER`) and a same-origin `Origin`. Two-factor sign-in (TOTP) with ten recovery codes, command-line login two ways (`POST /api/auth/device` + `/token` with a short `ABCD-EFGH` code and a browser approval, or `POST /api/auth/cli-login` with email and password) that both end in a revocable tenant admin key, an audit log (`GET /api/audit`), `ACCOUNT_ROUTES` with every request and response schema. New error codes `invalid_credentials`, `account_exists_login_first`, `accounts_disabled`, `csrf_failed`. Plans may set `members` (team members plus pending invites; `PlanLimitsSchema.members` and `PlanUsageSchema.members` are optional, defaults free 3 and internal 100). |
41
- | 1.9.0 | Tenants and keys: `TENANT_ID_PATTERN` / `DEFAULT_TENANT_ID` (`tn_` + 12 hex), key secrets `gfk_a_` (admin) / `gfk_g_` (guide) + 48 hex (`KEY_SECRET_PATTERN`, `ADMIN_KEY_PATTERN`, `GUIDE_KEY_PATTERN`), key handles `kid_` + 12 hex (`KEY_ID_PATTERN`), one-time enrollment codes `gfe_` + 32 hex (`ENROLL_CODE_PATTERN`, `ENROLLMENT_TTL_MS` 15 minutes), `TENANT_ROUTES` (`POST /api/tenant/enroll`, `GET /api/tenant`, `POST/GET /api/keys`, `DELETE /api/keys/{id}`) with their request and response schemas. Walkthrough requests may also authenticate with a guide key (`Authorization: Bearer gfk_g_...`) from a tenant's backend proxy. Every tenant has its own keys, clients, flows and knowledge base. Plans (`PlanNameSchema`, `PlanLimitsSchema`, `TenantPlanSchema`, `DEFAULT_PLAN` `free`) set per-tenant limits on clients, keys and flows; `GET /api/tenant` carries `plan`, `limits` and `usage`; error code `plan_limit_reached` (403) with `limit` and `used` on error responses. |
42
- | 1.8.0 | App clients: the `X-HeyPointer-Client` header (`CLIENT_ID_HEADER`) on walkthrough requests, `CLIENT_ID_PATTERN` / `ClientIdSchema` (`gfc_` + 24 hex; a publishable id, not a secret), admin routes `CLIENT_ROUTES` (`POST /api/clients`, `GET /api/clients`, `DELETE /api/clients/{id}`) with `CreateClientRequestSchema`, `CreateClientResponseSchema`, `AppClientSchema`, `ClientListResponseSchema`; error codes `client_required` (401), `client_invalid` (401), `client_origin_not_allowed` (403); optional `message` on error responses. A server with the default `HEYPOINTER_CLIENT_AUTH=required` refuses walkthroughs without a valid client id. |
43
+ | 1.10.0 | Accounts and login: people sign in to the console with an email and password (OIDC providers later) and get a session cookie (`SESSION_COOKIE` `hp_session`, sent as `__Host-hp_session` over https; `SESSION_IDLE_MS` 12 hours, `SESSION_ABSOLUTE_MS` 7 days). Signup is invite-only: `POST /api/invites` (owners and admins; the first owner of a tenant is invited by the operator), invite links `hpi_` + 32 hex (`INVITE_TOKEN_PATTERN`, `INVITE_TTL_MS` 7 days), reset links `hpr_` + 32 hex (`RESET_TTL_MS` 1 hour). Users `usr_` + 12 hex, members with roles `owner`/`admin`/`member` (`MemberRoleSchema`). A request that changes state with the cookie must send `X-HeyPointer-CSRF` (`CSRF_HEADER`) and a same-origin `Origin`. Two-factor sign-in (TOTP) with ten recovery codes, command-line login two ways (`POST /api/auth/device` + `/token` with a short `ABCD-EFGH` code and a browser approval, or `POST /api/auth/cli-login` with email and password) that both end in a revocable tenant admin key, an audit log (`GET /api/audit`), `ACCOUNT_ROUTES` with every request and response schema. New error codes `invalid_credentials`, `account_exists_login_first`, `accounts_disabled`, `csrf_failed`. Plans may set `members` (team members plus pending invites; `PlanLimitsSchema.members` and `PlanUsageSchema.members` are optional, defaults free 3 and internal 100). |
44
+ | 1.9.0 | Tenants and keys: `TENANT_ID_PATTERN` / `DEFAULT_TENANT_ID` (`tn_` + 12 hex), key secrets `hpk_a_` (admin) / `hpk_g_` (guide) + 48 hex (`KEY_SECRET_PATTERN`, `ADMIN_KEY_PATTERN`, `GUIDE_KEY_PATTERN`), key handles `kid_` + 12 hex (`KEY_ID_PATTERN`), one-time enrollment codes `hpe_` + 32 hex (`ENROLL_CODE_PATTERN`, `ENROLLMENT_TTL_MS` 15 minutes), `TENANT_ROUTES` (`POST /api/tenant/enroll`, `GET /api/tenant`, `POST/GET /api/keys`, `DELETE /api/keys/{id}`) with their request and response schemas. Walkthrough requests may also authenticate with a guide key (`Authorization: Bearer hpk_g_...`) from a tenant's backend proxy. Every tenant has its own keys, clients, flows and knowledge base. Plans (`PlanNameSchema`, `PlanLimitsSchema`, `TenantPlanSchema`, `DEFAULT_PLAN` `free`) set per-tenant limits on clients, keys and flows; `GET /api/tenant` carries `plan`, `limits` and `usage`; error code `plan_limit_reached` (403) with `limit` and `used` on error responses. |
45
+ | 1.8.0 | App clients: the `X-HeyPointer-Client` header (`CLIENT_ID_HEADER`) on walkthrough requests, `CLIENT_ID_PATTERN` / `ClientIdSchema` (`hpc_` + 24 hex; a publishable id, not a secret), admin routes `CLIENT_ROUTES` (`POST /api/clients`, `GET /api/clients`, `DELETE /api/clients/{id}`) with `CreateClientRequestSchema`, `CreateClientResponseSchema`, `AppClientSchema`, `ClientListResponseSchema`; error codes `client_required` (401), `client_invalid` (401), `client_origin_not_allowed` (403); optional `message` on error responses. A server with the default `HEYPOINTER_CLIENT_AUTH=required` refuses walkthroughs without a valid client id. |
43
46
  | 1.7.0 | Publish a scanned knowledge base: `PUT /api/kb` (`API_ROUTES.publishKnowledgeBase`), `PublishKbRequestSchema` (the `kb.json` body, strict, with graph consistency checks), `PublishKbResponseSchema`, `MAX_KB_PUBLISH_BYTES`; error codes `embedder_mismatch`, `scanner_too_old`, `conflict`. Additive. |
44
47
  | 1.6.0 | Flows API: `FLOW_ROUTES`, `FlowInput`, `Flow`, `FlowDetail`, `FlowVersion`, `FlowValidateResponse`. Add, edit, publish, unpublish, roll back and delete flows on a running server. Additive. |
45
48
  | 1.5.0 | `suggestions` (up to 5 `{workflowId, title}`) on a walkthrough: the nearest guides, allowed only with `insufficient_evidence`. Optional and additive. The server does not produce it yet; it is the contract for the planned decision step. |
@@ -52,3 +55,7 @@ A schema change is a contract change. Bump `CONTRACT_VERSION` in `src/index.ts`,
52
55
  ## Test
53
56
 
54
57
  `npm test -w packages/contracts`
58
+
59
+ ---
60
+
61
+ [Website](https://heypointer.com/) · [Docs](https://heypointer.com/docs/) · [X](https://x.com/heypointer) · [Instagram](https://www.instagram.com/heypointer/) · Support: [Buy Me a Coffee](https://buymeacoffee.com/heypointer) · [Ko-fi](https://ko-fi.com/heypointer)
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  /** Contract version. Bump on any breaking schema change and note it in packages/contracts/README.md. */
3
- export declare const CONTRACT_VERSION = "1.11.0";
3
+ export declare const CONTRACT_VERSION = "1.14.0";
4
4
  /**
5
5
  * `code` (added in 1.3.0) marks flows a model inferred from application source in
6
6
  * `heypointer scan --llm`. Every such step still cites a real file, lines and excerpt.
@@ -718,7 +718,7 @@ export type FlowValidateResponse = z.infer<typeof FlowValidateResponseSchema>;
718
718
  * usage counts); it does not prove who is asking.
719
719
  */
720
720
  export declare const CLIENT_ID_HEADER = "X-HeyPointer-Client";
721
- /** `gfc_` and 24 lowercase hex characters (96 random bits). */
721
+ /** `hpc_` and 24 lowercase hex characters (96 random bits). Ids issued before 1.14.0 start with `gfc_` and stay valid. */
722
722
  export declare const CLIENT_ID_PATTERN: RegExp;
723
723
  export declare const ClientIdSchema: z.ZodString;
724
724
  /** Routes use `Authorization: Bearer <server API key>`. */
@@ -777,23 +777,27 @@ export declare const TENANT_ID_PATTERN: RegExp;
777
777
  export declare const TenantIdSchema: z.ZodString;
778
778
  /** The tenant every pre-1.9.0 install is migrated into. Requests that name no tenant act on it. */
779
779
  export declare const DEFAULT_TENANT_ID = "tn_000000000000";
780
- /** A secret key: `gfk_a_` (admin) or `gfk_g_` (guide) and 48 lowercase hex characters (192 random bits). Shown once. */
780
+ /** A secret key: `hpk_a_` (admin), `hpk_g_` (guide) or `hpk_m_` (MCP, added in 1.12.0) and 48 lowercase hex characters (192 random bits). Shown once. Admin and guide keys issued before 1.14.0 start with `gfk_a_` / `gfk_g_` and stay valid. */
781
781
  export declare const KEY_SECRET_PATTERN: RegExp;
782
782
  export declare const ADMIN_KEY_PATTERN: RegExp;
783
783
  export declare const GUIDE_KEY_PATTERN: RegExp;
784
+ export declare const MCP_KEY_PATTERN: RegExp;
784
785
  /** A key handle (not a secret): used to list and revoke keys. */
785
786
  export declare const KEY_ID_PATTERN: RegExp;
786
787
  export declare const KeyIdSchema: z.ZodString;
787
- /** A one-time enrollment code: `gfe_` and 32 lowercase hex characters. Valid for 15 minutes. */
788
+ /** A one-time enrollment code: `hpe_` and 32 lowercase hex characters. Valid for 15 minutes. */
788
789
  export declare const ENROLL_CODE_PATTERN: RegExp;
789
790
  export declare const ENROLLMENT_TTL_MS: number;
791
+ /** `mcp` (1.12.0) is read-only and works only on the hosted MCP endpoint (`POST /mcp`); every other route refuses it. */
790
792
  export declare const KeyScopeSchema: z.ZodEnum<{
791
793
  admin: "admin";
792
794
  guide: "guide";
795
+ mcp: "mcp";
793
796
  }>;
794
797
  export type KeyScope = z.infer<typeof KeyScopeSchema>;
795
798
  /**
796
- * Tenant routes use a tenant admin key (`Authorization: Bearer gfk_a_...`). A guide key (`gfk_g_...`) may only fetch walkthroughs.
799
+ * Tenant routes use a tenant admin key (`Authorization: Bearer hpk_a_...`). A guide key (`hpk_g_...`) may only fetch walkthroughs.
800
+ * An MCP key (`hpk_m_...`, 1.12.0) may only call the hosted MCP endpoint, `POST /mcp`.
797
801
  */
798
802
  export declare const TENANT_ROUTES: {
799
803
  /** No authentication: the code is the credential. Rate limited like failed key checks. */
@@ -852,6 +856,7 @@ export declare const CreatedKeySchema: z.ZodObject<{
852
856
  scope: z.ZodEnum<{
853
857
  admin: "admin";
854
858
  guide: "guide";
859
+ mcp: "mcp";
855
860
  }>;
856
861
  secret: z.ZodString;
857
862
  }, z.core.$strip>;
@@ -866,23 +871,46 @@ export declare const EnrollTenantResponseSchema: z.ZodObject<{
866
871
  }, z.core.$strip>;
867
872
  }, z.core.$strip>;
868
873
  export type EnrollTenantResponse = z.infer<typeof EnrollTenantResponseSchema>;
874
+ /**
875
+ * What an MCP key or an OAuth sign-in lets an agent do on the hosted MCP endpoint (1.13.0). `mcp:read` covers the tools that only
876
+ * read or validate; `mcp:write` adds the tools that change the tenant (a draft flow, never a live one). The customer picks.
877
+ */
878
+ export declare const McpScopeSchema: z.ZodEnum<{
879
+ "mcp:read": "mcp:read";
880
+ "mcp:write": "mcp:write";
881
+ }>;
882
+ export type McpScope = z.infer<typeof McpScopeSchema>;
883
+ export declare const MCP_SCOPES: readonly ["mcp:read", "mcp:write"];
884
+ /** `mcpScopes` applies to `scope: "mcp"` only and must include `mcp:read`; it defaults to read only. */
869
885
  export declare const CreateKeyRequestSchema: z.ZodObject<{
870
886
  name: z.ZodString;
871
887
  scope: z.ZodEnum<{
872
888
  admin: "admin";
873
889
  guide: "guide";
890
+ mcp: "mcp";
874
891
  }>;
892
+ mcpScopes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
893
+ "mcp:read": "mcp:read";
894
+ "mcp:write": "mcp:write";
895
+ }>>>;
875
896
  }, z.core.$strip>;
876
897
  export type CreateKeyRequest = z.infer<typeof CreateKeyRequestSchema>;
898
+ /** `expiresAt` (1.13.0): an MCP key stops working at this time (7 days after creation unless the operator set another lifetime). Other keys do not expire (`null`). */
877
899
  export declare const CreateKeyResponseSchema: z.ZodObject<{
878
900
  keyId: z.ZodString;
879
901
  scope: z.ZodEnum<{
880
902
  admin: "admin";
881
903
  guide: "guide";
904
+ mcp: "mcp";
882
905
  }>;
883
906
  secret: z.ZodString;
884
907
  name: z.ZodString;
885
908
  createdAt: z.ZodString;
909
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
910
+ mcpScopes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
911
+ "mcp:read": "mcp:read";
912
+ "mcp:write": "mcp:write";
913
+ }>>>;
886
914
  }, z.core.$strip>;
887
915
  export type CreateKeyResponse = z.infer<typeof CreateKeyResponseSchema>;
888
916
  export declare const KeySummarySchema: z.ZodObject<{
@@ -890,12 +918,18 @@ export declare const KeySummarySchema: z.ZodObject<{
890
918
  scope: z.ZodEnum<{
891
919
  admin: "admin";
892
920
  guide: "guide";
921
+ mcp: "mcp";
893
922
  }>;
894
923
  name: z.ZodString;
895
924
  prefix: z.ZodString;
896
925
  createdAt: z.ZodString;
897
926
  lastUsedAt: z.ZodNullable<z.ZodString>;
898
927
  revoked: z.ZodBoolean;
928
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
929
+ mcpScopes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
930
+ "mcp:read": "mcp:read";
931
+ "mcp:write": "mcp:write";
932
+ }>>>;
899
933
  }, z.core.$strip>;
900
934
  export type KeySummary = z.infer<typeof KeySummarySchema>;
901
935
  export declare const KeyListResponseSchema: z.ZodObject<{
@@ -904,12 +938,18 @@ export declare const KeyListResponseSchema: z.ZodObject<{
904
938
  scope: z.ZodEnum<{
905
939
  admin: "admin";
906
940
  guide: "guide";
941
+ mcp: "mcp";
907
942
  }>;
908
943
  name: z.ZodString;
909
944
  prefix: z.ZodString;
910
945
  createdAt: z.ZodString;
911
946
  lastUsedAt: z.ZodNullable<z.ZodString>;
912
947
  revoked: z.ZodBoolean;
948
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
949
+ mcpScopes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
950
+ "mcp:read": "mcp:read";
951
+ "mcp:write": "mcp:write";
952
+ }>>>;
913
953
  }, z.core.$strip>>;
914
954
  }, z.core.$strip>;
915
955
  export type KeyListResponse = z.infer<typeof KeyListResponseSchema>;
package/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright 2026 HeyPointer
1
3
  import { z } from "zod";
2
4
  /** Contract version. Bump on any breaking schema change and note it in packages/contracts/README.md. */
3
- export const CONTRACT_VERSION = "1.11.0";
5
+ export const CONTRACT_VERSION = "1.14.0";
4
6
  // ---------------------------------------------------------------------------
5
7
  // Knowledge base: sources, provenance, workflow graph
6
8
  // ---------------------------------------------------------------------------
@@ -443,8 +445,8 @@ export const FlowValidateResponseSchema = z.object({
443
445
  * usage counts); it does not prove who is asking.
444
446
  */
445
447
  export const CLIENT_ID_HEADER = "X-HeyPointer-Client";
446
- /** `gfc_` and 24 lowercase hex characters (96 random bits). */
447
- export const CLIENT_ID_PATTERN = /^gfc_[0-9a-f]{24}$/;
448
+ /** `hpc_` and 24 lowercase hex characters (96 random bits). Ids issued before 1.14.0 start with `gfc_` and stay valid. */
449
+ export const CLIENT_ID_PATTERN = /^(?:hpc|gfc)_[0-9a-f]{24}$/;
448
450
  export const ClientIdSchema = z.string().regex(CLIENT_ID_PATTERN);
449
451
  /** Routes use `Authorization: Bearer <server API key>`. */
450
452
  export const CLIENT_ROUTES = {
@@ -501,19 +503,22 @@ export const TENANT_ID_PATTERN = /^tn_[0-9a-f]{12}$/;
501
503
  export const TenantIdSchema = z.string().regex(TENANT_ID_PATTERN);
502
504
  /** The tenant every pre-1.9.0 install is migrated into. Requests that name no tenant act on it. */
503
505
  export const DEFAULT_TENANT_ID = "tn_000000000000";
504
- /** A secret key: `gfk_a_` (admin) or `gfk_g_` (guide) and 48 lowercase hex characters (192 random bits). Shown once. */
505
- export const KEY_SECRET_PATTERN = /^gfk_[ag]_[0-9a-f]{48}$/;
506
- export const ADMIN_KEY_PATTERN = /^gfk_a_[0-9a-f]{48}$/;
507
- export const GUIDE_KEY_PATTERN = /^gfk_g_[0-9a-f]{48}$/;
506
+ /** A secret key: `hpk_a_` (admin), `hpk_g_` (guide) or `hpk_m_` (MCP, added in 1.12.0) and 48 lowercase hex characters (192 random bits). Shown once. Admin and guide keys issued before 1.14.0 start with `gfk_a_` / `gfk_g_` and stay valid. */
507
+ export const KEY_SECRET_PATTERN = /^(?:(?:hpk|gfk)_[ag]|hpk_m)_[0-9a-f]{48}$/;
508
+ export const ADMIN_KEY_PATTERN = /^(?:hpk|gfk)_a_[0-9a-f]{48}$/;
509
+ export const GUIDE_KEY_PATTERN = /^(?:hpk|gfk)_g_[0-9a-f]{48}$/;
510
+ export const MCP_KEY_PATTERN = /^hpk_m_[0-9a-f]{48}$/;
508
511
  /** A key handle (not a secret): used to list and revoke keys. */
509
512
  export const KEY_ID_PATTERN = /^kid_[0-9a-f]{12}$/;
510
513
  export const KeyIdSchema = z.string().regex(KEY_ID_PATTERN);
511
- /** A one-time enrollment code: `gfe_` and 32 lowercase hex characters. Valid for 15 minutes. */
512
- export const ENROLL_CODE_PATTERN = /^gfe_[0-9a-f]{32}$/;
514
+ /** A one-time enrollment code: `hpe_` and 32 lowercase hex characters. Valid for 15 minutes. */
515
+ export const ENROLL_CODE_PATTERN = /^(?:hpe|gfe)_[0-9a-f]{32}$/;
513
516
  export const ENROLLMENT_TTL_MS = 15 * 60 * 1000;
514
- export const KeyScopeSchema = z.enum(["admin", "guide"]);
517
+ /** `mcp` (1.12.0) is read-only and works only on the hosted MCP endpoint (`POST /mcp`); every other route refuses it. */
518
+ export const KeyScopeSchema = z.enum(["admin", "guide", "mcp"]);
515
519
  /**
516
- * Tenant routes use a tenant admin key (`Authorization: Bearer gfk_a_...`). A guide key (`gfk_g_...`) may only fetch walkthroughs.
520
+ * Tenant routes use a tenant admin key (`Authorization: Bearer hpk_a_...`). A guide key (`hpk_g_...`) may only fetch walkthroughs.
521
+ * An MCP key (`hpk_m_...`, 1.12.0) may only call the hosted MCP endpoint, `POST /mcp`.
517
522
  */
518
523
  export const TENANT_ROUTES = {
519
524
  /** No authentication: the code is the credential. Rate limited like failed key checks. */
@@ -555,17 +560,29 @@ export const EnrollTenantResponseSchema = z.object({
555
560
  name: z.string(),
556
561
  key: CreatedKeySchema.extend({ scope: z.literal("admin") }),
557
562
  });
558
- export const CreateKeyRequestSchema = z.object({ name: NameSchema, scope: KeyScopeSchema });
559
- export const CreateKeyResponseSchema = CreatedKeySchema.extend({ name: z.string(), createdAt: z.string() });
563
+ /**
564
+ * What an MCP key or an OAuth sign-in lets an agent do on the hosted MCP endpoint (1.13.0). `mcp:read` covers the tools that only
565
+ * read or validate; `mcp:write` adds the tools that change the tenant (a draft flow, never a live one). The customer picks.
566
+ */
567
+ export const McpScopeSchema = z.enum(["mcp:read", "mcp:write"]);
568
+ export const MCP_SCOPES = ["mcp:read", "mcp:write"];
569
+ /** `mcpScopes` applies to `scope: "mcp"` only and must include `mcp:read`; it defaults to read only. */
570
+ export const CreateKeyRequestSchema = z.object({ name: NameSchema, scope: KeyScopeSchema, mcpScopes: z.array(McpScopeSchema).min(1).max(2).optional() });
571
+ /** `expiresAt` (1.13.0): an MCP key stops working at this time (7 days after creation unless the operator set another lifetime). Other keys do not expire (`null`). */
572
+ export const CreateKeyResponseSchema = CreatedKeySchema.extend({ name: z.string(), createdAt: z.string(), expiresAt: z.string().nullable().optional(), mcpScopes: z.array(McpScopeSchema).optional() });
560
573
  export const KeySummarySchema = z.object({
561
574
  keyId: KeyIdSchema,
562
575
  scope: KeyScopeSchema,
563
576
  name: z.string(),
564
- /** The first characters of the secret (e.g. `gfk_a_1a2b3c4d`), enough to recognise it. Not usable as a key. */
577
+ /** The first characters of the secret (e.g. `hpk_a_1a2b3c4d`), enough to recognise it. Not usable as a key. */
565
578
  prefix: z.string(),
566
579
  createdAt: z.string(),
567
580
  lastUsedAt: z.string().nullable(),
568
581
  revoked: z.boolean(),
582
+ /** 1.13.0. When an MCP key stops working; `null` for a key that does not expire. */
583
+ expiresAt: z.string().nullable().optional(),
584
+ /** 1.13.0. For MCP keys: what the key may do. */
585
+ mcpScopes: z.array(McpScopeSchema).optional(),
569
586
  });
570
587
  export const KeyListResponseSchema = z.object({ keys: z.array(KeySummarySchema) });
571
588
  export const TenantSelfResponseSchema = z.object({
@@ -591,11 +608,11 @@ export const UserIdSchema = z.string().regex(USER_ID_PATTERN);
591
608
  export const SESSION_ID_PATTERN = /^ses_[0-9a-f]{12}$/;
592
609
  export const INVITE_ID_PATTERN = /^inv_[0-9a-f]{12}$/;
593
610
  /** An invite link token: shown once to the inviter inside the link. */
594
- export const INVITE_TOKEN_PATTERN = /^gfi_[0-9a-f]{32}$/;
611
+ export const INVITE_TOKEN_PATTERN = /^(?:hpi|gfi)_[0-9a-f]{32}$/;
595
612
  /** A password reset token: shown once inside the reset link; valid one hour. */
596
- export const RESET_TOKEN_PATTERN = /^gfr_[0-9a-f]{32}$/;
613
+ export const RESET_TOKEN_PATTERN = /^(?:hpr|gfr)_[0-9a-f]{32}$/;
597
614
  /** The device code the CLI polls with. A secret: only its hash is stored. */
598
- export const DEVICE_CODE_PATTERN = /^gfd_[0-9a-f]{40}$/;
615
+ export const DEVICE_CODE_PATTERN = /^(?:hpd|gfd)_[0-9a-f]{40}$/;
599
616
  /** What the person types in the browser: `ABCD-EFGH`, no vowels and no look-alike characters. */
600
617
  export const USER_CODE_PATTERN = /^[BCDFGHJKLMNPQRSTVWXZ2-9]{4}-[BCDFGHJKLMNPQRSTVWXZ2-9]{4}$/;
601
618
  export const RECOVERY_CODE_PATTERN = /^[0-9a-f]{5}-[0-9a-f]{5}$/;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heypointerhq/contracts",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "description": "Shared HeyPointer workflow, knowledge-base and walkthrough contracts (zod schemas + types).",
6
6
  "keywords": [