* 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
* 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
* 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
* 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
* 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
* 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
* 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
- 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.
* 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
* 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"