@rebasepro/server 0.27.0 → 0.28.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 (111) hide show
  1. package/dist/{GCSStorageController-BUClIfp0.js → GCSStorageController-LXeAF6Ks.js} +4 -4
  2. package/dist/{GCSStorageController-BUClIfp0.js.map → GCSStorageController-LXeAF6Ks.js.map} +1 -1
  3. package/dist/{S3StorageController-CixCQEky.js → S3StorageController-CVKMUXo_.js} +8 -4
  4. package/dist/S3StorageController-CVKMUXo_.js.map +1 -0
  5. package/dist/{access-BFAUvsSs.js → access-BDz4FO9D.js} +7 -7
  6. package/dist/{access-BFAUvsSs.js.map → access-BDz4FO9D.js.map} +1 -1
  7. package/dist/api/openapi-generator.d.ts +13 -1
  8. package/dist/api/rest/api-generator.d.ts +16 -0
  9. package/dist/api/rest/batch.d.ts +9 -0
  10. package/dist/{ast-schema-editor-madTa9Hh.js → ast-schema-editor-C4bDSb61.js} +2 -2
  11. package/dist/{ast-schema-editor-madTa9Hh.js.map → ast-schema-editor-C4bDSb61.js.map} +1 -1
  12. package/dist/auth/interfaces.d.ts +23 -4
  13. package/dist/auth/otp-routes.d.ts +10 -0
  14. package/dist/auth/platform-token.d.ts +24 -8
  15. package/dist/{auth-DDXPw0mn.js → auth-CZGfVKcL.js} +173 -114
  16. package/dist/auth-CZGfVKcL.js.map +1 -0
  17. package/dist/backend/options.d.ts +21 -0
  18. package/dist/{backup-B6brPSeB.js → backup-BmzY9xdN.js} +8 -8
  19. package/dist/{backup-B6brPSeB.js.map → backup-BmzY9xdN.js.map} +1 -1
  20. package/dist/{branch-routes-B2vvEx53.js → branch-routes-DpgaeTJl.js} +4 -4
  21. package/dist/{branch-routes-B2vvEx53.js.map → branch-routes-DpgaeTJl.js.map} +1 -1
  22. package/dist/{contract-routes-CU2A3JnF.js → contract-routes-vYiBHbjI.js} +3 -3
  23. package/dist/{contract-routes-CU2A3JnF.js.map → contract-routes-vYiBHbjI.js.map} +1 -1
  24. package/dist/cron/cron-loader.d.ts +12 -0
  25. package/dist/{cron-loader-CC1Jy_KN.js → cron-loader-C_C-lNgG.js} +27 -6
  26. package/dist/cron-loader-C_C-lNgG.js.map +1 -0
  27. package/dist/{cron-routes-BK60Rn1r.js → cron-routes-DlwOV6zl.js} +5 -5
  28. package/dist/{cron-routes-BK60Rn1r.js.map → cron-routes-DlwOV6zl.js.map} +1 -1
  29. package/dist/{cron-scheduler-DyCjPlQR.js → cron-scheduler-6ipIm5mm.js} +3 -3
  30. package/dist/{cron-scheduler-DyCjPlQR.js.map → cron-scheduler-6ipIm5mm.js.map} +1 -1
  31. package/dist/{cron-store-DLn11M8H.js → cron-store-KIOM8LCC.js} +5 -5
  32. package/dist/{cron-store-DLn11M8H.js.map → cron-store-KIOM8LCC.js.map} +1 -1
  33. package/dist/{ddl-bootstrap-CjRrn12l.js → ddl-bootstrap-DhCuwhHM.js} +2 -2
  34. package/dist/{ddl-bootstrap-CjRrn12l.js.map → ddl-bootstrap-DhCuwhHM.js.map} +1 -1
  35. package/dist/dist-CT9HJehq.js +22 -0
  36. package/dist/dist-CT9HJehq.js.map +1 -0
  37. package/dist/{errors-OMWkKSH-.js → errors-DIWnZIDY.js} +2 -2
  38. package/dist/{errors-OMWkKSH-.js.map → errors-DIWnZIDY.js.map} +1 -1
  39. package/dist/{field-access-DYsvjI_P.js → field-access-KYk8RGOx.js} +3 -2
  40. package/dist/field-access-KYk8RGOx.js.map +1 -0
  41. package/dist/{filter-dialect-TrKFWLqT.js → filter-dialect-CE4bloug.js} +2 -2
  42. package/dist/{filter-dialect-TrKFWLqT.js.map → filter-dialect-CE4bloug.js.map} +1 -1
  43. package/dist/{function-loader-eFigStYX.js → function-loader-CKB9b4uP.js} +2 -2
  44. package/dist/{function-loader-eFigStYX.js.map → function-loader-CKB9b4uP.js.map} +1 -1
  45. package/dist/{function-routes-RxrCHNuM.js → function-routes-DLaXaiQA.js} +2 -2
  46. package/dist/{function-routes-RxrCHNuM.js.map → function-routes-DLaXaiQA.js.map} +1 -1
  47. package/dist/functions/index.js +16 -9
  48. package/dist/functions/index.js.map +1 -1
  49. package/dist/{history-recorder-Bsau7h4X.js → history-recorder-BE4HWR-M.js} +4 -4
  50. package/dist/{history-recorder-Bsau7h4X.js.map → history-recorder-BE4HWR-M.js.map} +1 -1
  51. package/dist/{history-store-BQz5YCkW.js → history-store-D-jDz4Nv.js} +2 -2
  52. package/dist/{history-store-BQz5YCkW.js.map → history-store-D-jDz4Nv.js.map} +1 -1
  53. package/dist/index.d.ts +4 -0
  54. package/dist/index.es.js +1194 -249
  55. package/dist/index.es.js.map +1 -1
  56. package/dist/{internal-tables-L2t39RdT.js → internal-tables-CRaBxJeE.js} +57 -2
  57. package/dist/{internal-tables-L2t39RdT.js.map → internal-tables-CRaBxJeE.js.map} +1 -1
  58. package/dist/{jobs-Co6Ni5HP.js → jobs-CXTs9qXH.js} +5 -5
  59. package/dist/{jobs-Co6Ni5HP.js.map → jobs-CXTs9qXH.js.map} +1 -1
  60. package/dist/{jwt-rDS0884_.js → jwt-5EvX3lQa.js} +3 -3
  61. package/dist/{jwt-rDS0884_.js.map → jwt-5EvX3lQa.js.map} +1 -1
  62. package/dist/{keys-BXcdRNhJ.js → keys-DJ1ZNcZi.js} +2 -2
  63. package/dist/{keys-BXcdRNhJ.js.map → keys-DJ1ZNcZi.js.map} +1 -1
  64. package/dist/{logger-CW8pmTS6.js → logger-SigQ2oZJ.js} +17 -10
  65. package/dist/logger-SigQ2oZJ.js.map +1 -0
  66. package/dist/{logs-routes-CBt7mMIL.js → logs-routes-DXLvMasE.js} +3 -3
  67. package/dist/{logs-routes-CBt7mMIL.js.map → logs-routes-DXLvMasE.js.map} +1 -1
  68. package/dist/mcp/confirmation.d.ts +84 -0
  69. package/dist/mcp/consent-page.d.ts +17 -3
  70. package/dist/mcp/mcp-apps.d.ts +53 -0
  71. package/dist/mcp/mcp-routes.d.ts +42 -1
  72. package/dist/mcp/mcp-tools.d.ts +50 -6
  73. package/dist/mcp/oauth-metadata.d.ts +25 -3
  74. package/dist/mcp/oauth-routes.d.ts +4 -1
  75. package/dist/mcp/oauth-store.d.ts +7 -1
  76. package/dist/mcp/platform-mcp.d.ts +37 -0
  77. package/dist/{offline-AvuEcg7u-DFHL98OT.js → offline-BjJdcVBb-BOzzsnrh.js} +35 -7
  78. package/dist/offline-BjJdcVBb-BOzzsnrh.js.map +1 -0
  79. package/dist/{offline-store-BhYXViha-YTmjBpo2.js → offline-store-Cxhh99Q--FB6fSf5A.js} +43 -9
  80. package/dist/offline-store-Cxhh99Q--FB6fSf5A.js.map +1 -0
  81. package/dist/{openapi-generator-CyxEtYEX.js → openapi-generator-B6aw_KuR.js} +41 -7
  82. package/dist/openapi-generator-B6aw_KuR.js.map +1 -0
  83. package/dist/{proxy-BYir8tWK.js → proxy-2nS5N63I.js} +3 -3
  84. package/dist/{proxy-BYir8tWK.js.map → proxy-2nS5N63I.js.map} +1 -1
  85. package/dist/{query-parser-CDXWf2hH.js → query-parser-DFVCjW5i.js} +6 -6
  86. package/dist/{query-parser-CDXWf2hH.js.map → query-parser-DFVCjW5i.js.map} +1 -1
  87. package/dist/{request-timeout-DVjo-c_8.js → request-timeout-Cqm4JXtZ.js} +3 -3
  88. package/dist/{request-timeout-DVjo-c_8.js.map → request-timeout-Cqm4JXtZ.js.map} +1 -1
  89. package/dist/{rls-simulator-routes-bEY7-5-u.js → rls-simulator-routes-D5-XfjzW.js} +4 -4
  90. package/dist/{rls-simulator-routes-bEY7-5-u.js.map → rls-simulator-routes-D5-XfjzW.js.map} +1 -1
  91. package/dist/{schema-editor-routes-Dc3DU_jm.js → schema-editor-routes-DzSe6V0a.js} +4 -4
  92. package/dist/{schema-editor-routes-Dc3DU_jm.js.map → schema-editor-routes-DzSe6V0a.js.map} +1 -1
  93. package/dist/{soft-delete-params-BRONCOA2.js → soft-delete-params-9lKBAlDw.js} +2 -2
  94. package/dist/{soft-delete-params-BRONCOA2.js.map → soft-delete-params-9lKBAlDw.js.map} +1 -1
  95. package/dist/{sql-export-routes-QycX8W8S.js → sql-export-routes-BxMqgAFX.js} +4 -4
  96. package/dist/{sql-export-routes-QycX8W8S.js.map → sql-export-routes-BxMqgAFX.js.map} +1 -1
  97. package/dist/{src-Bh9LRPb9.js → src-JQNz7cWv.js} +19 -2
  98. package/dist/{src-Bh9LRPb9.js.map → src-JQNz7cWv.js.map} +1 -1
  99. package/dist/storage/orphan-sweep.d.ts +67 -0
  100. package/dist/{upload-validation-CkkQGs-j.js → upload-validation-IYXn4xcm.js} +2 -2
  101. package/dist/{upload-validation-CkkQGs-j.js.map → upload-validation-IYXn4xcm.js.map} +1 -1
  102. package/dist/utils/logger.d.ts +9 -4
  103. package/package.json +7 -6
  104. package/dist/S3StorageController-CixCQEky.js.map +0 -1
  105. package/dist/auth-DDXPw0mn.js.map +0 -1
  106. package/dist/cron-loader-CC1Jy_KN.js.map +0 -1
  107. package/dist/field-access-DYsvjI_P.js.map +0 -1
  108. package/dist/logger-CW8pmTS6.js.map +0 -1
  109. package/dist/offline-AvuEcg7u-DFHL98OT.js.map +0 -1
  110. package/dist/offline-store-BhYXViha-YTmjBpo2.js.map +0 -1
  111. package/dist/openapi-generator-CyxEtYEX.js.map +0 -1
