@talonic/mcp 0.1.110 → 0.1.112

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.
@@ -9874,6 +9874,21 @@ function handleDecideApproval(getToken, baseUrl, args) {
9874
9874
  )
9875
9875
  );
9876
9876
  }
9877
+ var OPEN_ASKS_DESCRIPTION = [
9878
+ "List what colleagues sent the person through their agents that still waits for them: requests, tasks and messages from the last 30 days, soonest due first. Read straight from the workspace, no agent turn and no credits.",
9879
+ "USE WHEN: the person asks what to work on, what is open for them, or what colleagues are waiting for.",
9880
+ "NOT FOR: answering a request (send the answer with talonic_thread_send); drafts waiting for approval (talonic_thread_list_drafts).",
9881
+ "",
9882
+ "ARGS: optional `limit` (1-100, default 50).",
9883
+ "RETURNS: { asks[] { id, kind message|task|request, from, text, answer_shape, choices[], due, sent_at, still_open[] } }. still_open: steps that tick off by themselves once done."
9884
+ ].join("\n");
9885
+ var openAsksInputSchema = {
9886
+ limit: z.number().int().min(1).max(100).optional().describe("Most requests to return (1-100, default 50).")
9887
+ };
9888
+ function handleOpenAsks(getToken, baseUrl, args = {}) {
9889
+ const q = args.limit ? `?limit=${args.limit}` : "";
9890
+ return runTool(() => apiJson(getToken, baseUrl, "GET", `/v1/thread/asks${q}`));
9891
+ }
9877
9892
  var DRAFTS_DESCRIPTION = [
9878
9893
  "List the drafts the thread prepared and is waiting for the person to approve: an email, a start of one of their processes, or sharing one of their documents. Each names what a decision must quote back.",
9879
9894
  "USE WHEN: before talonic_thread_decide_draft, to show the person exactly what would happen.",
@@ -10008,6 +10023,42 @@ function handleFigure(getToken, baseUrl, args) {
10008
10023
  })
10009
10024
  );
10010
10025
  }
