Skip to content

Add resolveResource method to ResourceHost interface with documentation#1818

Merged
pelikhan merged 11 commits intodevfrom
copilot/fix-66ab302c-0453-432c-b543-c232c106e6bb
Aug 2, 2025
Merged

Add resolveResource method to ResourceHost interface with documentation#1818
pelikhan merged 11 commits intodevfrom
copilot/fix-66ab302c-0453-432c-b543-c232c106e6bb

Conversation

Copy link
Copy Markdown

Copilot AI commented Aug 2, 2025

This PR adds the resolveResource method to the ResourceHost interface and provides comprehensive documentation and examples.

Changes Made

Enhanced ResourceHost Interface

  • Added resolveResource method to the ResourceHost interface that resolves URLs to downloadable resources
  • Updated the PromptHost implementation to provide the functionality through the underlying tryResolveResource function

Documentation and Examples

  • Added comprehensive documentation for host.resolveResource in the fetch.md reference guide
  • Created a complete sample script (resolve-resource.genai.mts) demonstrating practical usage with GitHub URLs
  • Updated llmstxt documentation to include resolveResource information

Usage

The public API provides a simple interface for resolving resources:

const result = await host.resolveResource(url);

The function resolves various URL schemes and protocols, including automatic transformation of GitHub blob URLs to raw content URLs, making it easy to access remote resources in GenAIScript prompts.

Sample Script

The included sample demonstrates resolving the GitHub favicon image and shows how to handle both binary and text content from resolved resources.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…host classes

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Export the tryResolveResource functionality through the host interface object. Export tryResolveResource functionality through the host interface Aug 2, 2025
Copilot AI requested a review from pelikhan August 2, 2025 13:53
Comment thread packages/core/src/promptcontext.ts Outdated
Comment thread packages/core/src/types.ts Outdated
Comment thread packages/core/src/host.ts Outdated
Comment thread packages/runtime/src/nodehost.ts Outdated
Comment thread packages/vscode/src/vshost.ts Outdated
Copy link
Copy Markdown
Member

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the changes to host/nodehost/vshost
rename tryResolveResource to resovleResource in prompt context

@pelikhan
Copy link
Copy Markdown
Member

pelikhan commented Aug 2, 2025

@copilot apply comments

…esource in ResourceHost

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Aug 2, 2025

@copilot apply comments

All comments have been applied in commit db8638a

Copy link
Copy Markdown
Author

Copilot AI commented Aug 2, 2025

remove the changes to host/nodehost/vshost
rename tryResolveResource to resovleResource in prompt context

Applied all requested changes in commit db8638a:

  • Removed from host/nodehost/vshost/testhost
  • Renamed to resolveResource in prompt context and ResourceHost interface

Copilot AI changed the title Export tryResolveResource functionality through the host interface Export resolveResource functionality through the ResourceHost interface for prompt contexts Aug 2, 2025
Copilot AI requested a review from pelikhan August 2, 2025 15:07
@pelikhan pelikhan marked this pull request as ready for review August 2, 2025 16:38
Comment thread packages/core/src/promptcontext.ts Outdated
Comment thread packages/core/src/types.ts Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Aug 2, 2025

Investigator report

Context collection

  • run id: 16695643908
  • failed job
  • last successful run not found

AI Analysis

AI-generated content by gai may be incorrect. Use reactions to eval.

@pelikhan
Copy link
Copy Markdown
Member

pelikhan commented Aug 2, 2025

@copilot - add sample script (under samples/sample/genaisrc) that uses host.resolveResource to resolve the URL (like https://github.com/microsoft/genaiscript/blob/main/docs/public/images/favicon.png)

  • update documentation on resources

…ation

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Aug 2, 2025

@copilot - add sample script (under samples/sample/genaisrc) that uses host.resolveResource to resolve the URL (like https://github.com/microsoft/genaiscript/blob/main/docs/public/images/favicon.png...

Added sample script resolve-resource.genai.mts demonstrating host.resolveResource usage with GitHub favicon URL and updated documentation in fetch.md with comprehensive examples in commit b81ae7e

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.sheetjs.com
    • Triggering command: node /home/REDACTED/.local/share/pnpm/.tools/pnpm/10.12.3/bin/pnpm install (dns block)
  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)
  • https://api.github.com/markdown
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/branches
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/contents/README.md
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/contents/packages%2Fcore%2Fsrc
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/git/blobs
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/git/ref/heads%2Ftest-ignore
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/issues
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/labels
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/languages
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/pulls
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/pulls/999999
    • Triggering command: node (vitest 3) (http block)
  • microsoft.github.io
    • Triggering command: node (vitest 2) (dns block)
    • Triggering command: node (vitest 3) (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Export resolveResource functionality through the ResourceHost interface for prompt contexts Add options parameter to resolveResource method and documentation Aug 2, 2025
Copilot AI requested a review from pelikhan August 2, 2025 17:05
@pelikhan
Copy link
Copy Markdown
Member

pelikhan commented Aug 2, 2025

@copilot remove CancellationToken from the public interface

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Aug 2, 2025

@copilot remove CancellationToken from the public interface

Removed CancellationToken from the public ResourceHost interface. The resolveResource method now only takes a URL parameter, while internal trace functionality is preserved. Updated documentation to remove cancellation options section. Changes in commit a74d592.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.sheetjs.com
    • Triggering command: node /home/REDACTED/.local/share/pnpm/.tools/pnpm/10.12.3/bin/pnpm install (dns block)
  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Add options parameter to resolveResource method and documentation Add resolveResource method to ResourceHost interface with documentation Aug 2, 2025
Comment thread packages/core/src/types.ts Outdated
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import type { CancellationOptions } from "./cancellation.js";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot remove this import

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unused CancellationOptions import from types.ts in commit e2c4cbd

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Aug 2, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.sheetjs.com
    • Triggering command: node /home/REDACTED/.local/share/pnpm/.tools/pnpm/10.12.3/bin/pnpm install (dns block)
  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)
  • https://api.github.com/markdown
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/branches
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/contents/README.md
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/contents/packages%2Fcore%2Fsrc
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/git/blobs
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/git/ref/heads%2Ftest-ignore
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/issues
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/labels
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/languages
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/pulls
    • Triggering command: node (vitest 3) (http block)
  • https://api.github.com/repos/microsoft/genaiscript/pulls/999999
    • Triggering command: node (vitest 3) (http block)
  • microsoft.github.io
    • Triggering command: node (vitest 2) (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from pelikhan August 2, 2025 18:41
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Aug 2, 2025

Warning

LLM error (403): error

AI-generated content by docs may be incorrect.

@pelikhan pelikhan merged commit 09ae642 into dev Aug 2, 2025
1 check passed
@pelikhan pelikhan deleted the copilot/fix-66ab302c-0453-432c-b543-c232c106e6bb branch August 4, 2025 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants