Skip to content

Commit 160eca8

Browse files
update the doc strings
1 parent 94bdeb9 commit 160eca8

3 files changed

Lines changed: 13 additions & 15 deletions

File tree

src/semantic-search.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@
1313
* This is the primary method used when integrating with OpenAI, Anthropic, or AI SDK.
1414
* The internal flow is:
1515
*
16-
* 1. Fetch tools from linked accounts via MCP to discover available connectors
16+
* 1. Fetch tools from linked accounts via MCP (provides connectors and tool schemas)
1717
* 2. Search EACH connector in parallel via the semantic search API (/actions/search)
18-
* 3. The search API returns results with full `inputSchema` for each action
19-
* 4. Build executable tools directly from search results (no match-back needed)
20-
* 5. Deduplicate by actionId, sort by relevance score, apply topK
21-
* 6. Return Tools sorted by relevance score
18+
* 3. Match search results to MCP tool definitions
19+
* 4. Deduplicate, sort by relevance score, apply topK
20+
* 5. Return Tools sorted by relevance score
2221
*
2322
* Key point: only the user's own connectors are searched — no wasted results
24-
* from connectors the user doesn't have. The search API returns `inputSchema`
25-
* with each result, so tools can be built directly without a separate fetch.
23+
* from connectors the user doesn't have. Tool schemas come from MCP (source
24+
* of truth), while the search API provides relevance ranking.
2625
*
2726
* If the semantic API is unavailable, the SDK falls back to a local
2827
* BM25 + TF-IDF hybrid search over the fetched tools (unless
@@ -32,10 +31,9 @@
3231
* 2. `searchActionNames(query)` — Lightweight discovery
3332
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3433
*
35-
* Queries the semantic API directly and returns action metadata
36-
* (actionId, connector, score, description, inputSchema) **without**
37-
* building full tool objects. Useful for previewing results before
38-
* committing to a full fetch.
34+
* Queries the semantic API directly and returns action IDs with
35+
* similarity scores, **without** building full tool objects. Useful
36+
* for previewing results before committing to a full fetch.
3937
*
4038
* When `accountIds` are provided, each connector is searched in
4139
* parallel (same as `searchTools`). Without `accountIds`, results
@@ -103,7 +101,7 @@ export interface SemanticSearchOptions {
103101
* const client = new SemanticSearchClient({ apiKey: 'sk-xxx' });
104102
* const response = await client.search('create employee', { connector: 'bamboohr', topK: 5 });
105103
* for (const result of response.results) {
106-
* console.log(`${result.actionId}: ${result.similarityScore.toFixed(2)}`);
104+
* console.log(`${result.id}: ${result.similarityScore.toFixed(2)}`);
107105
* }
108106
* ```
109107
*/
@@ -146,7 +144,7 @@ export class SemanticSearchClient {
146144
* ```typescript
147145
* const response = await client.search('onboard a new team member', { topK: 5 });
148146
* for (const result of response.results) {
149-
* console.log(`${result.actionId}: ${result.similarityScore.toFixed(2)}`);
147+
* console.log(`${result.id}: ${result.similarityScore.toFixed(2)}`);
150148
* }
151149
* ```
152150
*/

src/tool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export class BaseTool {
145145
async execute(inputParams?: JsonObject | string, options?: ExecuteOptions): Promise<JsonObject> {
146146
try {
147147
if (!this.requestBuilder || this.executeConfig.kind !== 'http') {
148-
// Non-HTTP tools provide their own execute override (e.g. RPC, local meta tools).
148+
// Non-HTTP tools provide their own execute override (e.g. RPC, local tools).
149149
throw new StackOneError(
150150
'BaseTool.execute is only available for HTTP-backed tools. Provide a custom execute implementation for non-HTTP tools.',
151151
);

src/toolsets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ export class StackOneToolSet {
938938
allResults = response.results;
939939
}
940940

941-
// Sort by score — action_id is already in MCP format, no normalization needed
941+
// Sort by score — return raw results (consumers can normalize the composite ID if needed)
942942
allResults.sort((a, b) => b.similarityScore - a.similarityScore);
943943

944944
return effectiveTopK != null ? allResults.slice(0, effectiveTopK) : allResults;

0 commit comments

Comments
 (0)