@@ -5,7 +5,9 @@
5
5
  * `@modelcontextprotocol/sdk`. The SDK's HTTP transport is built around Node's
6
6
  * `req`/`res`, this server is Hono, and the adapter would be more code than the
7
7
  * protocol — which, for a server that offers tools and neither prompts nor
8
- * sampling, is `initialize`, `tools/list`, `tools/call` and `ping`. It also
8
+ * sampling, is `initialize`, `tools/list`, `tools/call` and `ping`, plus
9
+ * `resources/list` and `resources/read` for the MCP App views (`mcp-apps.ts`)
10
+ * when there are any. It also
9
11
  * keeps a dependency out of `@rebasepro/server`, whose import graph feeds the
10
12
  * portable functions bundle.
11
13
  *
@@ -21,12 +23,19 @@
21
23
  * 401, and a token too narrow for the tool it names is 403 `insufficient_scope`.
22
24
  */
23
25
  import { Hono } from "hono";
26
+ import type { HonoRequest } from "hono";
24
27
  import type { AuthAdapter, CollectionConfig, DataDriver } from "@rebasepro/types";
25
28
  import type { HonoEnv } from "../api/types.js";
26
29
  import { type JwtService } from "../auth/jwt.js";
27
30
  import { type DataRateLimitConfig } from "../auth/rate-limiter.js";
