Commit Graph

40 Commits

Author SHA1 Message Date
Sandeep Somavarapu cebb5e5a05 introduce search extensions tool (#246721)
* introduce search extensions tool

* update tool reference name
2025-04-16 16:21:04 +02:00
Rob Lourens 63c455f9bf Clean up internal edit file tool, take a proper URI from the extension (#246451)
* Clean up internal edit file tool, take a proper URI from the extension
Move more work back to the extension
For microsoft/vscode-copilot#15348

* Remove this
2025-04-14 15:52:57 -07:00
Rob Lourens 2bdf282f0a Pass model to tools (#244323)
* Pass model to tools
When tools make requests, they should use the right model. So we
- save the model id on the request
- look it up when the tool is invoked
- resolve it to a LanguageModelChat in the EH

* Fix build
2025-03-22 06:42:06 +00:00
Tyler James Leonhardt c64359d91d Add InternalFetchWebPageToolId to proposed API (#244061)
@roblourens's feedback here https://github.com/microsoft/vscode/pull/243922#discussion_r2002313669
2025-03-20 14:26:25 -07:00
Rob Lourens dd6e06a8f2 Add onDidDisposeChatSession to enable closing chat terminals when a chat session ends (#244030) 2025-03-19 20:22:38 +01:00
Logan Ramos fddc71e69f Pass through chatInteractionId to tool calls (#242915) 2025-03-07 11:44:55 -08:00
Rob Lourens 45f744af6c Custom tool invocation renderer for terminal tool (#241768)
* Custom tool invocation renderer for terminal tool
Enable editing the terminal command

* Fix issues
2025-02-24 14:35:06 -08:00
Rob Lourens 2e6b2792b9 Move edit_file tool to extension (#241657)
Core contributes a tool which is the real implementation of file editing, but the extension gets to control the tool result
2025-02-24 12:19:12 -08:00
Rob Lourens 0b111a9a74 Remove PreparedToolInvocation#tooltip (#241549)
No longer used
2025-02-21 19:57:45 -08:00
Rob Lourens 574218a101 Better API for hiding tool invocations (#241132) 2025-02-19 00:29:08 +01:00
Rob Lourens 0233903285 Support collapsible list of tool results (#240842) 2025-02-14 13:03:16 -08:00
Rob Lourens e6f3e3a874 Support dynamic tool message after tool runs (#240586) 2025-02-13 00:08:21 +01:00
Rob Lourens 47b4f5c1dd Don't hardcode editFile tool name (#239440) 2025-02-02 12:58:50 -08:00
Rob Lourens db8e3d2913 Fix EditFileTool in remote windows (#239250)
Map the filePath to a URI in the EH, then uriTransformer runs, tool gets a proper URI.
2025-01-30 20:59:22 +01:00
Rob Lourens 720f2eb1fb Implement past tense invocation message and tooltip for tool calls (#238635)
* Implement past tense invocation message and tooltip for tool calls

* Fix

* Clean up
2025-01-24 18:59:58 +01:00
Rob Lourens 4575cfbeca Check api proposal for tool request ID (#238634) 2025-01-24 06:47:17 +01:00
Rob Lourens d6d62da51b Plumb a requestID and location through the tool invocation to the codemapper request (#238429)
To drive codemapper telemetry
2025-01-22 08:07:01 +01:00
Rob Lourens ac721a2d45 Prevent extensions from registering tools with copilot_ or vscode_ in the name or tag (#237919)
* Allow extensions to access vscode_editing tagged tools. Can make a decision later on whether to keep that. But filter out editFile tool to avoid confusion

* Prevent extensions from registering tools with copilot_ or vscode_ in the name or tag
2025-01-14 20:39:54 +01:00
Rob Lourens 70866d5287 Enable "tools agent" (#237369)
* Add an edit tool (doesn't work)

* More

* Properly wait on text edits to be done applying

* Better editFile tool

* Fixes

* Be more insistent with editFile instructions

* Add "agent mode" UI

* Fix error thrown when calling tools sometimes

* Persist chat agent mode state

* Hide editing tools from other extensions for now

* Fix test build issues

* Allow disabling tools agent mode

* Remove comment

* Fix codeblock index properly

* Cleanup

* Cleanup

* Remove ccreq check

* Rename for clarity
2025-01-07 04:22:42 +00:00
Rob Lourens a370576a87 invocationMessage as MarkdownString (#233744)
* invocationMessage as MarkdownString
Fix #232985

* string | MarkdownString
2024-11-13 09:07:32 +01:00
Johannes 2568cf04a4 remove parameter/input backwards compat thing 2024-11-01 17:16:56 +01:00
Johannes Rieken d78d488f28 Change tool paramters to input and make sure parameters stills works to keep backwards compatibility (#232249)
fixes https://github.com/microsoft/vscode/issues/232143
2024-10-25 08:54:45 -07:00
Johannes Rieken 86a4d1d7b3 tools API tweaks (#232023)
* update ctor order of `LanguageModelToolCallPart`

fixes https://github.com/microsoft/vscode/issues/231925

* 💄 make `LanguageModelToolResultPart` follow after `LanguageModelToolCallPart`

* use `never` for `ChatParticipantToolToken` so that nothing can be assigned to it

https://github.com/microsoft/vscode/issues/231937

* polish doc

* keep API runtime stable

https://github.com/microsoft/vscode/issues/231938

* More updates

* Fix build

* Add validation for toolInvocationToken

---------

Co-authored-by: Rob Lourens <roblourens@gmail.com>
2024-10-23 16:25:27 -07:00
Rob Lourens bc0eb008a1 Finalize lmTools (#231788)
* @returns

* Finalize it

* small tweaks

* add `LanguageModelTextPart` to chat message and its factory functions

* update `LanguageModelChatResponse` docs

* more doc tweaks

* LangModelChatMessage.content always array

* Optional cancel token

* parameters notes

* Updates

---------

Co-authored-by: Johannes Rieken <johannes.rieken@gmail.com>
2024-10-21 18:21:43 -07:00
Rob Lourens 21219a938e lmTools API updates and LanguageModelPromptTsxPart (#231544)
* Try LanguageModelToolResultItem

* Implement it

* lmTools API updates
Resolve TODOs

* Fix build

* Doc

* More content type -> mime type

* More edits

* Fixes

* Add LanguageModelChatToolMode

* Add implementation

* New thing

* note

* API version bump

* Finish it

* Updates

* Properly convert tool result content parts
2024-10-18 13:31:58 -07:00
Rob Lourens 7e8a0d6d48 Clean up participantName 2024-10-11 11:08:39 -07:00
Rob Lourens de557e7b66 lmTools docs, tweaks (#230351)
* Tools API updates

* Add tool tags

* lmtools docs and tweaks

* Update src/vscode-dts/vscode.proposed.lmTools.d.ts

Co-authored-by: Joyce Er <joyce.er@microsoft.com>

* Update src/vscode-dts/vscode.proposed.lmTools.d.ts

Co-authored-by: Joyce Er <joyce.er@microsoft.com>

* Fix build

---------

Co-authored-by: Joyce Er <joyce.er@microsoft.com>
2024-10-02 19:02:38 -07:00
Rob Lourens 03446f5c73 Tool confirmations (#229256)
* Chat tool confirmations

* Clean up

* Secondary

* Get messages from tool dynamically

* Call message provider methods on extension

* Don't send tool invocations as part of history

* Make provideToolInvocationMessage optional

* Remove terminal tool

* Serialize tool invocation correctly

* Show x when tool is dismissed

* Fix confirmation rerendering

* Fix test

* Fix rule

* Enable markdown in confirmation message

* Fix

* Comments
2024-09-23 16:36:33 -07:00
Rob Lourens fd772c9a1b Tools declare their supported content types and invokeTool requests a set of content types (#228903)
* Tools declare their supported content types and invokeTool requests a set of content types
For #213274

* Enforce requestedContentTypes strictly

* Fix test

* Add prompt-tsx note
2024-09-20 14:51:11 -07:00
Rob Lourens 65843d6c66 Tools API with a single invokeTool, show spinner for tool call (#228181)
* Chat tool confirmations

* await
2024-09-11 22:16:17 +02:00
Benjamin Pasero 6b924c5152 ESM merge to main (#227184)
Co-authored-by: Johannes Rieken <jrieken@microsoft.com>
Co-authored-by: Alexandru Dima <alexdima@microsoft.com>
2024-08-30 10:31:46 +02:00
Rob Lourens ff7a154d5e Don't allow returning a Promise from a tool call (#226688) 2024-08-27 02:46:59 +02:00
Rob Lourens 34b5026049 Add 'when' clause for tools (#226483)
* Add 'when' clause for tools
#213274

* Fix test
2024-08-23 21:54:29 +02:00
Connor Peet aca1518b48 api: some slight lmtools polish (#226371)
- Have `countTokens` only take a string for now, since that's all that
  tool elements in tsx should currently omit (not chat messages with
	roles.) String counting is a much easier interface to satisfy.
- Joyce pointed out that it's "invocation" not "invokation", for reasons
  unfathomable to me. I will open an issue with the English language.
2024-08-23 07:16:02 +02:00
Connor Peet 2bf25ee2fd lm: a second rendition of returning data from LM tools (#225634)
* lm: a second rendition of returning data from LM tools

This is an alternative to #225454. It allows the tool caller to pass
through token budget and counting information to the tool, and the
tool can then 'do its thing.'

Most of the actual implementation is in prompt-tsx with a new method to
render elements into a JSON-serializable form, and then splice them back
into the tree by the consumer. The implementation can be found here:

https://github.com/microsoft/vscode-prompt-tsx/tree/connor4312/tools-api-v2

On the tool side, this looks like:

```ts
vscode.lm.registerTool('myTestTool', {
	async invoke(context, token): Promise<vscode.LanguageModelToolResult> {
		return {
			// context includes the token info:
			'mytype': await renderElementJSON(MyCustomPrompt, {}, context, token),
			toString() {
				return 'hello world!'
			}
		};
	},
});
```

I didn't make any nice wrappers yet, but the MVP consumer side looks like:

```
export class TestPrompt extends PromptElement {
    async render(_state: void, sizing: PromptSizing) {
        const result = await vscode.lm.invokeTool('myTestTool', {
			parameters: {},
			tokenBudget: sizing.tokenBudget,
            countTokens: (v, token) => tokenizer.countTokens(v, token),
		}, new vscode.CancellationTokenSource().token);

        return (
            <>
                <elementJSON data={result.mytype} />
            </>
        );
    }
}
```

I like this approach better. It avoids bleeding knowledge of TSX into
the extension host and comparatively simple.

* address comments

* address comments
2024-08-22 09:41:31 -07:00
Rob Lourens 95058f56ba Expose language model tools as chat variables/attachments (#225450)
* Fix icons for tool attachments

* Add tool ID, replace requestedTools, parse in query (mostly)

* Finish handling tool calls as # variables

* API version bump

* Fix tests

* Fix tests

* Fix tests again, again

* Fix test again, again, again
2024-08-12 19:07:01 -07:00
Rob Lourens da2eb39383 Support returning different types from chat tools API (#224894)
See #213274
2024-08-05 16:04:21 -07:00
Rob Lourens 4b51cf1a64 Enable tool calls to be requested manually by the user (#223143)
* Support user requesting tool calls

* Add toolChoice option

* Add icons to tools

* Fix build
2024-07-22 16:03:06 -07:00
Rob Lourens ee173b0e65 Tools API tweaks, merge into lmTools (#216750)
* Tools API tweaks, merge into lmTools

* Rename more id -> name

* Fix

* Add lmTools API version
2024-06-20 18:54:00 -07:00
Rob Lourens 88b4dc75bd Chat Tools API (#213273)
* Implement a chat skills API

* Move around

* Rename to 'tools' and make variables part of it

* Updates

* value

* Differentiate 'tool invocation' and 'reference'

* Just one interface, ChatReference

* dts updates

* Rename "skills" to "tools"

* Fix up

* Add static registration of tools

* string

* Updates

* Fix

* Rename 'chat' in API

* Rename "chatTool"
2024-06-18 16:38:20 -07:00