@liqngliz/browser-coding-agent 0.1.2 → 0.1.3

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/README.md CHANGED
@@ -1,133 +1,47 @@
1
- # Browser-Coding-Agent
1
+ # Browser Coding Agent
2
2
 
3
- A .NET 10 Minimal API server exposing an OpenAI-compatible chat completions interface backed by Microsoft 365 Copilot web chat via Playwright for .NET.
3
+ OpenAI-compatible chat completions server backed by Microsoft 365 Copilot web chat, for coding agents such as Cline.
4
4
 
5
- The server opens a visible, standalone Microsoft Edge or Google Chrome window. Sign in manually and select your desired model and chat session in that window. Automation enters the prompt, clicks Send once, observes generation, and extracts the completed assistant response.
5
+ ## Run
6
6
 
7
- See [PLAN.md](PLAN.md) and [PACKAGING.md](PACKAGING.md) for architectural and packaging designs.
8
-
9
- ## Requirements
10
-
11
- - .NET 10 SDK
12
- - Google Chrome or Microsoft Edge installed on the host OS
13
- - npm package only: Node 20 or newer (Playwright's driver runs on it)
14
-
15
- ## Build and test
16
-
17
- Build the solution:
18
-
19
- ```sh
20
- dotnet build
21
- ```
22
-
23
- Run automated unit and simulated browser tests, excluding live M365 validation (also use this command in CI):
24
-
25
- ```sh
26
- dotnet test --filter "Category!=ManualLiveValidation"
27
- ```
28
-
29
- The live test has one toggle in [M365IntegrationTests.cs](tests/BrowserCodingAgent.Tests/M365IntegrationTests.cs):
30
-
31
- ```csharp
32
- private const bool SkipLocal = false;
33
- ```
7
+ | Package | Command | Needs |
8
+ | --- | --- | --- |
9
+ | npm | `npx -y @liqngliz/browser-coding-agent` | Node 20+, Chrome or Edge |
10
+ | .NET tool, no install | `dnx BrowserCodingAgent` | .NET 10 SDK, Chrome or Edge |
11
+ | .NET tool, installed | `dotnet tool install -g BrowserCodingAgent`, then `browser-coding-agent` | .NET 10 SDK, Chrome or Edge |
34
12
 
35
- Set `SkipLocal = true` to skip it, or `false` to run it. It defaults to `false` and opens a visible browser with a persistent profile to send a prompt and await the response.
13
+ Specific version: `npx -y @liqngliz/browser-coding-agent@0.1.2`, `dnx BrowserCodingAgent@0.1.2`.
36
14
 
37
- Run the live test:
15
+ First start opens a browser window: sign in to Copilot there. The sign-in is kept for later runs.
38
16
 
39
- ```sh
40
- dotnet test --filter "FullyQualifiedName~M365IntegrationTests"
41
- ```
17
+ ## Options
42
18
 
43
- Create .NET tool package:
19
+ Arguments after the command go to the server:
44
20
 
45
21
  ```sh
46
- dotnet pack src/BrowserCodingAgent.Api -c Release -o artifacts/nuget
22
+ npx -y @liqngliz/browser-coding-agent --urls http://localhost:5029 --Browser:Channel=msedge
23
+ dnx BrowserCodingAgent --urls http://localhost:5029 --Browser:Channel=msedge
47
24
  ```
48
25
 
49
- Create and smoke-test the npm package (headless Chrome against a fake chat page):
50
-
51
- ```sh
52
- node scripts/package-npm.mjs --version 0.0.0-local.1
53
- node scripts/smoke.mjs --npm artifacts/npm/liqngliz-browser-coding-agent-0.0.0-local.1.tgz
54
- ```
55
-
56
- ## CI and release
57
-
58
- | Workflow | Trigger | Does |
26
+ | Option | Default | Meaning |
59
27
  | --- | --- | --- |
60
- | `ci.yml` | PR, push to `main` | `build.yml` with version `0.0.0-ci.<run>` |
61
- | `build.yml` | called | tests (ubuntu/windows/macos), packs `.nupkg` + `.tgz` once, smoke-tests both on windows, macOS arm64, macOS x64, plus npm bootstrap in a container without .NET |
62
- | `release.yml` | tag `v<semver>` | `build.yml`, then publishes the tested artifacts to nuget.org and npm (`latest`, or `next` for prerelease tags) |
63
- | `post-release-smoke.yml` | after `release`, or manual | waits for nuget.org to serve the version, installs the tool from nuget.org, smoke-tests it with installed Edge on windows, macOS arm64, macOS x64 |
64
-
65
- Release: `git tag v0.1.0 && git push origin v0.1.0`. Run without installing: `dnx BrowserCodingAgent` (or `dnx BrowserCodingAgent@0.1.0`). Publish jobs use the `release` environment and OIDC trusted publishing; no API keys are stored.
66
-
67
- ## Running locally
68
-
69
- Run the API server:
70
-
71
- ```sh
72
- dotnet run --project src/BrowserCodingAgent.Api
73
- ```
74
-
75
- The server listens on `http://localhost:5000` (or configured loopback port) and launches the configured browser window.
76
-
77
- ## Configuration
28
+ | `--urls` | `http://localhost:5000` | listen address |
29
+ | `--Browser:Channel` | `chrome` | `chrome` or `msedge` |
30
+ | `--Browser:UserDataDirectory` | `~/.browser-coding-agent/profiles/<channel>` | browser profile (keeps the sign-in) |
31
+ | `--Chat:ResponseTimeoutMinutes` | `10` | wait per answer |
32
+ | `--Chat:MaxPromptChars` | `0` | split longer prompts into parts; `7000` for accounts with an 8000-character composer |
33
+ | `--Chat:SendEnableSeconds` | `30` | wait for Send after filling; focus + Enter at 10s |
34
+ | `--Chat:ReplacementsFile` | `~/.browser-coding-agent/replacements.json`, then bundled | prompt/reply replacement rules |
78
35
 
79
- Default `appsettings.json`:
36
+ ## Client setup (Cline)
80
37
 
81
- ```json
82
- {
83
- "Browser": {
84
- "Channel": "chrome",
85
- "StartUrl": "https://m365.cloud.microsoft/chat"
86
- },
87
- "Chat": {
88
- "ModelAlias": "m365-active",
89
- "ResponseTimeoutMinutes": 10
90
- }
91
- }
92
- ```
93
-
94
- ### Prompt replacements
95
-
96
- `replacements.json` rewrites prompts before they reach Copilot and maps reversible rules back in replies. Default rules target Cline's system prompt (`You are Cline, an AI coding agent.`, `<user_input mode="...">`, `<mode_notice>`, `<env>`), whose persona and wrapper tags trip Copilot's guardrails.
97
-
98
- | Field | Meaning |
38
+ | Field | Value |
99
39
  | --- | --- |
100
- | `find` / `replace` | text, or .NET regex when `regex: true` (`$1` = group) |
101
- | `wholeWord` | default `true`; `Cline` does not match inside `decline` |
102
- | `reverse` | map `replace` back to `find` in replies (plain text only) |
103
-
104
- Lookup order: `Chat:ReplacementsFile` -> `~/.browser-coding-agent/replacements.json` -> bundled default (`src/BrowserCodingAgent.Api/replacements.json`). Restart to reload. Startup fails on invalid JSON or regex.
105
-
106
- Persistent profiles default to `~/.browser-coding-agent/profiles/<channel>` outside package caches, keeping manual sign-in between restarts. Override with `Browser:UserDataDirectory` if desired.
107
-
108
- ## Endpoints
109
-
110
- | Endpoint | Method | Description |
111
- | --- | --- | --- |
112
- | `/v1/chat/completions` | `POST` | Submit single user message; returns completed assistant turn |
113
- | `/v1/models` | `GET` | Returns list containing configured alias (`m365-active`) |
114
- | `/health/live` | `GET` | Reports if server process is running |
115
- | `/health/ready` | `GET` | Reports if browser, tab, and composer are idle and ready (503 when busy or recovery needed) |
116
- | `/swagger` | `GET` | Swagger UI, with Cline and OpenCode setup values for this server's URL and model |
117
- | `/openapi/v1.json` | `GET` | OpenAPI 3.1 document |
40
+ | API Provider | OpenAI Compatible |
41
+ | Base URL | `http://localhost:5000/v1` (or your `--urls`) |
42
+ | API Key | any value, e.g. `local` |
43
+ | Model ID | `m365-active` |
118
44
 
119
- ## Supported API subset and limitations
45
+ Setup details for the running server: `http://localhost:5000/swagger`.
120
46
 
121
- - **Model:** Must match configured `Chat:ModelAlias` (`m365-active`).
122
- - **Messages:** roles `system`, `developer`, `user`, `assistant`, `tool`. Roll-forward mapping onto the M365 tab:
123
- - no `assistant` message yet (first turn) -> new M365 chat, prompt = system text + user message, joined by blank lines
124
- - otherwise -> only the messages after the last `assistant` message (`user` and `tool` content, joined by blank lines)
125
- - no role tags added: Copilot's guardrails refuse prompts wrapped in `<system>` ("it looks like I can't chat about this"); client content is sent unchanged
126
- - client-side rewinds are not mirrored; revert files with git
127
- - **Content:** String content or array of `{"type": "text", "text": "..."}` parts.
128
- - **Streaming:** `stream: true` -> SSE `chat.completion.chunk` deltas, `data: [DONE]`, `: keep-alive` every 15s; `stream_options.include_usage` -> zero-valued usage chunk (M365 exposes no token counts). Errors after Send arrive as an in-stream `{"error": ...}` event.
129
- - **Parameters:** `n: 1` only; `response_format` -> HTTP 400; legacy `functions`, `temperature`, and other generation settings are ignored (logged).
130
- - **Tool calling (emulated):** `tools` are described in the prompt as plain text; fenced call blocks in Copilot's reply come back as `tool_calls` with `finish_reason: "tool_calls"` (streamed as one `tool_calls` delta). `tool_choice`: `none` disables tools, `required` or a named function adds a must-call line. `tool` result messages are sent as `Result of <tool name>:`. Copilot web chat has no native function calling, so calls depend on Copilot following the format.
131
- - **Long prompts:** some M365 accounts cap the composer at 8000 characters. When the composer keeps only a prefix, or Send stays disabled on a prompt over 8000 characters, nothing is sent and the prompt is resent in parts in the same chat ("Part k of n … reply only with: received k/n"; the last part asks for the answer). Set `--Chat:MaxPromptChars=7000` on such accounts to split up front; default `0` splits only after a refusal. Each extra part uses one Copilot message.
132
- - **Concurrency:** Single-request gate. Overlapping requests receive HTTP 409 Conflict.
133
- - **Turn recovery:** Uncertain submissions or timeouts require manual recovery before accepting new prompts.
47
+ Source, limitations, configuration: https://github.com/liqngliz/Browser-Coding-Agent
@@ -6,7 +6,7 @@
6
6
  "compilationOptions": {},
7
7
  "targets": {
8
8
  ".NETCoreApp,Version=v10.0": {
9
- "BrowserCodingAgent.Api/0.1.2": {
9
+ "BrowserCodingAgent.Api/0.1.3": {
10
10
  "dependencies": {
11
11
  "Microsoft.AspNetCore.OpenApi": "10.0.13",
12
12
  "Microsoft.Playwright": "1.63.0",
@@ -65,7 +65,7 @@
65
65
  }
66
66
  },
67
67
  "libraries": {
68
- "BrowserCodingAgent.Api/0.1.2": {
68
+ "BrowserCodingAgent.Api/0.1.3": {
69
69
  "type": "project",
70
70
  "serviceable": false,
71
71
  "sha512": ""
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liqngliz/browser-coding-agent",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "OpenAI-compatible chat completions server backed by Microsoft 365 Copilot web chat via Playwright.",
5
5
  "bin": {
6
6
  "browser-coding-agent": "browser-coding-agent.cjs"