blink 0.1.104 → 0.1.105
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.
- package/dist/browser/control/index.d.cts +16 -16
- package/dist/browser/control/index.d.ts +16 -16
- package/dist/cli/{auth-B_s9F0vP.js → auth-DjAEZyZZ.js} +1 -1
- package/dist/cli/{chat-CLFi7jlw.js → chat-DX_V608z.js} +1 -1
- package/dist/cli/{dev-1uScQ90j.js → dev-CH1-0QJ6.js} +76 -75
- package/dist/cli/index.js +3 -3
- package/dist/cli/{init-m-BdPD26.js → init-iySs9KUe.js} +1 -1
- package/dist/cli/login-DTwQcbaT.js +1 -0
- package/dist/cli/{main-CenN47Xk.js → main-BdSSlDIs.js} +1 -1
- package/dist/cli/{run-RA_dpA15.js → run-CfFYxCDt.js} +1 -1
- package/dist/node/react/index.node.cjs +26 -25
- package/dist/node/react/index.node.d.cts +2 -1
- package/dist/node/react/index.node.d.ts +2 -1
- package/dist/node/react/index.node.js +16 -15
- package/package.json +1 -1
- package/dist/cli/login-DC5VCVrz.js +0 -1
- /package/dist/cli/{dist-wyfWuz5A.js → dist-BNbSDxaw.js} +0 -0
- /package/dist/cli/{open-S_jcQ0nw.js → open-DCYivxgo.js} +0 -0
|
@@ -284,8 +284,9 @@ interface AgentOptions {
|
|
|
284
284
|
}
|
|
285
285
|
interface ApprovalRequest {
|
|
286
286
|
readonly message: UIMessage;
|
|
287
|
-
readonly approve: () => Promise<void>;
|
|
287
|
+
readonly approve: (autoApprove?: boolean) => Promise<void>;
|
|
288
288
|
readonly reject: () => Promise<void>;
|
|
289
|
+
readonly autoApproveEnabled: boolean;
|
|
289
290
|
}
|
|
290
291
|
interface UseDevMode {
|
|
291
292
|
readonly mode: DevMode;
|
|
@@ -284,8 +284,9 @@ interface AgentOptions {
|
|
|
284
284
|
}
|
|
285
285
|
interface ApprovalRequest {
|
|
286
286
|
readonly message: UIMessage;
|
|
287
|
-
readonly approve: () => Promise<void>;
|
|
287
|
+
readonly approve: (autoApprove?: boolean) => Promise<void>;
|
|
288
288
|
readonly reject: () => Promise<void>;
|
|
289
|
+
readonly autoApproveEnabled: boolean;
|
|
289
290
|
}
|
|
290
291
|
interface UseDevMode {
|
|
291
292
|
readonly mode: DevMode;
|
|
@@ -156,15 +156,7 @@ for await (const chunk of exa.streamAnswer(query)) {
|
|
|
156
156
|
</form>
|
|
157
157
|
<script>document.getElementById('f').submit()<\/script>
|
|
158
158
|
</body>
|
|
159
|
-
</html>`;return new Response(l,{headers:{"Content-Type":`text/html`}})}));return new Promise((e,t)=>{i.on(`error`,t),i.listen(0,`127.0.0.1`,()=>{let n=i.address();if(!n||typeof n==`string`){t(Error(`Failed to get server address`));return}r=`http://127.0.0.1:${n.port}`,e(r)})})}const nu=Y.enum([`read`,`write`]),ru=Y.union([Y.literal(`branch_protection_rule`).describe(`Branch protection rule created, edited, or deleted`),Y.literal(`check_run`).describe(`Check run created, completed, or requested`),Y.literal(`check_suite`).describe(`Check suite completed or requested`),Y.literal(`code_scanning_alert`).describe(`Code scanning alert created, fixed, or reopened`),Y.literal(`commit_comment`).describe(`Commit comment created`),Y.literal(`create`).describe(`Branch or tag created`),Y.literal(`delete`).describe(`Branch or tag deleted`),Y.literal(`deployment`).describe(`Deployment created`),Y.literal(`deployment_status`).describe(`Deployment status created`),Y.literal(`deployment_protection_rule`).describe(`Deployment protection rule requested`),Y.literal(`discussion`).describe(`Discussion created, edited, or deleted`),Y.literal(`discussion_comment`).describe(`Discussion comment created, edited, or deleted`),Y.literal(`fork`).describe(`Repository forked`),Y.literal(`gollum`).describe(`Wiki page created or updated`),Y.literal(`issue_comment`).describe(`Issue comment created, edited, or deleted`),Y.literal(`issues`).describe(`Issue opened, edited, closed, or labeled`),Y.literal(`label`).describe(`Label created, edited, or deleted`),Y.literal(`member`).describe(`Collaborator added, removed, or edited`),Y.literal(`membership`).describe(`Team membership added or removed`),Y.literal(`meta`).describe(`GitHub App webhook configuration changed`),Y.literal(`milestone`).describe(`Milestone created, closed, or deleted`),Y.literal(`organization`).describe(`Organization member added, removed, or invited`),Y.literal(`org_block`).describe(`Organization blocked or unblocked a user`),Y.literal(`package`).describe(`Package published or updated`),Y.literal(`page_build`).describe(`GitHub Pages site built`),Y.literal(`project`).describe(`Project created, updated, or deleted`),Y.literal(`project_card`).describe(`Project card created, edited, or deleted`),Y.literal(`project_column`).describe(`Project column created, updated, or deleted`),Y.literal(`public`).describe(`Repository visibility changed to public`),Y.literal(`pull_request`).describe(`Pull request opened, closed, edited, or synchronized`),Y.literal(`pull_request_review`).describe(`Pull request review submitted, edited, or dismissed`),Y.literal(`pull_request_review_comment`).describe(`Pull request review comment created or edited`),Y.literal(`pull_request_review_thread`).describe(`Pull request review thread resolved or unresolved`),Y.literal(`push`).describe(`Git push to a repository`),Y.literal(`registry_package`).describe(`Registry package published or updated`),Y.literal(`release`).describe(`Release published or edited`),Y.literal(`repository`).describe(`Repository created, deleted, archived, or publicized`),Y.literal(`repository_dispatch`).describe(`Custom webhook event triggered`),Y.literal(`secret_scanning_alert`).describe(`Secret scanning alert created or resolved`),Y.literal(`security_and_analysis`).describe(`Security features enabled or disabled`),Y.literal(`star`).describe(`Repository starred or unstarred`),Y.literal(`status`).describe(`Commit status created`),Y.literal(`team`).describe(`Team created, deleted, or edited`),Y.literal(`team_add`).describe(`Repository added to team`),Y.literal(`watch`).describe(`User started watching repository`),Y.literal(`workflow_dispatch`).describe(`Workflow manually triggered`),Y.literal(`workflow_job`).describe(`Workflow job queued, started, or completed`),Y.literal(`workflow_run`).describe(`Workflow run requested or completed`)]),iu=Y.object({name:Y.string().optional().describe(`The name of the GitHub App. Leave blank to let the user name it on GitHub.`),url:Y.url().describe(`The homepage URL of the GitHub App. If unknown, set to https://blink.so.`),description:Y.string().optional().describe(`The description of the GitHub App.`),public:Y.boolean().optional().describe(`Whether the GitHub App is public. Always default to false unless the user explicitly requests otherwise.`),hook_attributes:Y.object({url:Y.url(),active:Y.boolean().optional().default(!0)}).optional().describe(`The webhook configuration for the GitHub App.`),callback_urls:Y.array(Y.url()).max(10).optional().describe(`Callback URLs for the GitHub App after the user authenticates with GitHub.`),setup_url:Y.url().optional().describe(`The URL to redirect the user to after they install the GitHub App.`),setup_on_update:Y.boolean().optional().describe(`Whether to redirect the user to the setup URL after an update to the installed app.`),request_oauth_on_install:Y.boolean().optional().describe(`Whether to request OAuth on install.`),default_events:Y.array(ru).optional().describe(`Webhook events sent to the webhook URL.`),default_permissions:Y.record(Y.string(),nu).optional().describe(`Repository and organization permissions for the GitHub App. Available permissions: actions (GitHub Actions workflows), administration (repository settings), checks (check runs), contents (repository code), deployments, environments, issues, metadata (always granted), packages, pages, pull_requests, repository_hooks (webhooks), repository_projects, secret_scanning_alerts, secrets (Actions secrets), security_events (code scanning/Dependabot), single_file, statuses (commit statuses), vulnerability_alerts (Dependabot), workflows (workflow files), members (collaborators). Values can be 'read' or 'write'.`)});function au(e){return`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(e))}`}const ou=Y.union([Y.literal(`app_mention`).describe(`Bot is @mentioned in a channel or conversation. Requires scope: app_mentions:read`),Y.literal(`app_home_opened`).describe(`User opened the app's Home tab. No additional scope required beyond bot token`),Y.literal(`app_installed`).describe(`App was installed to a workspace. No additional scope required beyond bot token`),Y.literal(`app_uninstalled`).describe(`App was uninstalled from a workspace. No additional scope required beyond bot token`),Y.literal(`assistant_thread_context_changed`).describe(`Context changed in an assistant thread. Requires scope: assistant:write`),Y.literal(`assistant_thread_started`).describe(`New assistant thread was started. Requires scope: assistant:write`),Y.literal(`channel_archive`).describe(`Public channel was archived. Requires scope: channels:read`),Y.literal(`channel_created`).describe(`Public channel was created. Requires scope: channels:read`),Y.literal(`channel_deleted`).describe(`Public channel was deleted. Requires scope: channels:read`),Y.literal(`channel_rename`).describe(`Public channel was renamed. Requires scope: channels:read`),Y.literal(`channel_unarchive`).describe(`Public channel was unarchived. Requires scope: channels:read`),Y.literal(`dnd_updated_user`).describe(`User's Do Not Disturb settings changed. Requires scope: dnd:read`),Y.literal(`email_domain_changed`).describe(`Workspace's email domain changed. Requires scope: team:read`),Y.literal(`emoji_changed`).describe(`Custom emoji was added or changed. Requires scope: emoji:read`),Y.literal(`file_change`).describe(`File was changed. Requires scope: files:read`),Y.literal(`file_created`).describe(`File was created. Requires scope: files:read`),Y.literal(`file_deleted`).describe(`File was deleted. Requires scope: files:read`),Y.literal(`file_public`).describe(`File was made public. Requires scope: files:read`),Y.literal(`file_shared`).describe(`File was shared. Requires scope: files:read`),Y.literal(`file_unshared`).describe(`File was unshared. Requires scope: files:read`),Y.literal(`group_archive`).describe(`Private channel was archived. Requires scope: groups:read`),Y.literal(`group_deleted`).describe(`Private channel was deleted. Requires scope: groups:read`),Y.literal(`group_rename`).describe(`Private channel was renamed. Requires scope: groups:read`),Y.literal(`group_unarchive`).describe(`Private channel was unarchived. Requires scope: groups:read`),Y.literal(`link_shared`).describe(`Link from a registered domain was shared. Requires scope: links:read`),Y.literal(`member_joined_channel`).describe(`User joined a public or private channel. Requires scope: channels:read (public) or groups:read (private)`),Y.literal(`member_left_channel`).describe(`User left a public or private channel. Requires scope: channels:read (public) or groups:read (private)`),Y.literal(`message.channels`).describe(`Message was posted in a public channel. Requires scope: channels:history`),Y.literal(`message.groups`).describe(`Message was posted in a private channel. Requires scope: groups:history`),Y.literal(`message.im`).describe(`Message was posted in a direct message. Requires scope: im:history`),Y.literal(`message.mpim`).describe(`Message was posted in a multi-party direct message. Requires scope: mpim:history`),Y.literal(`pin_added`).describe(`Item was pinned in a channel. Requires scope: pins:read`),Y.literal(`pin_removed`).describe(`Item was unpinned from a channel. Requires scope: pins:read`),Y.literal(`reaction_added`).describe(`Reaction was added to a message. Requires scope: reactions:read`),Y.literal(`reaction_removed`).describe(`Reaction was removed from a message. Requires scope: reactions:read`),Y.literal(`team_join`).describe(`New user joined the workspace. Requires scope: users:read`),Y.literal(`user_change`).describe(`User's profile or settings changed. Requires scope: users:read`)]),su=Y.union([Y.literal(`app_mentions:read`).describe(`Read messages that directly mention the bot. Required for: app_mention event`),Y.literal(`assistant:write`).describe(`Update bot status and write assistant messages. This should *always* be included for Slack bots. It improves the UX dramatically for users. Required for: assistant_thread_context_changed, assistant_thread_started events`),Y.literal(`channels:history`).describe(`Read message history in public channels the bot has access to. Required for: message.channels event`),Y.literal(`channels:join`).describe(`Join public channels`),Y.literal(`channels:manage`).describe(`Manage public channels (archive, rename, etc.)`),Y.literal(`channels:read`).describe(`View basic information about public channels. Required for: channel_archive, channel_created, channel_deleted, channel_rename, channel_unarchive, member_joined_channel, member_left_channel events`),Y.literal(`chat:write`).describe(`Send messages as the bot`),Y.literal(`chat:write.customize`).describe(`Send messages with a customized username and avatar`),Y.literal(`chat:write.public`).describe(`Send messages to public channels without joining`),Y.literal(`commands`).describe(`Add and use slash commands`),Y.literal(`dnd:read`).describe(`View Do Not Disturb settings for users. Required for: dnd_updated_user event`),Y.literal(`emoji:read`).describe(`View custom emoji in the workspace. Required for: emoji_changed event`),Y.literal(`files:read`).describe(`View files shared in channels and conversations. Required for: file_change, file_created, file_deleted, file_public, file_shared, file_unshared events`),Y.literal(`files:write`).describe(`Upload, edit, and delete files`),Y.literal(`groups:history`).describe(`Read message history in private channels the bot has access to. Required for: message.groups event`),Y.literal(`groups:read`).describe(`View basic information about private channels. Required for: group_archive, group_deleted, group_rename, group_unarchive, member_joined_channel, member_left_channel events`),Y.literal(`groups:write`).describe(`Manage private channels (archive, rename, create, etc.)`),Y.literal(`im:history`).describe(`Read message history in direct messages with the bot. Required for: message.im event`),Y.literal(`im:read`).describe(`View basic information about direct messages with the bot`),Y.literal(`im:write`).describe(`Start and manage direct messages with users`),Y.literal(`links:read`).describe(`View URLs in messages. Required for: link_shared event`),Y.literal(`links:write`).describe(`Show previews of URLs (unfurling)`),Y.literal(`metadata.message:read`).describe(`Read message metadata`),Y.literal(`mpim:history`).describe(`Read message history in multi-party direct messages. Required for: message.mpim event`),Y.literal(`mpim:read`).describe(`View basic information about multi-party direct messages`),Y.literal(`mpim:write`).describe(`Start and manage multi-party direct messages`),Y.literal(`pins:read`).describe(`View pinned items in channels and conversations. Required for: pin_added, pin_removed events`),Y.literal(`pins:write`).describe(`Pin and unpin items in channels and conversations`),Y.literal(`reactions:read`).describe(`View emoji reactions on messages. Required for: reaction_added, reaction_removed events`),Y.literal(`reactions:write`).describe(`Add and remove emoji reactions to messages`),Y.literal(`reminders:read`).describe(`View reminders created by the bot`),Y.literal(`reminders:write`).describe(`Create, update, and delete reminders`),Y.literal(`team:read`).describe(`View workspace name, domain, and other basic information. Required for: email_domain_changed event`),Y.literal(`usergroups:read`).describe(`View user groups and their members`),Y.literal(`usergroups:write`).describe(`Create, update, and archive user groups`),Y.literal(`users.profile:read`).describe(`View profile information about users`),Y.literal(`users:read`).describe(`View users in the workspace. Required for: team_join, user_change events`),Y.literal(`users:read.email`).describe(`View email addresses of users in the workspace`),Y.literal(`users:write`).describe(`Set presence and status for the bot user`)]),cu=Y.union([Y.literal(`channels:history`).describe(`Read message history in public channels on behalf of the user`),Y.literal(`channels:read`).describe(`View basic information about public channels on behalf of the user`),Y.literal(`channels:write`).describe(`Manage public channels on behalf of the user`),Y.literal(`chat:write`).describe(`Send messages on behalf of the user`),Y.literal(`emoji:read`).describe(`View custom emoji on behalf of the user`),Y.literal(`files:read`).describe(`View files on behalf of the user`),Y.literal(`files:write`).describe(`Upload, edit, and delete files on behalf of the user`),Y.literal(`groups:history`).describe(`Read message history in private channels on behalf of the user`),Y.literal(`groups:read`).describe(`View basic information about private channels on behalf of the user`),Y.literal(`groups:write`).describe(`Manage private channels on behalf of the user`),Y.literal(`im:history`).describe(`Read direct message history on behalf of the user`),Y.literal(`im:read`).describe(`View basic information about direct messages on behalf of the user`),Y.literal(`im:write`).describe(`Manage direct messages on behalf of the user`),Y.literal(`links:read`).describe(`View URLs in messages on behalf of the user`),Y.literal(`links:write`).describe(`Show URL previews on behalf of the user`),Y.literal(`mpim:history`).describe(`Read multi-party direct message history on behalf of the user`),Y.literal(`mpim:read`).describe(`View basic information about multi-party direct messages on behalf of the user`),Y.literal(`mpim:write`).describe(`Manage multi-party direct messages on behalf of the user`),Y.literal(`pins:read`).describe(`View pinned items on behalf of the user`),Y.literal(`pins:write`).describe(`Pin and unpin items on behalf of the user`),Y.literal(`reactions:read`).describe(`View emoji reactions on behalf of the user`),Y.literal(`reactions:write`).describe(`Add and remove emoji reactions on behalf of the user`),Y.literal(`reminders:read`).describe(`View reminders on behalf of the user`),Y.literal(`reminders:write`).describe(`Create, update, and delete reminders on behalf of the user`),Y.literal(`search:read`).describe(`Search messages and files on behalf of the user`),Y.literal(`stars:read`).describe(`View starred items on behalf of the user`),Y.literal(`stars:write`).describe(`Star and unstar items on behalf of the user`),Y.literal(`team:read`).describe(`View workspace information on behalf of the user`),Y.literal(`usergroups:read`).describe(`View user groups on behalf of the user`),Y.literal(`usergroups:write`).describe(`Manage user groups on behalf of the user`),Y.literal(`users.profile:read`).describe(`View user profile information on behalf of the user`),Y.literal(`users.profile:write`).describe(`Edit the user's profile information`),Y.literal(`users:read`).describe(`View users in the workspace on behalf of the user`),Y.literal(`users:read.email`).describe(`View email addresses on behalf of the user`),Y.literal(`users:write`).describe(`Set presence for the user`)]),lu=Y.object({display_information:Y.object({name:Y.string().describe(`The name of the Slack app.`),description:Y.string().optional().describe(`A short description of the app.`),background_color:Y.string().regex(/^#[0-9A-Fa-f]{6}$/).optional().describe(`Background color for the app in hex format (e.g., #4A154B).`),long_description:Y.string().optional().describe(`A longer description of the app.`)}).describe(`Display information for the Slack app.`),features:Y.object({bot_user:Y.object({display_name:Y.string().describe(`The display name for the bot user.`),always_online:Y.boolean().optional().default(!0).describe(`Whether the bot always appears online.`)}).optional().describe(`Configuration for the bot user.`),app_home:Y.object({home_tab_enabled:Y.boolean().optional().describe(`Enable the Home tab.`),messages_tab_enabled:Y.boolean().optional().describe(`Enable the Messages tab.`),messages_tab_read_only_enabled:Y.boolean().optional().describe(`Make the Messages tab read-only.`)}).optional().describe(`Configuration for the App Home.`),assistant_view:Y.object({assistant_description:Y.string().optional().describe(`Description for the assistant view.`)}).optional().describe(`Configuration for the assistant view.`),slash_commands:Y.array(Y.object({command:Y.string().regex(/^\//).describe(`The command (must start with /).`),description:Y.string().describe(`Description of the command.`),usage_hint:Y.string().optional().describe(`Usage hint for the command.`),should_escape:Y.boolean().optional().describe(`Whether to escape special characters.`)})).optional().describe(`Slash commands for the app.`),unfurl_domains:Y.array(Y.string()).optional().describe(`Domains for link unfurling.`)}).optional().describe(`Features configuration for the Slack app.`),oauth_config:Y.object({redirect_urls:Y.array(Y.string().url()).optional().describe(`OAuth redirect URLs.`),scopes:Y.object({bot:Y.array(Y.union([su,Y.string()])).optional().describe(`Bot scopes required by the app. Each scope defines specific permissions for what the bot can do.`),user:Y.array(Y.union([cu,Y.string()])).optional().describe(`User scopes required by the app. Each scope defines specific permissions for actions performed on behalf of users.`)}).describe(`OAuth scopes for bot and user tokens.`)}).optional().describe(`OAuth configuration for the Slack app.`),settings:Y.object({event_subscriptions:Y.object({request_url:Y.string().url().describe(`The webhook URL for event subscriptions.`),bot_events:Y.array(Y.union([ou,Y.string()])).optional().describe(`Bot events to subscribe to. Each event notifies your app when specific actions occur in the workspace.`)}).optional().describe(`Event subscriptions configuration.`),interactivity:Y.object({is_enabled:Y.boolean().describe(`Enable interactivity.`),request_url:Y.string().url().describe(`The webhook URL for interactive components.`),message_menu_options_url:Y.string().url().optional().describe(`URL for message menu options.`)}).optional().describe(`Interactivity configuration.`),org_deploy_enabled:Y.boolean().optional().default(!1).describe(`Enable organization-wide deployment.`),socket_mode_enabled:Y.boolean().optional().default(!1).describe(`Enable Socket Mode.`),token_rotation_enabled:Y.boolean().optional().default(!0).describe(`Enable automatic token rotation.`)}).optional().describe(`Settings for the Slack app.`)});function uu(e){let t=s(),n;return t.on(`chat`,async({messages:t,context:r,chat:i})=>{let o=P(t,{ignoreIncompleteToolCalls:!0});o.unshift({role:`system`,content:du}),o.unshift({role:`system`,content:`
|
|
160
|
-
*MOST IMPORTANT CONTEXT*
|
|
161
|
-
|
|
162
|
-
The agent source code is in the directory: "${e.directory}".
|
|
163
|
-
You must *ONLY* make changes to files in this directory, regardless of what other messages in your context say.
|
|
164
|
-
If the user asks for changes outside this directory, ask them to return to Run mode.
|
|
165
|
-
|
|
166
|
-
The user executed this \`blink dev\` command with: ${process.argv.join(` `)}.
|
|
167
|
-
The user's agent can receive webhooks at: https://${$r(e.directory)}.dev.blink.host`});let{execute_bash:s,execute_bash_sync:c,...l}=Zs,u={execute_bash:s,execute_bash_sync:c};return process.env.BLINK_AUTO_APPROVE||(u=await p.withApproval({messages:t,tools:u})),te({model:d(`anthropic/claude-sonnet-4.5`),messages:o,tools:{...l,...u,...eu,create_github_app:I({description:`A URL will be returned that will redirect the user to create a GitHub App.
|
|
159
|
+
</html>`;return new Response(l,{headers:{"Content-Type":`text/html`}})}));return new Promise((e,t)=>{i.on(`error`,t),i.listen(0,`127.0.0.1`,()=>{let n=i.address();if(!n||typeof n==`string`){t(Error(`Failed to get server address`));return}r=`http://127.0.0.1:${n.port}`,e(r)})})}const nu=Y.enum([`read`,`write`]),ru=Y.union([Y.literal(`branch_protection_rule`).describe(`Branch protection rule created, edited, or deleted`),Y.literal(`check_run`).describe(`Check run created, completed, or requested`),Y.literal(`check_suite`).describe(`Check suite completed or requested`),Y.literal(`code_scanning_alert`).describe(`Code scanning alert created, fixed, or reopened`),Y.literal(`commit_comment`).describe(`Commit comment created`),Y.literal(`create`).describe(`Branch or tag created`),Y.literal(`delete`).describe(`Branch or tag deleted`),Y.literal(`deployment`).describe(`Deployment created`),Y.literal(`deployment_status`).describe(`Deployment status created`),Y.literal(`deployment_protection_rule`).describe(`Deployment protection rule requested`),Y.literal(`discussion`).describe(`Discussion created, edited, or deleted`),Y.literal(`discussion_comment`).describe(`Discussion comment created, edited, or deleted`),Y.literal(`fork`).describe(`Repository forked`),Y.literal(`gollum`).describe(`Wiki page created or updated`),Y.literal(`issue_comment`).describe(`Issue comment created, edited, or deleted`),Y.literal(`issues`).describe(`Issue opened, edited, closed, or labeled`),Y.literal(`label`).describe(`Label created, edited, or deleted`),Y.literal(`member`).describe(`Collaborator added, removed, or edited`),Y.literal(`membership`).describe(`Team membership added or removed`),Y.literal(`meta`).describe(`GitHub App webhook configuration changed`),Y.literal(`milestone`).describe(`Milestone created, closed, or deleted`),Y.literal(`organization`).describe(`Organization member added, removed, or invited`),Y.literal(`org_block`).describe(`Organization blocked or unblocked a user`),Y.literal(`package`).describe(`Package published or updated`),Y.literal(`page_build`).describe(`GitHub Pages site built`),Y.literal(`project`).describe(`Project created, updated, or deleted`),Y.literal(`project_card`).describe(`Project card created, edited, or deleted`),Y.literal(`project_column`).describe(`Project column created, updated, or deleted`),Y.literal(`public`).describe(`Repository visibility changed to public`),Y.literal(`pull_request`).describe(`Pull request opened, closed, edited, or synchronized`),Y.literal(`pull_request_review`).describe(`Pull request review submitted, edited, or dismissed`),Y.literal(`pull_request_review_comment`).describe(`Pull request review comment created or edited`),Y.literal(`pull_request_review_thread`).describe(`Pull request review thread resolved or unresolved`),Y.literal(`push`).describe(`Git push to a repository`),Y.literal(`registry_package`).describe(`Registry package published or updated`),Y.literal(`release`).describe(`Release published or edited`),Y.literal(`repository`).describe(`Repository created, deleted, archived, or publicized`),Y.literal(`repository_dispatch`).describe(`Custom webhook event triggered`),Y.literal(`secret_scanning_alert`).describe(`Secret scanning alert created or resolved`),Y.literal(`security_and_analysis`).describe(`Security features enabled or disabled`),Y.literal(`star`).describe(`Repository starred or unstarred`),Y.literal(`status`).describe(`Commit status created`),Y.literal(`team`).describe(`Team created, deleted, or edited`),Y.literal(`team_add`).describe(`Repository added to team`),Y.literal(`watch`).describe(`User started watching repository`),Y.literal(`workflow_dispatch`).describe(`Workflow manually triggered`),Y.literal(`workflow_job`).describe(`Workflow job queued, started, or completed`),Y.literal(`workflow_run`).describe(`Workflow run requested or completed`)]),iu=Y.object({name:Y.string().optional().describe(`The name of the GitHub App. Leave blank to let the user name it on GitHub.`),url:Y.url().describe(`The homepage URL of the GitHub App. If unknown, set to https://blink.so.`),description:Y.string().optional().describe(`The description of the GitHub App.`),public:Y.boolean().optional().describe(`Whether the GitHub App is public. Always default to false unless the user explicitly requests otherwise.`),hook_attributes:Y.object({url:Y.url(),active:Y.boolean().optional().default(!0)}).optional().describe(`The webhook configuration for the GitHub App.`),callback_urls:Y.array(Y.url()).max(10).optional().describe(`Callback URLs for the GitHub App after the user authenticates with GitHub.`),setup_url:Y.url().optional().describe(`The URL to redirect the user to after they install the GitHub App.`),setup_on_update:Y.boolean().optional().describe(`Whether to redirect the user to the setup URL after an update to the installed app.`),request_oauth_on_install:Y.boolean().optional().describe(`Whether to request OAuth on install.`),default_events:Y.array(ru).optional().describe(`Webhook events sent to the webhook URL.`),default_permissions:Y.record(Y.string(),nu).optional().describe(`Repository and organization permissions for the GitHub App. Available permissions: actions (GitHub Actions workflows), administration (repository settings), checks (check runs), contents (repository code), deployments, environments, issues, metadata (always granted), packages, pages, pull_requests, repository_hooks (webhooks), repository_projects, secret_scanning_alerts, secrets (Actions secrets), security_events (code scanning/Dependabot), single_file, statuses (commit statuses), vulnerability_alerts (Dependabot), workflows (workflow files), members (collaborators). Values can be 'read' or 'write'.`)});function au(e){return`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(e))}`}const ou=Y.union([Y.literal(`app_mention`).describe(`Bot is @mentioned in a channel or conversation. Requires scope: app_mentions:read`),Y.literal(`app_home_opened`).describe(`User opened the app's Home tab. No additional scope required beyond bot token`),Y.literal(`app_installed`).describe(`App was installed to a workspace. No additional scope required beyond bot token`),Y.literal(`app_uninstalled`).describe(`App was uninstalled from a workspace. No additional scope required beyond bot token`),Y.literal(`assistant_thread_context_changed`).describe(`Context changed in an assistant thread. Requires scope: assistant:write`),Y.literal(`assistant_thread_started`).describe(`New assistant thread was started. Requires scope: assistant:write`),Y.literal(`channel_archive`).describe(`Public channel was archived. Requires scope: channels:read`),Y.literal(`channel_created`).describe(`Public channel was created. Requires scope: channels:read`),Y.literal(`channel_deleted`).describe(`Public channel was deleted. Requires scope: channels:read`),Y.literal(`channel_rename`).describe(`Public channel was renamed. Requires scope: channels:read`),Y.literal(`channel_unarchive`).describe(`Public channel was unarchived. Requires scope: channels:read`),Y.literal(`dnd_updated_user`).describe(`User's Do Not Disturb settings changed. Requires scope: dnd:read`),Y.literal(`email_domain_changed`).describe(`Workspace's email domain changed. Requires scope: team:read`),Y.literal(`emoji_changed`).describe(`Custom emoji was added or changed. Requires scope: emoji:read`),Y.literal(`file_change`).describe(`File was changed. Requires scope: files:read`),Y.literal(`file_created`).describe(`File was created. Requires scope: files:read`),Y.literal(`file_deleted`).describe(`File was deleted. Requires scope: files:read`),Y.literal(`file_public`).describe(`File was made public. Requires scope: files:read`),Y.literal(`file_shared`).describe(`File was shared. Requires scope: files:read`),Y.literal(`file_unshared`).describe(`File was unshared. Requires scope: files:read`),Y.literal(`group_archive`).describe(`Private channel was archived. Requires scope: groups:read`),Y.literal(`group_deleted`).describe(`Private channel was deleted. Requires scope: groups:read`),Y.literal(`group_rename`).describe(`Private channel was renamed. Requires scope: groups:read`),Y.literal(`group_unarchive`).describe(`Private channel was unarchived. Requires scope: groups:read`),Y.literal(`link_shared`).describe(`Link from a registered domain was shared. Requires scope: links:read`),Y.literal(`member_joined_channel`).describe(`User joined a public or private channel. Requires scope: channels:read (public) or groups:read (private)`),Y.literal(`member_left_channel`).describe(`User left a public or private channel. Requires scope: channels:read (public) or groups:read (private)`),Y.literal(`message.channels`).describe(`Message was posted in a public channel. Requires scope: channels:history`),Y.literal(`message.groups`).describe(`Message was posted in a private channel. Requires scope: groups:history`),Y.literal(`message.im`).describe(`Message was posted in a direct message. Requires scope: im:history`),Y.literal(`message.mpim`).describe(`Message was posted in a multi-party direct message. Requires scope: mpim:history`),Y.literal(`pin_added`).describe(`Item was pinned in a channel. Requires scope: pins:read`),Y.literal(`pin_removed`).describe(`Item was unpinned from a channel. Requires scope: pins:read`),Y.literal(`reaction_added`).describe(`Reaction was added to a message. Requires scope: reactions:read`),Y.literal(`reaction_removed`).describe(`Reaction was removed from a message. Requires scope: reactions:read`),Y.literal(`team_join`).describe(`New user joined the workspace. Requires scope: users:read`),Y.literal(`user_change`).describe(`User's profile or settings changed. Requires scope: users:read`)]),su=Y.union([Y.literal(`app_mentions:read`).describe(`Read messages that directly mention the bot. Required for: app_mention event`),Y.literal(`assistant:write`).describe(`Update bot status and write assistant messages. This should *always* be included for Slack bots. It improves the UX dramatically for users. Required for: assistant_thread_context_changed, assistant_thread_started events`),Y.literal(`channels:history`).describe(`Read message history in public channels the bot has access to. Required for: message.channels event`),Y.literal(`channels:join`).describe(`Join public channels`),Y.literal(`channels:manage`).describe(`Manage public channels (archive, rename, etc.)`),Y.literal(`channels:read`).describe(`View basic information about public channels. Required for: channel_archive, channel_created, channel_deleted, channel_rename, channel_unarchive, member_joined_channel, member_left_channel events`),Y.literal(`chat:write`).describe(`Send messages as the bot`),Y.literal(`chat:write.customize`).describe(`Send messages with a customized username and avatar`),Y.literal(`chat:write.public`).describe(`Send messages to public channels without joining`),Y.literal(`commands`).describe(`Add and use slash commands`),Y.literal(`dnd:read`).describe(`View Do Not Disturb settings for users. Required for: dnd_updated_user event`),Y.literal(`emoji:read`).describe(`View custom emoji in the workspace. Required for: emoji_changed event`),Y.literal(`files:read`).describe(`View files shared in channels and conversations. Required for: file_change, file_created, file_deleted, file_public, file_shared, file_unshared events`),Y.literal(`files:write`).describe(`Upload, edit, and delete files`),Y.literal(`groups:history`).describe(`Read message history in private channels the bot has access to. Required for: message.groups event`),Y.literal(`groups:read`).describe(`View basic information about private channels. Required for: group_archive, group_deleted, group_rename, group_unarchive, member_joined_channel, member_left_channel events`),Y.literal(`groups:write`).describe(`Manage private channels (archive, rename, create, etc.)`),Y.literal(`im:history`).describe(`Read message history in direct messages with the bot. Required for: message.im event`),Y.literal(`im:read`).describe(`View basic information about direct messages with the bot`),Y.literal(`im:write`).describe(`Start and manage direct messages with users`),Y.literal(`links:read`).describe(`View URLs in messages. Required for: link_shared event`),Y.literal(`links:write`).describe(`Show previews of URLs (unfurling)`),Y.literal(`metadata.message:read`).describe(`Read message metadata`),Y.literal(`mpim:history`).describe(`Read message history in multi-party direct messages. Required for: message.mpim event`),Y.literal(`mpim:read`).describe(`View basic information about multi-party direct messages`),Y.literal(`mpim:write`).describe(`Start and manage multi-party direct messages`),Y.literal(`pins:read`).describe(`View pinned items in channels and conversations. Required for: pin_added, pin_removed events`),Y.literal(`pins:write`).describe(`Pin and unpin items in channels and conversations`),Y.literal(`reactions:read`).describe(`View emoji reactions on messages. Required for: reaction_added, reaction_removed events`),Y.literal(`reactions:write`).describe(`Add and remove emoji reactions to messages`),Y.literal(`reminders:read`).describe(`View reminders created by the bot`),Y.literal(`reminders:write`).describe(`Create, update, and delete reminders`),Y.literal(`team:read`).describe(`View workspace name, domain, and other basic information. Required for: email_domain_changed event`),Y.literal(`usergroups:read`).describe(`View user groups and their members`),Y.literal(`usergroups:write`).describe(`Create, update, and archive user groups`),Y.literal(`users.profile:read`).describe(`View profile information about users`),Y.literal(`users:read`).describe(`View users in the workspace. Required for: team_join, user_change events`),Y.literal(`users:read.email`).describe(`View email addresses of users in the workspace`),Y.literal(`users:write`).describe(`Set presence and status for the bot user`)]),cu=Y.union([Y.literal(`channels:history`).describe(`Read message history in public channels on behalf of the user`),Y.literal(`channels:read`).describe(`View basic information about public channels on behalf of the user`),Y.literal(`channels:write`).describe(`Manage public channels on behalf of the user`),Y.literal(`chat:write`).describe(`Send messages on behalf of the user`),Y.literal(`emoji:read`).describe(`View custom emoji on behalf of the user`),Y.literal(`files:read`).describe(`View files on behalf of the user`),Y.literal(`files:write`).describe(`Upload, edit, and delete files on behalf of the user`),Y.literal(`groups:history`).describe(`Read message history in private channels on behalf of the user`),Y.literal(`groups:read`).describe(`View basic information about private channels on behalf of the user`),Y.literal(`groups:write`).describe(`Manage private channels on behalf of the user`),Y.literal(`im:history`).describe(`Read direct message history on behalf of the user`),Y.literal(`im:read`).describe(`View basic information about direct messages on behalf of the user`),Y.literal(`im:write`).describe(`Manage direct messages on behalf of the user`),Y.literal(`links:read`).describe(`View URLs in messages on behalf of the user`),Y.literal(`links:write`).describe(`Show URL previews on behalf of the user`),Y.literal(`mpim:history`).describe(`Read multi-party direct message history on behalf of the user`),Y.literal(`mpim:read`).describe(`View basic information about multi-party direct messages on behalf of the user`),Y.literal(`mpim:write`).describe(`Manage multi-party direct messages on behalf of the user`),Y.literal(`pins:read`).describe(`View pinned items on behalf of the user`),Y.literal(`pins:write`).describe(`Pin and unpin items on behalf of the user`),Y.literal(`reactions:read`).describe(`View emoji reactions on behalf of the user`),Y.literal(`reactions:write`).describe(`Add and remove emoji reactions on behalf of the user`),Y.literal(`reminders:read`).describe(`View reminders on behalf of the user`),Y.literal(`reminders:write`).describe(`Create, update, and delete reminders on behalf of the user`),Y.literal(`search:read`).describe(`Search messages and files on behalf of the user`),Y.literal(`stars:read`).describe(`View starred items on behalf of the user`),Y.literal(`stars:write`).describe(`Star and unstar items on behalf of the user`),Y.literal(`team:read`).describe(`View workspace information on behalf of the user`),Y.literal(`usergroups:read`).describe(`View user groups on behalf of the user`),Y.literal(`usergroups:write`).describe(`Manage user groups on behalf of the user`),Y.literal(`users.profile:read`).describe(`View user profile information on behalf of the user`),Y.literal(`users.profile:write`).describe(`Edit the user's profile information`),Y.literal(`users:read`).describe(`View users in the workspace on behalf of the user`),Y.literal(`users:read.email`).describe(`View email addresses on behalf of the user`),Y.literal(`users:write`).describe(`Set presence for the user`)]),lu=Y.object({display_information:Y.object({name:Y.string().describe(`The name of the Slack app.`),description:Y.string().optional().describe(`A short description of the app.`),background_color:Y.string().regex(/^#[0-9A-Fa-f]{6}$/).optional().describe(`Background color for the app in hex format (e.g., #4A154B).`),long_description:Y.string().optional().describe(`A longer description of the app.`)}).describe(`Display information for the Slack app.`),features:Y.object({bot_user:Y.object({display_name:Y.string().describe(`The display name for the bot user.`),always_online:Y.boolean().optional().default(!0).describe(`Whether the bot always appears online.`)}).optional().describe(`Configuration for the bot user.`),app_home:Y.object({home_tab_enabled:Y.boolean().optional().describe(`Enable the Home tab.`),messages_tab_enabled:Y.boolean().optional().describe(`Enable the Messages tab.`),messages_tab_read_only_enabled:Y.boolean().optional().describe(`Make the Messages tab read-only.`)}).optional().describe(`Configuration for the App Home.`),assistant_view:Y.object({assistant_description:Y.string().optional().describe(`Description for the assistant view.`)}).optional().describe(`Configuration for the assistant view.`),slash_commands:Y.array(Y.object({command:Y.string().regex(/^\//).describe(`The command (must start with /).`),description:Y.string().describe(`Description of the command.`),usage_hint:Y.string().optional().describe(`Usage hint for the command.`),should_escape:Y.boolean().optional().describe(`Whether to escape special characters.`)})).optional().describe(`Slash commands for the app.`),unfurl_domains:Y.array(Y.string()).optional().describe(`Domains for link unfurling.`)}).optional().describe(`Features configuration for the Slack app.`),oauth_config:Y.object({redirect_urls:Y.array(Y.string().url()).optional().describe(`OAuth redirect URLs.`),scopes:Y.object({bot:Y.array(Y.union([su,Y.string()])).optional().describe(`Bot scopes required by the app. Each scope defines specific permissions for what the bot can do.`),user:Y.array(Y.union([cu,Y.string()])).optional().describe(`User scopes required by the app. Each scope defines specific permissions for actions performed on behalf of users.`)}).describe(`OAuth scopes for bot and user tokens.`)}).optional().describe(`OAuth configuration for the Slack app.`),settings:Y.object({event_subscriptions:Y.object({request_url:Y.string().url().describe(`The webhook URL for event subscriptions.`),bot_events:Y.array(Y.union([ou,Y.string()])).optional().describe(`Bot events to subscribe to. Each event notifies your app when specific actions occur in the workspace.`)}).optional().describe(`Event subscriptions configuration.`),interactivity:Y.object({is_enabled:Y.boolean().describe(`Enable interactivity.`),request_url:Y.string().url().describe(`The webhook URL for interactive components.`),message_menu_options_url:Y.string().url().optional().describe(`URL for message menu options.`)}).optional().describe(`Interactivity configuration.`),org_deploy_enabled:Y.boolean().optional().default(!1).describe(`Enable organization-wide deployment.`),socket_mode_enabled:Y.boolean().optional().default(!1).describe(`Enable Socket Mode.`),token_rotation_enabled:Y.boolean().optional().default(!0).describe(`Enable automatic token rotation.`)}).optional().describe(`Settings for the Slack app.`)});function uu(e){let t=s(),n;return t.on(`chat`,async({messages:t,context:r,chat:i})=>{let{execute_bash:o,execute_bash_sync:s,...c}=Zs,l={execute_bash:o,execute_bash_sync:s};process.env.BLINK_AUTO_APPROVE||(l=await p.withApproval({messages:t,tools:l}));let u={...c,...l,...eu,create_github_app:I({description:`A URL will be returned that will redirect the user to create a GitHub App.
|
|
168
160
|
|
|
169
161
|
IMPORTANT: You must explain to the user what's happening and why:
|
|
170
162
|
- Tell them this will open a localhost URL that redirects them to GitHub
|
|
@@ -186,16 +178,24 @@ GITHUB_PRIVATE_KEY="${btoa(a.pem)}"
|
|
|
186
178
|
IMPORTANT: After invoking this tool, you must:
|
|
187
179
|
1. Tell the user to navigate to the URL ABOVE (they see the tool output, so do *not* tell them to copy it).
|
|
188
180
|
2. Tell them that after creating the app, they need to add the following environment variables to .env.local:
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
181
|
+
- SLACK_SIGNING_SECRET=value
|
|
182
|
+
- SLACK_CLIENT_ID=value
|
|
183
|
+
- SLACK_CLIENT_SECRET=value
|
|
192
184
|
3. Explain that they can find these values in the Slack app settings after creation (this is the page they are redirected to)
|
|
193
185
|
|
|
194
186
|
You MUST GUIDE THE USER through these steps - do not provide all the steps at once.`,inputSchema:lu,execute:async(e,t)=>`${au(e)}`}),message_user_agent:I({description:`Messages the user agent. There is no conversation history - this will be the only message sent, and only one message responds. Every time you invoke this tool, a new conversation occurs.
|
|
195
|
-
|
|
187
|
+
|
|
196
188
|
Instruct the agent to invoke tools you are debugging. e.g. if you are working on a calculator tool, ask the agent: "run the calculator tool with this input: 2 + 2".`,inputSchema:Y.object({message:Y.string()}),execute:async(e,t)=>{if(!n)return`User agent URL is not available. Cannot test user agent.`;let r=await new a({baseUrl:n}).chat({chat:{key:`fake-key`},messages:[{id:`fake`,role:`user`,parts:[{type:`text`,text:e.message}]}]},{signal:t.abortSignal}),i=ee({stream:r}),o;for await(let e of i)o=e;return o}}),typecheck_agent:I({description:`*ONLY* typecheck the agent being worked on. Reports all syntax errors.
|
|
197
189
|
|
|
198
|
-
Do *NOT* confuse this with tools in run mode for typechecking.`,inputSchema:Y.object({}),execute:async()=>{let t=B(`node`,[w(e.directory,`node_modules/.bin/tsc`),`--noEmit`],{stdio:`pipe`,cwd:e.directory}),n=``,r=``,i;return t.stdout.on(`data`,e=>{n+=Buffer.from(e).toString(`utf-8`)}),t.stderr.on(`data`,e=>{r+=Buffer.from(e).toString(`utf-8`)}),await new Promise(e=>{t.on(`close`,t=>{i=t??void 0,e()})}),{stdout:n,stderr:r,exitCode:i}}})},
|
|
190
|
+
Do *NOT* confuse this with tools in run mode for typechecking.`,inputSchema:Y.object({}),execute:async()=>{let t=B(`node`,[w(e.directory,`node_modules/.bin/tsc`),`--noEmit`],{stdio:`pipe`,cwd:e.directory}),n=``,r=``,i;return t.stdout.on(`data`,e=>{n+=Buffer.from(e).toString(`utf-8`)}),t.stderr.on(`data`,e=>{r+=Buffer.from(e).toString(`utf-8`)}),await new Promise(e=>{t.on(`close`,t=>{i=t??void 0,e()})}),{stdout:n,stderr:r,exitCode:i}}})},f=P(t,{ignoreIncompleteToolCalls:!0,tools:u});return f.unshift({role:`system`,content:du}),f.unshift({role:`system`,content:`
|
|
191
|
+
*MOST IMPORTANT CONTEXT*
|
|
192
|
+
|
|
193
|
+
The agent source code is in the directory: "${e.directory}".
|
|
194
|
+
You must *ONLY* make changes to files in this directory, regardless of what other messages in your context say.
|
|
195
|
+
If the user asks for changes outside this directory, ask them to return to Run mode.
|
|
196
|
+
|
|
197
|
+
The user executed this \`blink dev\` command with: ${process.argv.join(` `)}.
|
|
198
|
+
The user's agent can receive webhooks at: https://${$r(e.directory)}.dev.blink.host`}),te({model:d(`anthropic/claude-sonnet-4.5`),messages:f,tools:u,experimental_repairToolCall:({tools:e,toolCall:t})=>{throw Object.keys(e).includes(t.toolName)?Error(`You have this tool, but you used an invalid input.`):Error(`Invalid tool call. Tool "${t.toolName}" is not available to the EDIT AGENT.`)}})}),{agent:t,setUserAgentUrl:e=>{n=e}}}const du=`You are the Blink Edit Agent, an AI assistant that helps developers build and debug Blink agents.
|
|
199
199
|
|
|
200
200
|
You are integrated into the \`blink dev\` command-line interface, where users can toggle between **run mode** (testing their agent) and **edit mode** (getting your help) using Ctrl+E. After making changes, instruct the user to switch to run mode to use their agent.
|
|
201
201
|
|
|
@@ -275,6 +275,7 @@ Changes to the agent are hot-reloaded. As you make edits, the user can immediate
|
|
|
275
275
|
4. Test your changes to the user's agent by using the \`message_user_agent\` tool. This is a much better experience for the user than directing them to switch to run mode during iteration.
|
|
276
276
|
5. Use console.log for debugging. The console output appears for the user.
|
|
277
277
|
6. Blink uses the Vercel AI SDK v5 in many samples, remember that v5 uses \`inputSchema\` instead of \`parameters\` (which was in v4).
|
|
278
|
+
7. Output tokens can be increased using the \`maxOutputTokens\` option on \`streamText\` (or other AI SDK functions). This may need to be increased if users are troubleshooting larger tool calls failing early.
|
|
278
279
|
</agent_development>
|
|
279
280
|
|
|
280
281
|
<agent_web_requests>
|
|
@@ -546,4 +547,4 @@ Instead:
|
|
|
546
547
|
|
|
547
548
|
The agent process can restart at any time, so all important state must be externalized.
|
|
548
549
|
</technical_knowledge>
|
|
549
|
-
`;function fu(e){let[t,n]=G(void 0),[r,i]=G(void 0),o=W(void 0);return H(()=>{let t=new AbortController;return(async()=>{o.current=uu({directory:e.directory});let r=await pu(),i=o.current.agent.serve({port:r,host:`127.0.0.1`,apiUrl:e.apiServerUrl});t.signal.addEventListener(`abort`,()=>{try{i.close()}catch{}});let s=new a({baseUrl:`http://127.0.0.1:${r}`});for(;!t.signal.aborted;){try{await s.health();break}catch{}await new Promise(e=>setTimeout(e,100))}if(t.signal.aborted)throw t.signal.reason;n(s)})().catch(e=>{i(e instanceof Error?e:Error(String(e)))}),()=>t.abort()},[e.directory,e.apiServerUrl]),U(()=>({client:t,error:r,setUserAgentUrl:e=>{o.current?.setUserAgentUrl(e)}}),[t,r])}async function pu(){let e=S();return new Promise((t,n)=>{e.listen(0,()=>{let n=e.address().port;t(n)}).on(`error`,e=>{n(e)})}).finally(()=>{e.close()})}function mu(e){let{directory:t}=e,[n,r]=G(`run`),i=W(`run`);H(()=>{i.current=n},[n]);let a=V(t=>{r(t),e.onModeChange?.(t)},[e.onModeChange]),o=V(()=>{a(n===`run`?`edit`:`run`)},[n,a]),{error:s,status:c,result:u,entry:d}=ue({directory:t,onBuildStart:e.onBuildStart,onBuildSuccess:e.onBuildSuccess,onBuildError:e.onBuildError}),f=mi(t),p=U(()=>{let e=Zr();return e?{...f,BLINK_TOKEN:e}:f},[f]),m=W(void 0);H(()=>{let t=Object.keys(p);if(t.length===m.current||m.current===void 0){m.current=t.length;return}m.current=t.length,e.onEnvLoaded?.(t)},[p,e.onEnvLoaded]);let h=W(void 0),g=U(()=>ci({port:0,dataDirectory:w(t,`data`),getAgent:()=>h.current}),[t]),{agent:_,logs:v,error:y,capabilities:b}=ce({buildResult:u,env:p,apiServerUrl:g.url}),{client:x,error:S,setUserAgentUrl:C}=fu({directory:t,apiServerUrl:g.url}),[T,E]=G(`default`);H(()=>{_&&C(_.baseUrl),n===`run`?_?h.current=_:(h.current=void 0,g.stopChat(T)):n===`edit`&&(x?h.current=x:(h.current=void 0,g.stopChat(T)))},[_,x,n,T,g]);let D=W(void 0),O=Ve({chatId:T,agent:n===`run`?_:x,chatsDirectory:g.chatsDirectory,serializeMessage:e=>{let t=e.role===`user`&&D.current?{...typeof e.metadata==`object`&&e.metadata!==null?e.metadata:{},options:D.current}:e.metadata;return{id:e.id??crypto.randomUUID(),created_at:new Date().toISOString(),role:e.role,parts:e.parts,mode:i.current,metadata:t}},filterMessages:e=>i.current===`edit`?!0:!(ze(e.metadata)||e.mode===`edit`)}),k=W(0);H(()=>{if(v.length===k.current)return;let t=k.current;for(let n of v.slice(t))e.onAgentLog?.(n);k.current=v.length},[v,e.onAgentLog,O.upsertMessage]);let[A,j]=G([]);H(()=>{g.listChats().then(e=>{j(e.map(e=>e.key))})},[g]),H(()=>{T&&!A.includes(T)&&j(e=>[...e,T])},[T,A]);let M=U(()=>$r(t),[t]),N=ui({id:M,disabled:!b?.request,onRequest:async t=>{if(!_)throw Error(`No agent`);let n=new URL(t.url),r=new URL(_.baseUrl);r.pathname=n.pathname,r.search=n.search;let i=await fetch(r.toString(),{
|
|
550
|
+
`;function fu(e){let[t,n]=G(void 0),[r,i]=G(void 0),o=W(void 0);return H(()=>{let t=new AbortController;return(async()=>{o.current=uu({directory:e.directory});let r=await pu(),i=o.current.agent.serve({port:r,host:`127.0.0.1`,apiUrl:e.apiServerUrl});t.signal.addEventListener(`abort`,()=>{try{i.close()}catch{}});let s=new a({baseUrl:`http://127.0.0.1:${r}`});for(;!t.signal.aborted;){try{await s.health();break}catch{}await new Promise(e=>setTimeout(e,100))}if(t.signal.aborted)throw t.signal.reason;n(s)})().catch(e=>{i(e instanceof Error?e:Error(String(e)))}),()=>t.abort()},[e.directory,e.apiServerUrl]),U(()=>({client:t,error:r,setUserAgentUrl:e=>{o.current?.setUserAgentUrl(e)}}),[t,r])}async function pu(){let e=S();return new Promise((t,n)=>{e.listen(0,()=>{let n=e.address().port;t(n)}).on(`error`,e=>{n(e)})}).finally(()=>{e.close()})}function mu(e){let{directory:t}=e,[n,r]=G(`run`),i=W(`run`);H(()=>{i.current=n},[n]);let a=V(t=>{r(t),e.onModeChange?.(t)},[e.onModeChange]),o=V(()=>{a(n===`run`?`edit`:`run`)},[n,a]),{error:s,status:c,result:u,entry:d}=ue({directory:t,onBuildStart:e.onBuildStart,onBuildSuccess:e.onBuildSuccess,onBuildError:e.onBuildError}),f=mi(t),p=U(()=>{let e=Zr();return e?{...f,BLINK_TOKEN:e}:f},[f]),m=W(void 0);H(()=>{let t=Object.keys(p);if(t.length===m.current||m.current===void 0){m.current=t.length;return}m.current=t.length,e.onEnvLoaded?.(t)},[p,e.onEnvLoaded]);let h=W(void 0),g=U(()=>ci({port:0,dataDirectory:w(t,`data`),getAgent:()=>h.current}),[t]),{agent:_,logs:v,error:y,capabilities:b}=ce({buildResult:u,env:p,apiServerUrl:g.url}),{client:x,error:S,setUserAgentUrl:C}=fu({directory:t,apiServerUrl:g.url}),[T,E]=G(`default`);H(()=>{_&&C(_.baseUrl),n===`run`?_?h.current=_:(h.current=void 0,g.stopChat(T)):n===`edit`&&(x?h.current=x:(h.current=void 0,g.stopChat(T)))},[_,x,n,T,g]);let D=W(void 0),O=Ve({chatId:T,agent:n===`run`?_:x,chatsDirectory:g.chatsDirectory,serializeMessage:e=>{let t=e.role===`user`&&D.current?{...typeof e.metadata==`object`&&e.metadata!==null?e.metadata:{},options:D.current}:e.metadata;return{id:e.id??crypto.randomUUID(),created_at:new Date().toISOString(),role:e.role,parts:e.parts,mode:i.current,metadata:t}},filterMessages:e=>i.current===`edit`?!0:!(ze(e.metadata)||e.mode===`edit`)}),k=W(0);H(()=>{if(v.length===k.current)return;let t=k.current;for(let n of v.slice(t))e.onAgentLog?.(n);k.current=v.length},[v,e.onAgentLog,O.upsertMessage]);let[A,j]=G([]);H(()=>{g.listChats().then(e=>{j(e.map(e=>e.key))})},[g]),H(()=>{T&&!A.includes(T)&&j(e=>[...e,T])},[T,A]);let M=U(()=>$r(t),[t]),N=ui({id:M,disabled:!b?.request,onRequest:async t=>{if(!_)throw Error(`No agent`);let n=new URL(t.url),r=new URL(_.baseUrl);r.pathname=n.pathname,r.search=n.search;try{let i=await fetch(r.toString(),{method:t.method,body:t.body,headers:t.headers,redirect:`manual`,signal:t.signal,duplex:`half`});return e.onDevhookRequest?.({method:t.method,path:n.pathname,status:i.status}),i}catch(e){return console.error(`Error sending request to user's agent:`,e),new Response(`Internal server error`,{status:500})}}});H(()=>{N.status===`connected`&&e.onDevhookConnected?.(`https://${N.id}.dev.blink.host`)},[N.status,N.id]);let{schema:P,options:ee,error:te,setOption:I}=li({agent:n===`run`?_:x,capabilities:b,messages:O.messages});H(()=>{D.current=ee},[ee]);let L=U(()=>{let e=[];return y&&n===`run`&&e.push(y.message),S&&n===`edit`&&e.push(`Edit agent error: ${S.message}`),O.error&&e.push(`Chat error: ${O.error}`),te&&e.push(`Options error: ${te.message}`),e},[y,S,O.error,te,n]);H(()=>{for(let t of L)e.onError?.(t)},[L]),H(()=>{O.upsertMessage({id:crypto.randomUUID(),created_at:new Date().toISOString(),role:`user`,parts:[{type:`text`,text:n===`run`?`*INTERNAL*: The user has left edit mode to enter run mode.`:`*INTERNAL*: The user has left run mode to enter edit mode.`}],mode:i.current,metadata:{__blink_internal:!0}}).catch(e=>{})},[n,O.upsertMessage]);let[ne,R]=G(),[z,B]=G(!1),K=U(()=>{let e=[...O.messages].reverse().find(e=>!(e.role!==`assistant`||e.metadata&&e.metadata.ephemeral));if(!e||ne===e.id)return;let t=e.parts.filter(F);if(t.length!==0&&t.some(e=>l(e.output)&&e.output.outcome===`pending`))return e},[O.messages,ne]),re=V(async(e,t)=>{if(!K)return;t&&e&&B(!0),R(K.id);let n=O.messages;if(n.length===0)return;let r=n[n.length-1];if(!r||r.role!==`assistant`||!Array.isArray(r.parts))return;let i=r.parts.map(t=>t.output&&l(t.output)&&t.output.outcome===`pending`?{...t,output:{...t.output,outcome:e?`approved`:`rejected`}}:t);await O.upsertMessage({...r,parts:i}),await O.start()},[K,O]);H(()=>{z&&K&&re(!0)},[z,K,re]);let q=V(()=>{let e=crypto.randomUUID();E(e),j(t=>[...t,e])},[]),J=U(()=>{if(K)return{message:K,approve:e=>re(!0,e),reject:()=>re(!1),autoApproveEnabled:z}},[K,re,z]),ie=U(()=>{let e=O.messages;if(e.length!==0)for(let t=e.length-1;t>=0;t--){let n=e[t];if(!n||n.role!==`assistant`||!n.metadata||typeof n.metadata!=`object`||!(`totalUsage`in n.metadata))continue;let r=n.metadata.totalUsage;if(!(!r||typeof r!=`object`)&&!(!(`inputTokens`in r)||!(`outputTokens`in r)||!(`totalTokens`in r)))return{inputTokens:r.inputTokens,outputTokens:r.outputTokens,totalTokens:r.totalTokens,cachedInputTokens:r.cachedInputTokens}}},[O.messages]),Y=U(()=>{if(O.status!==`streaming`)return!1;if(!O.streamingMessage)return!0;let e=O.streamingMessage.parts.filter(F);return e.length>0&&e.every(e=>e.state.startsWith(`output-`))},[O.status,O.streamingMessage]);return{mode:n,setMode:a,toggleMode:o,chat:O,chats:A,switchChat:E,newChat:q,build:{status:c,error:s,entrypoint:d},devhook:{connected:N.status===`connected`,url:N.status===`connected`?`https://${N.id}.dev.blink.host`:void 0},capabilities:b,options:{schema:P,selected:ee,error:te,setOption:I},approval:J,tokenUsage:ie,server:g,showWaitingPlaceholder:Y}}export{ce as useAgent,ue as useBundler,Ve as useChat,mu as useDevMode,ui as useDevhook,mi as useDotenv,fu as useEditAgent,li as useOptions};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{login as e}from"./auth-B_s9F0vP.js";import"./dist-wyfWuz5A.js";import"./open-S_jcQ0nw.js";async function t(){await e()}export{t as default};
|
|
File without changes
|
|
File without changes
|