10026
+ var THREAD_RECONNECT_TOOL = "talonic_thread_reconnect";
10027
+ var THREAD_READ_SCOPE = "thread:read";
10028
+ var THREAD_RECONNECT_TEXT = "This Talonic connection was made before the personal agent was part of it, so it cannot reach the agent yet. Reconnect Talonic once: in Claude, open Settings > Connectors, remove Talonic and add it again (in Claude Code: /mcp, Talonic, re-authenticate), then accept the Talonic consent screen. Your agent then acts with exactly your own Talonic permissions.";
10029
+ function tokenLacksThreadScopes(token) {
10030
+ if (token.startsWith("tlnc_")) return false;
10031
+ const parts = token.split(".");
10032
+ if (parts.length !== 3) return false;
10033
+ try {
10034
+ const payload = JSON.parse(Buffer.from(parts[1] ?? "", "base64url").toString("utf8"));
10035
+ return Array.isArray(payload.scopes) && !payload.scopes.includes(THREAD_READ_SCOPE);
10036
+ } catch {
10037
+ return false;
10038
+ }
10039
+ }
10040
+ function registerThreadReconnectTool(server) {
10041
+ server.registerTool(
10042
+ THREAD_RECONNECT_TOOL,
10043
+ {
10044
+ title: "Connect your Talonic agent",
10045
+ description: [
10046
+ "The person's Talonic personal agent (their thread, requests colleagues sent them, drafts waiting for approval) is not reachable over this connection yet. " + THREAD_RECONNECT_TEXT,
10047
+ "USE WHEN: the person asks for their Talonic agent, their thread, what to work on, or open requests from colleagues.",
10048
+ "ARGS: none.",
10049
+ "RETURNS: what the person has to do; tell them in one or two sentences."
10050
+ ].join("\n"),
10051
+ inputSchema: {},
10052
+ annotations: {
10053
+ readOnlyHint: true,
10054
+ destructiveHint: false,
10055
+ idempotentHint: true,
10056
+ openWorldHint: false
10057
+ }
10058
+ },
10059
+ async () => ({ content: [{ type: "text", text: THREAD_RECONNECT_TEXT }] })
10060
+ );
10061
+ }
10011
10062
  function registerThreadTools(server, getToken, baseUrl) {
10012
10063
  const tools2 = [
10013
10064
  [
@@ -10050,6 +10101,14 @@ function registerThreadTools(server, getToken, baseUrl) {
10050
10101
  write13(false, false, true),
10051
10102
  (a) => handleDecideApproval(getToken, baseUrl, a)
10052
10103
  ],
10104
+ [
10105
+ "talonic_thread_open_asks",
10106
+ "List requests waiting for you",
10107
+ OPEN_ASKS_DESCRIPTION,
10108
+ openAsksInputSchema,
10109
+ readOnly13,
10110
+ (a) => handleOpenAsks(getToken, baseUrl, a)
10111
+ ],
10053
10112
  [
10054
10113
  "talonic_thread_list_drafts",
10055
10114
  "List prepared drafts",
@@ -18179,7 +18238,7 @@ function registerOperationsTools(server, getToken, baseUrl, families) {
18179
18238
 
18180
18239
  // package.json
18181
18240
  var package_default = {
18182
- version: "0.1.110"};
18241
+ version: "0.1.112"};
18183
18242
 
18184
18243
  // src/version.ts
18185
18244
  var VERSION = package_default.version;
@@ -18433,6 +18492,9 @@ function createServer(options) {
18433
18492
  if (options.includeSchemaReviewTools) {
18434
18493
  registerSchemaReviewTools(server, rawToken, baseUrl);
18435
18494
  }
18495
+ if (!options.includeThreadTools && options.includeThreadReconnect) {
18496
+ registerThreadReconnectTool(server);
18497
+ }
18436
18498
  if (options.includeThreadTools) {
18437
18499
  registerThreadTools(server, rawToken, baseUrl);
18438
18500
  }
@@ -18669,6 +18731,16 @@ function extractBearerToken(req) {
18669
18731
  }
18670
18732
  return void 0;
18671
18733
  }
18734
+ function insufficientScopeChallenge(path) {
18735
+ const suffix = isMcpPath(path) ? "/mcp" : "";
18736
+ return `Bearer error="insufficient_scope", scope="${SCOPES_SUPPORTED.join(" ")}", resource_metadata="${RESOURCE_URL}/.well-known/oauth-protected-resource${suffix}", error_description="The personal agent needs the thread scopes; reconnect to grant them."`;
18737
+ }
18738
+ function threadToolCallId(parsed) {
18739
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return void 0;
18740
+ const msg = parsed;
18741
+ if (msg.method !== "tools/call" || typeof msg.params?.name !== "string") return void 0;
18742
+ return msg.params.name.startsWith("talonic_thread_") ? { id: msg.id ?? null } : void 0;
18743
+ }
18672
18744
  function wwwAuthenticate(path) {
18673
18745
  const suffix = isMcpPath(path) ? "/mcp" : "";
18674
18746
  return `Bearer error="invalid_token", resource_metadata="${RESOURCE_URL}/.well-known/oauth-protected-resource${suffix}"`;
@@ -18950,6 +19022,22 @@ function createRequestHandler(options = {}) {
18950
19022
  (options.myDataAccess ?? myDataAccessCached)(token),
18951
19023
  (options.appWorkflowGroups ?? appWorkflowGroupsCached)(token)
18952
19024
  ]);
19025
+ const threadNeedsConsent = !includeThreadTools && tokenLacksThreadScopes(token);
19026
+ const threadCall = threadNeedsConsent ? threadToolCallId(parsed) : void 0;
19027
+ if (threadCall) {
19028
+ res.writeHead(403, {
19029
+ "Content-Type": "application/json",
19030
+ "WWW-Authenticate": insufficientScopeChallenge(path)
19031
+ });
19032
+ res.end(
19033
+ JSON.stringify({
19034
+ jsonrpc: "2.0",
19035
+ id: threadCall.id,
19036
+ error: { code: -32001, message: THREAD_RECONNECT_TEXT }
19037
+ })
19038
+ );
19039
+ return;
19040
+ }
18953
19041
  const includeDecisionTaskTools = externalAppsInUse || includeMiningDriverTools;
18954
19042
  const mcpServer = createServer({
18955
19043
  tokenProvider: () => token,
@@ -18982,6 +19070,7 @@ function createRequestHandler(options = {}) {
18982
19070
  includeRecordsAdminTools,
18983
19071
  includeWorkspaceTools,
18984
19072
  includeThreadTools,
19073
+ includeThreadReconnect: threadNeedsConsent,
18985
19074
  includeAgentTurnTools,
18986
19075
  includeMyDataTools,
18987
19076
  appWorkflowGroups,
@@ -19032,6 +19121,6 @@ if (isDirectInvocation()) {
19032
19121
  });
19033
19122
  }
19034
19123
 
19035
- export { PRODUCTS_SCOPES, SCOPES_SUPPORTED, THREAD_SCOPES, adminAgentTaskAccessCached, agentTasksAccessCached, agentTurnsAccessCached, apAccessCached, appWorkflowAccessCached, appWorkflowGroupsCached, appsToolsetAccessCached, casesAccessCached, contractsAccessCached, createRequestHandler, dataPoliciesAccessCached, dataProductsAccessCached, decisionTasksAccessCached, docGenAccessCached, growthAccessCached, integrationsAccessCached, isOpenAiClient, masterRecordsAccessCached, miningAccessCached, myDataAccessCached, operationsAccessCached, partiesAccessCached, portfolioAccessCached, priceBaselineAccessCached, processesAccessCached, recordsAdminAccessCached, reviewAccessCached, schemaReviewAccessCached, specAuthoringAccessCached, submissionsAccessCached, teamAdminAccessCached, threadAccessCached, tokenAcceptedCached, toolGroupsAccessCached, workspaceAccessCached, workspaceDataAccessCached };
19124
+ export { PRODUCTS_SCOPES, SCOPES_SUPPORTED, THREAD_SCOPES, adminAgentTaskAccessCached, agentTasksAccessCached, agentTurnsAccessCached, apAccessCached, appWorkflowAccessCached, appWorkflowGroupsCached, appsToolsetAccessCached, casesAccessCached, contractsAccessCached, createRequestHandler, dataPoliciesAccessCached, dataProductsAccessCached, decisionTasksAccessCached, docGenAccessCached, growthAccessCached, insufficientScopeChallenge, integrationsAccessCached, isOpenAiClient, masterRecordsAccessCached, miningAccessCached, myDataAccessCached, operationsAccessCached, partiesAccessCached, portfolioAccessCached, priceBaselineAccessCached, processesAccessCached, recordsAdminAccessCached, reviewAccessCached, schemaReviewAccessCached, specAuthoringAccessCached, submissionsAccessCached, teamAdminAccessCached, threadAccessCached, tokenAcceptedCached, toolGroupsAccessCached, workspaceAccessCached, workspaceDataAccessCached };
19036
19125
  //# sourceMappingURL=http-server.js.map
19037
19126
  //# sourceMappingURL=http-server.js.map