Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ INTELLIGENCE_GATEWAY_WS_URL=wss://realtime.intelligence.copilotkit.ai
# npx --yes copilotkit@latest project select # writes the cpk-... key to .env as CPK_INTELLIGENCE_API_KEY
# bun scripts/setup-learning.ts # copies it here, as INTELLIGENCE_API_KEY
#
# The server reads only INTELLIGENCE_API_KEY, so a key left as CPK_INTELLIGENCE_API_KEY is not seen.
# The server reads INTELLIGENCE_API_KEY first and falls back to CPK_INTELLIGENCE_API_KEY, so the CLI-written key works as written.
#
# The runtime key is also under "API Keys" in your project at https://intelligence.copilotkit.ai
INTELLIGENCE_API_KEY=
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ not a production installation. Run its
`npx copilotkit@latest local connect` from the OpenBot root, where `.env` is.

That command writes `INTELLIGENCE_API_URL`, `INTELLIGENCE_GATEWAY_WS_URL` and
`CPK_INTELLIGENCE_API_KEY` to `.env`. OpenBot reads the first two as they are, but takes its project
key only from `INTELLIGENCE_API_KEY` and refuses to start without it, so copy the `cpk-...` value
across before `bash scripts/start.sh`:
`CPK_INTELLIGENCE_API_KEY` to `.env`. OpenBot reads the first two as they are and falls back to
`CPK_INTELLIGENCE_API_KEY` for its project key, so `bash scripts/start.sh` works as written. Set
`INTELLIGENCE_API_KEY` only when it should differ from the CLI-written key:

```sh
INTELLIGENCE_API_KEY=cpk-... # the value of CPK_INTELLIGENCE_API_KEY
INTELLIGENCE_API_KEY=cpk-... # overrides CPK_INTELLIGENCE_API_KEY
```

To give the Bots a Learning container on that stack, see
Expand Down
6 changes: 3 additions & 3 deletions prompt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ OpenBot root where `.env` is:
npx copilotkit@latest local connect --approve-connection

`local connect` writes INTELLIGENCE_API_URL, INTELLIGENCE_GATEWAY_WS_URL and
CPK_INTELLIGENCE_API_KEY to `.env`. OpenBot reads the first two as they are but takes its project
key only from INTELLIGENCE_API_KEY, so copy the `cpk-...` value of CPK_INTELLIGENCE_API_KEY into
INTELLIGENCE_API_KEY before `bash scripts/start.sh`. The local licence lasts 30 days;
CPK_INTELLIGENCE_API_KEY to `.env`. OpenBot reads the first two as they are and falls back to
CPK_INTELLIGENCE_API_KEY for its project key, so `bash scripts/start.sh` works as written; set
INTELLIGENCE_API_KEY only when it should differ from the CLI-written key. The local licence lasts 30 days;
`npx copilotkit@latest local renew` renews it as often as needed while the account is in good
standing. Skip the managed `project select` and setup-learning commands on this path.

Expand Down
6 changes: 5 additions & 1 deletion server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,11 @@ function runtimeCapabilities(environment: Environment): RuntimeCapabilities {
const settings = {
apiUrl: url(environment, "INTELLIGENCE_API_URL"),
gatewayWsUrl: url(environment, "INTELLIGENCE_GATEWAY_WS_URL"),
apiKey: optional(environment, "INTELLIGENCE_API_KEY"),
// The CopilotKit CLI writes the runtime key as CPK_INTELLIGENCE_API_KEY; setup-learning.ts
// copies it across, but a deployment that ran only the CLI would otherwise refuse to boot.
apiKey:
optional(environment, "INTELLIGENCE_API_KEY") ??
optional(environment, "CPK_INTELLIGENCE_API_KEY"),
Comment on lines +955 to +956

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Synchronize the CLI-key setup guidance

When users follow the checked-in setup guidance, .env.example:134 still says that the server cannot see CPK_INTELLIGENCE_API_KEY, while prompt.txt:106-108 still requires copying that value to INTELLIGENCE_API_KEY before startup. This fallback makes both instructions false, so the documented CLI/local-connect workflow continues to require the manual step that this change is intended to remove; update those guidance surfaces alongside the new alias.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Update the remaining local-connect README guidance

When users follow the README's local Intelligence flow, README.md:140-146 still says OpenBot reads the key only from INTELLIGENCE_API_KEY and requires copying the CLI value before scripts/start.sh. The fallback on this line makes that statement false, so the primary setup page still teaches the manual copy this change removes; update that section along with the other guidance.

Useful? React with 👍 / 👎.

licenseToken: optional(environment, "COPILOTKIT_LICENSE_TOKEN"),
};

Expand Down
21 changes: 21 additions & 0 deletions server/tests/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,27 @@ describe("deployment configuration", () => {
);
});

test("reads the CLI-written CPK_INTELLIGENCE_API_KEY when INTELLIGENCE_API_KEY is unset", () => {
const environment: Record<string, string | undefined> = {
...baseEnvironment,
};
delete environment.INTELLIGENCE_API_KEY;
environment.CPK_INTELLIGENCE_API_KEY = "cpk-cli-written";

const config = loadConfig(environment);

expect(config.runtime.intelligence.apiKey).toBe("cpk-cli-written");
});

test("prefers INTELLIGENCE_API_KEY over CPK_INTELLIGENCE_API_KEY when both are set", () => {
const config = loadConfig({
...baseEnvironment,
CPK_INTELLIGENCE_API_KEY: "cpk-cli-written",
});

expect(config.runtime.intelligence.apiKey).toBe("tenant-api-key");
});

test("starts without COPILOTKIT_LICENSE_TOKEN, because managed Intelligence no longer issues one", () => {
const environment: Record<string, string | undefined> = {
...baseEnvironment,
Expand Down