31
+ import { type McpScopeVocabulary } from "./oauth-metadata.js";
32
+ import { type McpCaller, type McpToolDefinition } from "./mcp-tools.js";
33
+ import { type McpConfirmationStore } from "./confirmation.js";
34
+ import { type McpAppsSource } from "./mcp-apps.js";
28
35
  import type { ApiKeyIdentity, ApiKeyRefusal } from "../auth/api-keys/api-key-middleware.js";
29
36
  import type { McpGrantIdentity } from "./oauth-routes.js";
37
+ /** What `initialize` tells a client about the default data tools. */
38
+ export declare const DEFAULT_MCP_INSTRUCTIONS: string;
30
39
  /**
31
40
  * The most messages one JSON-RPC batch may carry.
32
41
  *
@@ -88,6 +97,38 @@ export interface McpRoutesConfig {
88
97
  * user repository, and then a token carries the roles it was minted with.
89
98
  */
90
99
  identity?: McpGrantIdentity;
100
+ /**
101
+ * The MCP App views this endpoint serves as `ui://` resources. Without
102
+ * them it declares no resources, and a tool that opens a view is not
103
+ * offered. See `mcp-apps.ts`.
104
+ */
105
+ apps?: McpAppsSource;
106
+ /**
107
+ * The tools this endpoint serves, in place of the default data tools
108
+ * (`MCP_TOOLS`). Each still refuses an argument it does not declare, and
109
+ * is offered only to a grant holding its `requiredScope`.
110
+ */
111
+ tools?: readonly McpToolDefinition[];
112
+ /** What `initialize` tells the client. {@link DEFAULT_MCP_INSTRUCTIONS} when omitted. */
113
+ instructions?: string;
114
+ /** The scopes a grant may hold. The data vocabulary when omitted. */
115
+ vocabulary?: McpScopeVocabulary;
116
+ /**
117
+ * Where a confirmed call's token is spent (`confirmation.ts`). The OAuth
118
+ * store's table on a backend; this process's memory when omitted, which
119
+ * is single-use only within one process.
120
+ */
121
+ confirmations?: McpConfirmationStore;
122
+ /**
123
+ * Decide who a request is, in place of the OAuth token and `rk_` key
124
+ * checks. A refusal is answered 401 with its words and a bare `Bearer`
125
+ * challenge — there is no authorization server to point at. The
126
+ * platform's endpoint (`platform-mcp.ts`) accepts platform tokens this
127
+ * way, and nothing else.
128
+ */
129
+ authenticate?(request: HonoRequest): Promise<McpCaller | {
130
+ refusal: string;
131
+ }>;
91
132
  }
