@miniaxolotl/grove-server 1.11.2 → 1.11.3

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/dist/server.js CHANGED
@@ -13,7 +13,7 @@ var __export = (target, all2) => {
13
13
  var define_GROVE_TELEMETRY_default;
14
14
  var init_define_GROVE_TELEMETRY = __esm({
15
15
  "<define:__GROVE_TELEMETRY__>"() {
16
- define_GROVE_TELEMETRY_default = { enabled: true, revision: "862ea7d1f1b5b843f5080d549c4a33c177f39a5e", version: "1.11.2", component: "api", key: "phc_AqVrjhk7W2X2pFjyngY7uWxcSSRREfJhgr8mBmKbXYEh", cliDsn: "https://3f6d0711b5890dea4ce8e6ccf2a1a7fd@o4511632209346560.ingest.us.sentry.io/4512290791620608", apiDsn: "https://4524e8910e318110277babdfe818999b@o4511632209346560.ingest.us.sentry.io/4512290791489536" };
16
+ define_GROVE_TELEMETRY_default = { enabled: true, revision: "311212e29921d19c8f58b2ca5382ec0790867293", version: "1.11.3", component: "api", key: "phc_AqVrjhk7W2X2pFjyngY7uWxcSSRREfJhgr8mBmKbXYEh", cliDsn: "https://3f6d0711b5890dea4ce8e6ccf2a1a7fd@o4511632209346560.ingest.us.sentry.io/4512290791620608", apiDsn: "https://4524e8910e318110277babdfe818999b@o4511632209346560.ingest.us.sentry.io/4512290791489536" };
17
17
  }
18
18
  });
19
19
 
@@ -12725,6 +12725,9 @@ var grantSchema = z6.object({
12725
12725
  var connectionSchema = grantSchema.extend({
12726
12726
  clientId: z6.string().min(1).max(500)
12727
12727
  });
12728
+ var connectionUpdateSchema = grantSchema.extend({
12729
+ expectedState: z6.string().regex(/^[a-f0-9]{64}$/).optional()
12730
+ });
12728
12731
  var agentSchema = z6.enum(["opencode", "claude", "codex"]);
12729
12732
  var agentNames = {
12730
12733
  opencode: "OpenCode",
@@ -12830,25 +12833,30 @@ var notebookToolLifecycleSchema = z7.object({
12830
12833
  );
12831
12834
  var memoryTools = {
12832
12835
  remember: {
12836
+ title: "Save a memory",
12833
12837
  schema: rememberSchema,
12834
12838
  description: "Save a concise memory or replace it by id/expectedVersion. Corrections replace metadata too: prefer update_memory for partial edits. Reuse operationId on retries. Handoffs default to 30 days; expired records are hidden and later soft-deleted."
12835
12839
  },
12836
12840
  recall: {
12841
+ title: "Recall saved context",
12837
12842
  schema: recallSchema,
12838
12843
  readOnly: true,
12839
12844
  description: "Recall bounded relevant active memories in the explicit project/personal scope. Without query, retrieve a compact profile and selected task handoff."
12840
12845
  },
12841
12846
  memories: {
12847
+ title: "Find memories",
12842
12848
  schema: listSchema,
12843
12849
  readOnly: true,
12844
12850
  description: "Search and list notes with IDs, versions, provenance, status/tag filters and cursor pagination. Omit projectId to inspect all granted scopes; null means Personal."
12845
12851
  },
12846
12852
  forget: {
12853
+ title: "Delete selected memories",
12847
12854
  schema: forgetSchema,
12848
12855
  destructive: true,
12849
12856
  description: "Soft-delete exact note IDs at their expectedVersion. Retained authored history is hidden, not physically erased. There is no ordinary restore/Undo for deletion. Inspect each outcome; previously delivered text cannot be retracted."
12850
12857
  },
12851
12858
  get_memory: {
12859
+ title: "Read a memory",
12852
12860
  schema: z7.object({
12853
12861
  id: uuidSchema,
12854
12862
  revision: z7.number().int().positive().optional()
@@ -12857,19 +12865,23 @@ var memoryTools = {
12857
12865
  description: "Read one exact note by ID, optionally at a historical revision. Current scope, deletion and historical-source expiry checks still apply."
12858
12866
  },
12859
12867
  memory_history: {
12868
+ title: "Read memory history",
12860
12869
  schema: z7.object({ id: uuidSchema }).strict(),
12861
12870
  readOnly: true,
12862
12871
  description: "Read up to 100 most recent revisions of an accessible note. Use get_memory with revision for historical content."
12863
12872
  },
12864
12873
  update_memory: {
12874
+ title: "Update a memory",
12865
12875
  schema: memoryUpdateSchema,
12866
12876
  description: "Partially update a note at expectedVersion. Omitted content, scope, kind, provenance and lifetime are preserved. projectId moves the note; null means Personal. Reuse operationId on retry."
12867
12877
  },
12868
12878
  move_memories: {
12879
+ title: "Move memories",
12869
12880
  schema: moveMemoriesSchema,
12870
12881
  description: "Atomically move up to 50 exact ID/version notes into an existing notebook (projectId) or Personal (null). Preserve content and metadata; source and destination must be granted. Reuse operationId."
12871
12882
  },
12872
12883
  archive_memory: {
12884
+ title: "Archive a memory",
12873
12885
  schema: z7.object({
12874
12886
  id: uuidSchema,
12875
12887
  operationId: operationSchema,
@@ -12878,23 +12890,28 @@ var memoryTools = {
12878
12890
  description: "Archive an exact note at expectedVersion, removing it from recall. Content/history remain available; restore_memory reverses archive. Reuse operationId."
12879
12891
  },
12880
12892
  restore_memory: {
12893
+ title: "Restore a memory",
12881
12894
  schema: versionSchema.extend({ id: uuidSchema }),
12882
12895
  description: "Restore an archived/expired note or a historical revision at expectedVersion. Deleted notes cannot be restored. Optional revision selects history; durable removes expiry. Reuse operationId."
12883
12896
  },
12884
12897
  notebooks: {
12898
+ title: "Find notebooks",
12885
12899
  schema: notebookListSchema,
12886
12900
  readOnly: true,
12887
12901
  description: "List/search granted notebooks (folders) with IDs, names, parentId, versions and cursor pagination. Follow every page to build a tree. Archived notebooks require an owner website session."
12888
12902
  },
12889
12903
  create_notebook: {
12904
+ title: "Create a notebook",
12890
12905
  schema: notebookCreateSchema,
12891
12906
  description: "Create a notebook, optionally under parentId. Requires all-project write access or an owner session. Reuse operationId for retry-safe creation."
12892
12907
  },
12893
12908
  update_notebook: {
12909
+ title: "Update a notebook",
12894
12910
  schema: notebookUpdateSchema,
12895
12911
  description: "Rename and/or move an existing notebook at expectedVersion. Omitted fields are preserved; parentId=null moves to root. Source and parent must be granted; cycles are rejected. Reuse operationId."
12896
12912
  },
12897
12913
  notebook_lifecycle: {
12914
+ title: "Manage notebook lifecycle",
12898
12915
  schema: notebookToolLifecycleSchema,
12899
12916
  destructive: true,
12900
12917
  description: "Owner website session only: preview a notebook subtree, then archive/restore/soft-delete using its fingerprint, expectedVersion and operationId. Agent OAuth/API keys cannot administer subtrees. Deletion hides retained history and has no ordinary Undo."
@@ -18714,9 +18731,9 @@ var ConnectionSetup = class {
18714
18731
  0,
18715
18732
  100
18716
18733
  ),
18717
- capabilities: ["memory:read", "memory:write"],
18734
+ capabilities: [...capabilities],
18718
18735
  personal: true,
18719
- allProjects: false,
18736
+ allProjects: true,
18720
18737
  projectIds: []
18721
18738
  }
18722
18739
  };
@@ -20807,11 +20824,33 @@ ${input.query}`.slice(-1e3) : input.query;
20807
20824
  if (created) currentTelemetry().capture("notebook_created");
20808
20825
  return result;
20809
20826
  }
20827
+ connectionState(connection) {
20828
+ return createHmac4("sha256", this.cursorSecret).update(
20829
+ JSON.stringify([
20830
+ "connection-review-v1",
20831
+ connection.accountId,
20832
+ connection.id,
20833
+ connection.clientId,
20834
+ connection.name,
20835
+ [...connection.capabilities].sort(),
20836
+ connection.personal,
20837
+ connection.allProjects,
20838
+ [...connection.projectIds].sort(),
20839
+ connection.expiresAt,
20840
+ connection.revokedAt,
20841
+ connection.authorizedAfter,
20842
+ connection.setup ?? null
20843
+ ])
20844
+ ).digest("hex");
20845
+ }
20810
20846
  async connections(principal) {
20811
20847
  return this.access(
20812
20848
  principal,
20813
20849
  "admin",
20814
- async ({ trx }) => trx("connections").orderBy("createdAt", "desc").limit(100)
20850
+ async ({ trx }) => (await trx("connections").orderBy("createdAt", "desc").limit(100)).map((connection) => ({
20851
+ ...connection,
20852
+ state: this.connectionState(connection)
20853
+ }))
20815
20854
  );
20816
20855
  }
20817
20856
  async grant(principal, input, options = {}) {
@@ -20831,6 +20870,12 @@ ${input.query}`.slice(-1e3) : input.query;
20831
20870
  const old = await trx("connections").where({ id: options.id }).forUpdate().first();
20832
20871
  if (!old)
20833
20872
  throw new GroveError("not_found", "Connection not found", 404);
20873
+ if (options.expectedState && options.expectedState !== this.connectionState(old))
20874
+ throw new GroveError(
20875
+ "connection_conflict",
20876
+ "Connection access changed. Close this dialog, refresh Connections, and review the current permissions before saving.",
20877
+ 409
20878
+ );
20834
20879
  if (old.revokedAt && !old.clientId)
20835
20880
  throw new GroveError(
20836
20881
  "connection_revoked",
@@ -37555,6 +37600,7 @@ function createMemoryMcp(execute) {
37555
37600
  server.registerTool(
37556
37601
  name,
37557
37602
  {
37603
+ title: tool.title,
37558
37604
  description: tool.description,
37559
37605
  inputSchema: tool.schema.shape,
37560
37606
  annotations: {
@@ -38117,6 +38163,11 @@ function createApp(deps) {
38117
38163
  };
38118
38164
  app.get("/.well-known/oauth-protected-resource/mcp", (c) => c.json(metadata));
38119
38165
  app.get("/.well-known/oauth-protected-resource", (c) => c.json(metadata));
38166
+ app.get("/.well-known/openai-apps-challenge", (c) => {
38167
+ if (!deps.openaiAppsChallenge) return c.notFound();
38168
+ c.header("Cache-Control", "no-store");
38169
+ return c.text(deps.openaiAppsChallenge);
38170
+ });
38120
38171
  app.get("/health/live", (c) => c.json({ status: "ok" }));
38121
38172
  app.get("/health/ready", async (c) => {
38122
38173
  await deps.ready();
@@ -39102,17 +39153,16 @@ function createApp(deps) {
39102
39153
  data: await service.grant(c.get("principal"), grant, { clientId })
39103
39154
  });
39104
39155
  });
39105
- app.patch(
39106
- "/v1/connections/:id",
39107
- async (c) => c.json({
39156
+ app.patch("/v1/connections/:id", async (c) => {
39157
+ const { expectedState, ...grant } = await body(c, connectionUpdateSchema);
39158
+ return c.json({
39108
39159
  success: true,
39109
- data: await service.grant(
39110
- c.get("principal"),
39111
- await body(c, grantSchema),
39112
- { id: uuidSchema.parse(c.req.param("id")) }
39113
- )
39114
- })
39115
- );
39160
+ data: await service.grant(c.get("principal"), grant, {
39161
+ id: uuidSchema.parse(c.req.param("id")),
39162
+ expectedState
39163
+ })
39164
+ });
39165
+ });
39116
39166
  app.delete(
39117
39167
  "/v1/connections/:id",
39118
39168
  async (c) => c.json({
@@ -39285,11 +39335,22 @@ function createApp(deps) {
39285
39335
  });
39286
39336
  app.all("/mcp", async (c) => {
39287
39337
  const principal = c.get("principal");
39288
- await service.me(principal);
39289
- const execute = async (tool, value, signal) => withDatabaseSignal(
39290
- AbortSignal.any([databaseSignal(), ...signal ? [signal] : []]),
39291
- () => executeMemoryTool(service, principal, tool, value, signal)
39292
- );
39338
+ const identity = await service.me(principal);
39339
+ const execute = async (tool, value, signal) => {
39340
+ if (principal.type === "oauth" && !identity.capabilities.length) {
39341
+ const approval = new URL("/app/settings/connections", deps.siteUrl);
39342
+ approval.hash = `connection-${principal.connectionId}`;
39343
+ throw new GroveError(
39344
+ "connection_required",
39345
+ `Sign-in is complete. Approve OAuth client ${principal.clientId} in Grove Connections: ${approval.href} . Use the same Grove account, then return to your chat and retry. Sign-in alone grants no note access.`,
39346
+ 403
39347
+ );
39348
+ }
39349
+ return withDatabaseSignal(
39350
+ AbortSignal.any([databaseSignal(), ...signal ? [signal] : []]),
39351
+ () => executeMemoryTool(service, principal, tool, value, signal)
39352
+ );
39353
+ };
39293
39354
  const server = createMemoryMcp(execute);
39294
39355
  const transport = new WebStandardStreamableHTTPServerTransport({
39295
39356
  sessionIdGenerator: void 0,
@@ -39500,6 +39561,11 @@ var serverSchema = z17.object({
39500
39561
  API_INTERACTIVE_TIMEOUT_MS: z17.coerce.number().int().min(100).max(18e4).default(9e4),
39501
39562
  API_ORIGIN: origin,
39502
39563
  SITE_URL: origin,
39564
+ // Public ownership proof, never an account credential. Empty values are omitted below.
39565
+ OPENAI_APPS_CHALLENGE: z17.string().min(1).max(512).refine(
39566
+ (value) => !/\s/.test(value),
39567
+ "Use the exact non-whitespace verification token"
39568
+ ).optional(),
39503
39569
  CLERK_PUBLISHABLE_KEY: z17.string().startsWith("pk_"),
39504
39570
  CLERK_SECRET_KEY: z17.string().startsWith("sk_"),
39505
39571
  CLERK_ISSUER: origin,
@@ -40514,6 +40580,7 @@ async function startServer() {
40514
40580
  ),
40515
40581
  origin: env.API_ORIGIN,
40516
40582
  siteUrl: env.SITE_URL,
40583
+ openaiAppsChallenge: env.OPENAI_APPS_CHALLENGE,
40517
40584
  issuer: env.CLERK_ISSUER,
40518
40585
  webhookSecret: env.CLERK_WEBHOOK_SIGNING_SECRET,
40519
40586
  ready: async () => {