add-gchat · diff

git:20260616.59460e9 to git:20260623.8f2f788

42 added, 65 removed. Audit A to A.

---
name: add-gchat
description: Add Google Chat channel integration via Chat SDK.
---
# Add Google Chat Channel
- Adds Google Chat support via the Chat SDK bridge. NanoClaw doesn't ship channels
- in trunk — this skill copies the Google Chat adapter in from the `channels`
- branch.
+ Adds Google Chat support via the Chat SDK bridge.
- The mechanical steps under **Apply** carry `nc:` directive fences: an agent
- reads the prose and applies them, and a parser can apply them deterministically
- from the same document. Every directive is idempotent, so the whole skill is
- safe to re-run; anything a parser can't apply falls back to the prose beside it.
+ ## Install
- ## Apply
+ NanoClaw doesn't ship channels in trunk. This skill copies the Google Chat adapter in from the `channels` branch.
- ### 1. Copy the adapter and its registration test
+ ### Pre-flight (idempotent)
- Fetch the `channels` branch and copy the Google Chat adapter and its
- registration test into `src/channels/` (overwrite — the branch is canonical):
+ Skip to **Credentials** if all of these are already in place:
- ```nc:copy from-branch:channels
- src/channels/gchat.ts
- src/channels/gchat-registration.test.ts
- ```
+ - `src/channels/gchat.ts` exists
+ - `src/channels/gchat-registration.test.ts` exists
+ - `src/channels/index.ts` contains `import './gchat.js';`
+ - `@chat-adapter/gchat` is listed in `package.json` dependencies
- ### 2. Register the adapter
+ Otherwise continue. Every step below is safe to re-run.
- Append the self-registration import to the channel barrel (skipped if the line
- is already present). This one line is the skill's only reach-in into core:
+ ### 1. Fetch the channels branch
- ```nc:append to:src/channels/index.ts
- import './gchat.js';
+ ```bash
+ git fetch origin channels
```
- ### 3. Install the adapter package
+ ### 2. Copy the adapter and its registration test
- Pinned to an exact version — the supply-chain policy rejects ranges and `latest`:
+ ```bash
+ git show origin/channels:src/channels/gchat.ts > src/channels/gchat.ts
+ git show origin/channels:src/channels/gchat-registration.test.ts > src/channels/gchat-registration.test.ts
+ ```
- ```nc:dep
- @chat-adapter/gchat@4.26.0
+ ### 3. Append the self-registration import
+
+ Append to `src/channels/index.ts` (skip if the line is already present):
+
+ ```typescript
+ import './gchat.js';
```
- ### 4. Build and validate
+ ### 4. Install the adapter package (pinned)
- Build first: it guards the typed `createChatSdkBridge(...)` core call and proves
- the dependency is installed. Then run the one integration test.
+ ```bash
+ pnpm install @chat-adapter/gchat@4.29.0
+ ```
- ```nc:run effect:build
+ ### 5. Build and validate
+
+ ```bash
pnpm run build
- ```
- ```nc:run effect:test
pnpm exec vitest run src/channels/gchat-registration.test.ts
```
- `gchat-registration.test.ts` imports the real channel barrel and asserts the
- registry contains `gchat`. It goes red if the import line is deleted or drifts,
- if the barrel fails to evaluate, or if `@chat-adapter/gchat` isn't installed (the
- import throws) — so it also covers the dependency from step 3. End-to-end
- delivery against a real Google Chat space is verified manually once the service
- runs — see Credentials and Next Steps.
+ Both must be clean before proceeding. `gchat-registration.test.ts` is the one integration test: it imports the real channel barrel and asserts the registry contains `gchat`. It goes red if the `import './gchat.js';` line is deleted or drifts, if the barrel fails to evaluate, or if `@chat-adapter/gchat` isn't installed (the import throws) — so it also implicitly verifies the dependency from step 4. The adapter also calls core's `createChatSdkBridge(...)`; that typed core-API consumption is guarded by `pnpm run build`.
- ## Credentials
+ End-to-end message delivery against a real Google Chat space is verified manually once the service is running — see Next Steps and the webhook setup above.
- Google Cloud setup is human and interactive — these steps are prose, not
- directives (no parser can click through the Google Cloud Console). A recipe
- rebuild produces a compiling, registered adapter that cannot receive a message
- until they're done.
+ ## Credentials
> 1. Go to [Google Cloud Console](https://console.cloud.google.com)
> 2. Create or select a project
> 3. Enable the **Google Chat API**
> 4. Go to **Google Chat API** > **Configuration**:
> - App name and description
> - Connection settings: select **HTTP endpoint URL** and set to `https://your-domain/webhook/gchat`
> 5. Create a **Service Account**:
> - Go to **IAM & Admin** > **Service Accounts** > **Create Service Account**
> - Grant the Chat Bot role
> - Create a JSON key and download it
- ### Store the credentials
+ ### Configure environment
- Capture the service account JSON, then write it. `prompt` only *asks* and binds
- the answer to a name; a separate directive consumes it — so the same prompt
- could feed `ncl` or the OneCLI vault instead of `.env` by swapping only the
- consumer. Here it goes to `.env` (set-if-absent — a value you've already filled
- in is never overwritten) as a single-line string, then syncs to the container:
+ Add the service account JSON as a single-line string to `.env`:
- ```nc:prompt gchat_credentials secret
- Paste the service account JSON as a single line — the key file you downloaded, e.g. `{"type":"service_account","project_id":"...","private_key":"...","client_email":"..."}`.
- ```
- ```nc:env-set
- GCHAT_CREDENTIALS={{gchat_credentials}}
- ```
- ```nc:env-sync
+ ```bash
+ GCHAT_CREDENTIALS={"type":"service_account","project_id":"...","private_key":"...","client_email":"..."}
```
- ### Webhook server
-
- The Chat SDK bridge automatically starts a shared webhook server on port 3000
- (`WEBHOOK_PORT` to change it), handling `/webhook/gchat`. This port must be
- publicly reachable for Google Chat to deliver events — it's the HTTP endpoint
- URL you set in the Connection settings above. Running locally, expose it with
- ngrok (`ngrok http 3000`), a Cloudflare Tunnel, or a reverse proxy on a VPS.
+ Sync to container: `mkdir -p data/env && cp .env data/env/env`
## Next Steps
- If you're in the middle of `/setup`, return to the setup flow now. Otherwise run
- `/manage-channels` to wire this channel to an agent group.
+ If you're in the middle of `/setup`, return to the setup flow now.
+ Otherwise, run `/manage-channels` to wire this channel to an agent group.
+
## Channel Info
- **type**: `gchat`
- **terminology**: Google Chat has "spaces." A space can be a group conversation or a direct message with the bot.
- **how-to-find-id**: Open the space in Google Chat, look at the URL — the space ID is the segment after `/space/` (e.g. `spaces/AAAA...`). Or use the Google Chat API to list spaces.
- **supports-threads**: yes
- **typical-use**: Interactive chat — team spaces or direct messages
- **default-isolation**: Same agent group for spaces where you're the primary user. Separate agent group for spaces with different teams or sensitive contexts.
- </content>
- </invoke>