92
133
  /**
93
134
  * The `.well-known` documents.
@@ -22,7 +22,7 @@
22
22
  * a row the user could not write themselves.
23
23
  */
24
24
  import type { AuthAdapter, CallerCredential, CollectionConfig, DataDriver } from "@rebasepro/types";
25
- import type { McpScope } from "./oauth-metadata.js";
25
+ import type { McpConfirmationPlan } from "./confirmation.js";
26
26
  /** The identity a tool call runs as. Comes from the verified access token. */
27
27
  export interface McpCaller {
28
28
  uid: string;
@@ -48,15 +48,35 @@ export interface McpToolContext {
48
48
  */
49
49
  authAdapter?: AuthAdapter;
50
50
  }
51
+ /**
52
+ * What a host may assume about a tool, sent with it on `tools/list` (MCP's
53
+ * `ToolAnnotations`). Hints, not guarantees: a host uses them to decide
54
+ * whether to ask the person before a call — Claude asks before any tool not
55
+ * marked read-only — and the server never relies on a host honouring them.
56
+ */
57
+ export interface McpToolAnnotations {
58
+ /** It changes nothing. A host may call it without asking. */
59
+ readOnlyHint?: boolean;
60
+ /** It may overwrite or remove what exists, rather than only add. Meaningful when not read-only. */
61
+ destructiveHint?: boolean;
62
+ /** Calling it twice with the same arguments does no more than calling it once. */
63
+ idempotentHint?: boolean;
64
+ /** It reaches outside this server (the open web, a third party). */
65
+ openWorldHint?: boolean;
66
+ }
51
67
  export interface McpToolDefinition {
52
68
  name: string;
69
+ /** The tool's name for a person, where a host shows one. */
70
+ title?: string;
53
71
  description: string;
54
72
  inputSchema: Record<string, unknown>;
55
73
  /**
56
- * The scope a caller must hold — on at least one collection for the tool
57
- * to be listed, and on the collection a call names for it to run.
74
+ * The scope a caller must hold — on at least one target for the tool to
75
+ * be listed. The data tools also check it on the collection a call names.
76
+ * A scope of the vocabulary the surface issues (see `McpScopeVocabulary`).
58
77
  */
59
- requiredScope: McpScope;
78
+ requiredScope: string;
79
+ annotations?: McpToolAnnotations;
60
80
  /**
61
81
  * Whether the reply carries the result a second time, as
62
82
  * `structuredContent`. The text block always carries it — it is what a
@@ -65,13 +85,37 @@ export interface McpToolDefinition {
65
85
  * so the reply is not twice its size. Defaults to true.
66
86
  */
67
87
  structuredContent?: boolean;
88
+ /**
89
+ * The MCP App view a host shows this tool's result in (see
90
+ * `mcp-apps.ts`). A tool with one is offered only where that view is
91
+ * served.
92
+ */
93
+ ui?: {
94
+ resourceUri: string;
95
+ };
96
+ /**
97
+ * Make the tool take two calls (`confirmation.ts`): the first answers the
98
+ * plan this returns and a token, and changes nothing; the second, with
99
+ * the same arguments and the token, runs {@link run}. For a tool that
100
+ * changes production or reaches outward. It must check what `run` will
101
+ * check, and throw {@link McpToolError} for what `run` would refuse, so a
102
+ * plan is never offered for a call that cannot happen.
103
+ */
104
+ confirm?(args: Record<string, unknown>, ctx: McpToolContext): Promise<McpConfirmationPlan>;
68
105
  run(args: Record<string, unknown>, ctx: McpToolContext): Promise<unknown>;
69
106
  }
70
107
  /** An error whose message is safe to hand back to the model. */
71
108
  export declare class McpToolError extends Error {
72
109
  }
110
+ /** The `ui://` resource show_collection opens. Built by `@rebasepro/mcp-apps`. */
111
+ export declare const COLLECTION_TABLE_URI = "ui://rebase/collection-table.html";
73
112
  export declare const MCP_TOOLS: McpToolDefinition[];
113
+ /**
114
+ * The tool, refusing any argument it does not declare. Every tool `/mcp`
115
+ * serves goes through this — the default data tools and an app's own.
116
+ */
117
+ export declare function declaredArgumentsOnly(tool: McpToolDefinition): McpToolDefinition;
74
118
  /** The tools a caller holding `scopes` may see and call: each needs its scope on at least one collection. */
75
- export declare function toolsForScopes(scopes: readonly string[]): McpToolDefinition[];
119
+ export declare function toolsForScopes(scopes: readonly string[], tools?: readonly McpToolDefinition[]): McpToolDefinition[];
76
120
  /** Look up a tool by name, honouring scope — an unlisted tool is not callable. */
77
- export declare function findTool(name: string, scopes: readonly string[]): McpToolDefinition | undefined;
121
+ export declare function findTool(name: string, scopes: readonly string[], tools?: readonly McpToolDefinition[]): McpToolDefinition | undefined;
@@ -12,6 +12,28 @@ export declare const MCP_SCOPES: readonly ["data:read", "data:write", "data:dele
12
12
  export type McpScope = (typeof MCP_SCOPES)[number];
13
13
  /** The scope a client gets when it asks for nothing in particular. */
14
14
  export declare const DEFAULT_MCP_SCOPE = "data:read";
15
+ /**
16
+ * The scopes one MCP surface issues: what a client may ask for, what it gets
17
+ * when it asks for nothing, and how the consent screen words each.
18
+ *
19
+ * A backend serves the data vocabulary ({@link DATA_SCOPE_VOCABULARY}) unless
20
+ * it supplies its own tools, and with them the scopes those tools need — the
21
+ * Rebase Cloud control plane issues `project:*`. A scope outside the
22
+ * vocabulary is dropped from a request, never granted.
23
+ */
24
+ export interface McpScopeVocabulary {
25
+ /** Every scope a grant may hold, each with the line the consent screen shows for it. */
26
+ supported: readonly {
27
+ scope: string;
28
+ description: string;
29
+ }[];
30
+ /** What a client that asks for nothing gets. One of `supported`. */
31
+ defaultScope: string;
32
+ }
33
+ /** The data-plane vocabulary: `/mcp`'s own, and every backend's unless it brings its own tools. */
34
+ export declare const DATA_SCOPE_VOCABULARY: McpScopeVocabulary;
35
+ /** The scope names a vocabulary issues. */
36
+ export declare function supportedScopes(vocabulary: McpScopeVocabulary): string[];
15
37
  /**
16
38
  * A scope string as granted before `/mcp` spoke the shared vocabulary, read as
17
39
  * what it granted: `mcp:read` was every read, `mcp:write` every create, change
@@ -48,7 +70,7 @@ export interface ProtectedResourceMetadata {
48
70
  bearer_methods_supported: string[];
49
71
  resource_documentation?: string;
50
72
  }
51
- export declare function protectedResourceMetadata(publicUrl: string, mcpPath?: string): ProtectedResourceMetadata;
73
+ export declare function protectedResourceMetadata(publicUrl: string, mcpPath?: string, vocabulary?: McpScopeVocabulary): ProtectedResourceMetadata;
52
74
  export interface AuthorizationServerMetadata {
53
75
  issuer: string;
54
76
  authorization_endpoint: string;
@@ -64,7 +86,7 @@ export interface AuthorizationServerMetadata {
64
86
  authorization_response_iss_parameter_supported: boolean;
65
87
  service_documentation?: string;
66
88
  }
67
- export declare function authorizationServerMetadata(publicUrl: string, oauthBasePath: string): AuthorizationServerMetadata;
89
+ export declare function authorizationServerMetadata(publicUrl: string, oauthBasePath: string, vocabulary?: McpScopeVocabulary): AuthorizationServerMetadata;
68
90
  /**
69
91
  * Verify a PKCE code verifier against the challenge recorded at authorize time.
70
92
  *
@@ -101,7 +123,7 @@ export declare function redirectUriAllowed(candidate: string, registered: string
101
123
  * entitled to and none of the ones it invented. A collection target is kept:
102
124
  * `data:read:posts` is a narrower grant, never a wider one.
103
125
  */
104
- export declare function narrowScope(requested: string | undefined | null): string;
126
+ export declare function narrowScope(requested: string | undefined | null, vocabulary?: McpScopeVocabulary): string;
105
127
  /** A granted scope string as the list of scopes it holds. */
106
128
  export declare function scopeList(scope: string): string[];
107
129
  /**
@@ -28,6 +28,7 @@ import type { HonoEnv } from "../api/types.js";
28
28
  import { type JwtService } from "../auth/jwt.js";
29
29
  import type { AuthRepository } from "../auth/interfaces.js";
30
30
  import type { OAuthStore } from "./oauth-store.js";
31
+ import { type McpScopeVocabulary } from "./oauth-metadata.js";
31
32
  export interface OAuthRoutesConfig {
32
33
  store: OAuthStore;
33
34
  /**
@@ -49,6 +50,8 @@ export interface OAuthRoutesConfig {
49
50
  * repository, and then a grant carries the roles it was consented with.
50
51
  */
51
52
  identity?: McpGrantIdentity;
53
+ /** The scopes this server issues and how consent words them. The data vocabulary when omitted. */
54
+ vocabulary?: McpScopeVocabulary;
52
55
  }
53
56
  /**
54
57
  * The account a grant acts for, read where a grant is issued or renewed.
@@ -86,7 +89,7 @@ export declare function redirectUriProblem(uri: string): string | null;
86
89
  * they need to read here is that the client gets *their own* access and no
87
90
  * more, and which collections it reaches when the grant names some.
88
91
  */
89
- export declare function describeScopes(scope: string): {
92
+ export declare function describeScopes(scope: string, vocabulary?: McpScopeVocabulary): {
90
93
  scope: string;
91
94
  description: string;
92
95
  }[];
@@ -20,7 +20,7 @@
20
20
  */
21
21
  import type { DataDriver } from "@rebasepro/types";
22
22
  /** Every table this store owns, for the revoke sweep and for tests. */
23
- export declare const OAUTH_TABLES: readonly ["rebase.oauth_clients", "rebase.oauth_authorization_codes", "rebase.oauth_refresh_tokens", "rebase.oauth_consents"];
23
+ export declare const OAUTH_TABLES: readonly ["rebase.oauth_clients", "rebase.oauth_authorization_codes", "rebase.oauth_refresh_tokens", "rebase.oauth_consents", "rebase.mcp_confirmations"];
24
24
  /**
25
25
  * How long an authorization code lives.
26
26
  *
@@ -152,6 +152,12 @@ export interface OAuthStore {
152
152
  * than implying an instant cut-off.
153
153
  */
154
154
  revokeGrant(uid: string, clientId: string): Promise<boolean>;
155
+ /**
156
+ * Spend a tool call's confirmation (`confirmation.ts`): true the first
157
+ * time a `jti` is presented, false after. One row per confirmed call,
158
+ * kept until its token could no longer verify anyway.
159
+ */
160
+ consumeConfirmation(jti: string, expiresAt: Date): Promise<boolean>;
155
161
  }
156
162
  /** One row of the "applications you have connected" list. */
157
163
  export interface GrantSummary {
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The platform's MCP endpoint: `POST /api/admin/mcp`, for platform tokens only.
3
+ *
4
+ * The hosted Rebase connector (docs/hosted-mcp-connector.md) lets a developer
5
+ * reach their Cloud projects' data from one MCP connection. The control plane
6
+ * does not run the data tools itself: it signs a platform token for the
7
+ * person and the project (`auth/platform-token.ts`) and forwards the call
8
+ * here, where the app's own MCP tools (`mcp-tools.ts`) run it — with this
9
+ * app's collections, callbacks, auth-collection rules and RLS, at the version
10
+ * that is deployed.
11
+ *
12
+ * What it accepts: an `rpt_` token verified against the platform's public key
13
+ * and this project's audience, granted at most {@link PLATFORM_MCP_SCOPES}.
14
+ * Nothing else — no OAuth access token, no `rk_` key, no session. It serves no
15
+ * discovery documents: no third party is meant to find it.
16
+ *
17
+ * Who a call runs as: `platform:<sub>` with the `admin` role, under RLS (the
18
+ * default policies' admin arm passes; `serverContext()` does not). That is the
19
+ * reach of the identity the platform's Studio uses, and the control plane
20
+ * grants it to the same people: the project's organization owners and admins,
21
+ * with Studio switched on for the project.
22
+ *
23
+ * Independent of `REBASE_MCP_ENABLED`: that is the app owner's decision to
24
+ * hand credentials to third-party software, and turning this on hands none.
25
+ *
26
+ * @module
27
+ */
28
+ import type { Hono } from "hono";
29
+ import type { HonoEnv } from "../api/types.js";
30
+ import { type PlatformTokenConfig } from "../auth/platform-token.js";
31
+ import { type McpRoutesConfig } from "./mcp-routes.js";
32
+ /** Where it is mounted, under `basePath`. */
33
+ export declare const PLATFORM_MCP_PATH = "/admin/mcp";
34
+ export type PlatformMcpConfig = Omit<McpRoutesConfig, "authenticate" | "resolveApiKey" | "identity" | "jwt" | "tools" | "vocabulary"> & {
35
+ platformTokens: PlatformTokenConfig;
36
+ };
37
+ export declare function createPlatformMcpRoutes(config: PlatformMcpConfig): Hono<HonoEnv>;
@@ -3,11 +3,11 @@ import __rebaseProcess from "process";
3
3
  globalThis.process ??= __rebaseProcess;
4
4
  __rebaseCreateRequire(import.meta.url);
5
5
  import { a as RebaseClientError, i as RebaseApiError, o as isUnsupported } from "./data_driver-D0mg1Y_x.js";
6
- import { D as Vector, E as GeoPoint, S as hasFieldOperation, T as EntityRelation, _ as normalizeOrderBy, c as collectAllPages, l as paginateFind, u as resolveFindWindow, w as EntityReference } from "./filter-dialect-TrKFWLqT.js";
7
- import { et as parseRelationAggregateSort, nt as toCanonicalOp } from "./src-Bh9LRPb9.js";
6
+ import { D as Vector, E as GeoPoint, S as hasFieldOperation, T as EntityRelation, _ as normalizeOrderBy, c as collectAllPages, l as paginateFind, u as resolveFindWindow, w as EntityReference } from "./filter-dialect-CE4bloug.js";
7
+ import { et as parseRelationAggregateSort, nt as toCanonicalOp } from "./src-JQNz7cWv.js";
8
8
  import { t as splitSearchTerms } from "./strings.es-B7QLnHh2.js";
9
- import { a as byIdRead, f as rebaseReviver, h as unref, i as buildQueryString, m as withETag, n as MemoryOfflineStore, p as etagOf, r as SDKQueryBuilder, s as createMutationId, t as IndexedDBOfflineStore, u as invalidBulkBody } from "./offline-store-BhYXViha-YTmjBpo2.js";
10
- //#region ../client/dist/offline-AvuEcg7u.js
9
+ import { a as byIdRead, f as rebaseReviver, h as unref, i as buildQueryString, m as withETag, n as MemoryOfflineStore, p as etagOf, r as SDKQueryBuilder, s as createMutationId, t as IndexedDBOfflineStore, u as invalidBulkBody } from "./offline-store-Cxhh99Q--FB6fSf5A.js";
10
+ //#region ../client/dist/offline-BjJdcVBb.js
11
11
  /**
12
12
  * Lossless round-tripping of rows through the offline store.
13
13
  *
@@ -959,6 +959,8 @@ function generateOfflineStringId() {
959
959
  *
960
960
  * Module-scoped and strictly decreasing: two temporary ids in the same session
961
961
  * must not collide, and neither must one minted a millisecond after another.
962
+ * Another tab has a module of its own, which the random part of
963
+ * {@link nextOfflineNumericId} covers.
962
964
  */
963
965
  var lastOfflineNumericId = 0;
964
966
  /**
@@ -974,11 +976,24 @@ var lastOfflineNumericId = 0;
974
976
  * reconciled it — and the SDK's own types said it could not happen.
975
977
  */
976
978
  function generateOfflineNumericId() {
977
- const candidate = -Date.now();
978
- lastOfflineNumericId = lastOfflineNumericId === 0 ? candidate : Math.min(candidate, lastOfflineNumericId - 1);
979
+ lastOfflineNumericId = nextOfflineNumericId(lastOfflineNumericId, Date.now(), Math.random());
979
980
  return lastOfflineNumericId;
980
981
  }
981
982
  /**
983
+ * The temporary numeric id after `last` (0 for none yet), at `now` with the
984
+ * random draw `random` in [0, 1).
985
+ *
986
+ * The millisecond, scaled by 1000, with three random digits under it. Tabs of
987
+ * one origin share the offline database but not the module that remembers
988
+ * `last`, so two that create in the same millisecond minted the same id from
989
+ * the millisecond alone, and one row took the other's place in the store.
990
+ * Scaled, the value stays a safe integer for another two centuries.
991
+ */
992
+ function nextOfflineNumericId(last, now, random) {
993
+ const candidate = -(now * 1e3 + Math.floor(random * 1e3));
994
+ return last === 0 ? candidate : Math.min(candidate, last - 1);
995
+ }
996
+ /**
982
997
  * The row an optimistic write puts in the cache before the server has seen it.
983
998
  *
984
999
  * It is NOT an `M`, and saying so is the point of collecting this in one place.
@@ -3062,6 +3077,19 @@ var OfflineManager = class {
3062
3077
  if (queued.data && !Array.isArray(queued.data)) queued.data.id = serverId;
3063
3078
  dirty = true;
3064
3079
  }
3080
+ if (queued.updates?.some((u) => String(u.id) === oldKey)) {
3081
+ queued.updates = queued.updates.map((u) => String(u.id) === oldKey ? {
3082
+ id: serverId,
3083
+ data: u.data
3084
+ } : u);
3085
+ this.queueChangedInPlace();
3086
+ dirty = true;
3087
+ }
3088
+ if (queued.ids?.some((id) => String(id) === oldKey)) {
3089
+ queued.ids = queued.ids.map((id) => String(id) === oldKey ? serverId : id);
3090
+ this.queueChangedInPlace();
3091
+ dirty = true;
3092
+ }
3065
3093
  const rollbackRows = queued.rollback?.rows;
3066
3094
  if (rollbackRows && oldKey in rollbackRows) {
3067
3095
  rollbackRows[String(serverId)] = rollbackRows[oldKey];
@@ -3389,4 +3417,4 @@ var OfflineManager = class {
3389
3417
  //#endregion
3390
3418
  export { OfflineManager };
3391
3419
 
3392
- //# sourceMappingURL=offline-AvuEcg7u-DFHL98OT.js.map
3420
+ //# sourceMappingURL=offline-BjJdcVBb-BOzzsnrh.js.map