@octelium/cordium-agent 0.0.0-stage → 0.1.0

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.
Files changed (103) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +174 -2
  3. package/apis/cordium.json +1 -0
  4. package/dist/agent/pi/auth.d.ts +32 -0
  5. package/dist/agent/pi/auth.js +279 -0
  6. package/dist/agent/pi/auth.js.map +1 -0
  7. package/dist/agent/pi/backend.d.ts +80 -0
  8. package/dist/agent/pi/backend.js +572 -0
  9. package/dist/agent/pi/backend.js.map +1 -0
  10. package/dist/agent/pi/mapper.d.ts +33 -0
  11. package/dist/agent/pi/mapper.js +443 -0
  12. package/dist/agent/pi/mapper.js.map +1 -0
  13. package/dist/agent/pi/model.d.ts +47 -0
  14. package/dist/agent/pi/model.js +199 -0
  15. package/dist/agent/pi/model.js.map +1 -0
  16. package/dist/agent/prompt.d.ts +20 -0
  17. package/dist/agent/prompt.js +76 -0
  18. package/dist/agent/prompt.js.map +1 -0
  19. package/dist/agent/resources.d.ts +13 -0
  20. package/dist/agent/resources.js +78 -0
  21. package/dist/agent/resources.js.map +1 -0
  22. package/dist/agent/tools/api.d.ts +29 -0
  23. package/dist/agent/tools/api.js +238 -0
  24. package/dist/agent/tools/api.js.map +1 -0
  25. package/dist/agent/tools/builtin.d.ts +14 -0
  26. package/dist/agent/tools/builtin.js +81 -0
  27. package/dist/agent/tools/builtin.js.map +1 -0
  28. package/dist/agent/tools/present.d.ts +61 -0
  29. package/dist/agent/tools/present.js +273 -0
  30. package/dist/agent/tools/present.js.map +1 -0
  31. package/dist/agent/tools/transfer.d.ts +21 -0
  32. package/dist/agent/tools/transfer.js +243 -0
  33. package/dist/agent/tools/transfer.js.map +1 -0
  34. package/dist/agent/tools/util.d.ts +19 -0
  35. package/dist/agent/tools/util.js +103 -0
  36. package/dist/agent/tools/util.js.map +1 -0
  37. package/dist/agent/tools/web.d.ts +24 -0
  38. package/dist/agent/tools/web.js +237 -0
  39. package/dist/agent/tools/web.js.map +1 -0
  40. package/dist/agent/tools/workspaces.d.ts +95 -0
  41. package/dist/agent/tools/workspaces.js +862 -0
  42. package/dist/agent/tools/workspaces.js.map +1 -0
  43. package/dist/agent/types.d.ts +65 -0
  44. package/dist/agent/types.js +2 -0
  45. package/dist/agent/types.js.map +1 -0
  46. package/dist/api/catalog.d.ts +82 -0
  47. package/dist/api/catalog.js +481 -0
  48. package/dist/api/catalog.js.map +1 -0
  49. package/dist/api/client.d.ts +56 -0
  50. package/dist/api/client.js +201 -0
  51. package/dist/api/client.js.map +1 -0
  52. package/dist/api/search.d.ts +24 -0
  53. package/dist/api/search.js +229 -0
  54. package/dist/api/search.js.map +1 -0
  55. package/dist/app.d.ts +36 -0
  56. package/dist/app.js +131 -0
  57. package/dist/app.js.map +1 -0
  58. package/dist/cli.d.ts +2 -0
  59. package/dist/cli.js +263 -0
  60. package/dist/cli.js.map +1 -0
  61. package/dist/config.d.ts +161 -0
  62. package/dist/config.js +265 -0
  63. package/dist/config.js.map +1 -0
  64. package/dist/errors.d.ts +13 -0
  65. package/dist/errors.js +18 -0
  66. package/dist/errors.js.map +1 -0
  67. package/dist/index.d.ts +6 -0
  68. package/dist/index.js +6 -0
  69. package/dist/index.js.map +1 -0
  70. package/dist/log.d.ts +11 -0
  71. package/dist/log.js +41 -0
  72. package/dist/log.js.map +1 -0
  73. package/dist/protocol/index.d.ts +484 -0
  74. package/dist/protocol/index.js +45 -0
  75. package/dist/protocol/index.js.map +1 -0
  76. package/dist/runs/builder.d.ts +17 -0
  77. package/dist/runs/builder.js +81 -0
  78. package/dist/runs/builder.js.map +1 -0
  79. package/dist/runs/manager.d.ts +52 -0
  80. package/dist/runs/manager.js +536 -0
  81. package/dist/runs/manager.js.map +1 -0
  82. package/dist/server/http.d.ts +9 -0
  83. package/dist/server/http.js +100 -0
  84. package/dist/server/http.js.map +1 -0
  85. package/dist/server/server.d.ts +48 -0
  86. package/dist/server/server.js +501 -0
  87. package/dist/server/server.js.map +1 -0
  88. package/dist/skills.d.ts +4 -0
  89. package/dist/skills.js +69 -0
  90. package/dist/skills.js.map +1 -0
  91. package/dist/store/conversations.d.ts +26 -0
  92. package/dist/store/conversations.js +183 -0
  93. package/dist/store/conversations.js.map +1 -0
  94. package/dist/store/files.d.ts +27 -0
  95. package/dist/store/files.js +161 -0
  96. package/dist/store/files.js.map +1 -0
  97. package/dist/store/settings.d.ts +16 -0
  98. package/dist/store/settings.js +59 -0
  99. package/dist/store/settings.js.map +1 -0
  100. package/dist/version.d.ts +1 -0
  101. package/dist/version.js +11 -0
  102. package/dist/version.js.map +1 -0
  103. package/package.json +66 -4
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,175 @@
1
- # Temporary Holding Version
1
+ # @octelium/cordium-agent
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Cordium AI agent behind the chat of the Cordium web portal (`https://cordium.<DOMAIN>/agent`). It runs as an ordinary process inside a Cordium Workspace of the User, uses that Workspace's own Octelium identity and exposes an HTTP/JSON + SSE API that is served as the Workspace's default Application. It manages the User's Workspaces: creating, starting, stopping and deleting them, running commands and test suites inside them, copying files between them, reaching the Octelium Services that the User can access, and everything else exposed by the Cordium API.
4
+
5
+ ```text
6
+ Cordium web portal (chat UI)
7
+ │ HTTP/JSON + SSE (https://<workspace>.cordium.<domain>, authenticated as the Workspace owner)
8
+ ▼
9
+ cordium-agent ───────────────────── the User's agent Workspace (octelium.<user> Space) ─────────
10
+ ├─ Pi (agent loop, sessions, compaction, retries, skills)
11
+ ├─ tools
12
+ │ ├─ workspace_list / workspace_create / workspace_control / workspace_exec /
13
+ │ │ workspace_copy / workspace_logs └─ @octelium/cordium SDK ─┐
14
+ │ ├─ cordium_api_search / cordium_api_describe / cordium_api_call │
15
+ │ │ └─ @octelium/apis + apis/cordium.json (JSON Schemas) ─────────┤
16
+ │ │ gRPC over OCTELIUM_AUTH_PROXY_SOCKET ◄─────────┘──► Cordium, user and core APIs
17
+ │ ├─ present_table / present_chart / present_resources / publish_artifact
18
+ │ ├─ read / bash / edit / write / grep / find / ls (the Workspace is the agent's computer)
19
+ │ └─ web_fetch / web_search
20
+ └─ LLM ──► the User's Claude/ChatGPT subscription, an Octelium LLM Service or any Pi provider
21
+ ```
22
+
23
+ ## Design
24
+
25
+ - **Execution.** The agent is a Node.js process inside the User's agent Workspace. Its own shell commands run in that Workspace, while the commands in the User's other Workspaces run through the Cordium `WorkspaceService.Exec` API (no SSH needed). Both the agent's Workspace and the other Workspaces reach the Octelium Services that the User can access by name through their `octelium connect`.
26
+ - **Identity.** The Cordium, user and core APIs are called through the supervisor's auth proxy socket (`OCTELIUM_AUTH_PROXY_SOCKET`), exactly like the `cordium` and `octelium` CLIs do inside a Workspace. Every call is authorized server-side for the Workspace owner. The model never sees a credential.
27
+ - **APIs.** The typed protobuf messages and service clients come from the [`@octelium/apis`](https://www.npmjs.com/package/@octelium/apis) package and the high-level Workspace operations (lifecycle, exec, file transfers) from [`@octelium/cordium`](https://www.npmjs.com/package/@octelium/cordium). The documentation of the APIs is shipped as one deduplicated bundle of JSON Schemas (`apis/cordium.json`, generated from the `.proto` files with their doc comments) which powers a BM25 search over the methods, the rendering of the request schemas with their field documentation, and the method index of the system prompt (Cordium and user APIs). The model sends proto3 JSON, which is validated with the message types before the call (unknown fields and wrong types are rejected with precise errors).
28
+ - **Tools.** Besides the generic API tools, the agent has dedicated Workspace tools that are optimized for its use cases: `workspace_create` creates, starts and waits for a Workspace while streaming its state, `workspace_control` starts, stops, restarts, deletes or waits for several Workspaces in parallel, `workspace_exec` streams the output of a command (or starts it in the background), `workspace_copy` copies files and directories between Workspaces and the agent's own filesystem through the Exec API, and `workspace_logs` reads the initialization logs. Tool calls of the same model turn run concurrently, so the same operation can run in several Workspaces at once. The agent refuses to stop, restart or delete its own Workspace.
29
+ - **Approvals.** Methods are classified by risk (`read`, `write`, `destructive`, `sensitive`). Depending on the approval mode (`never`, `destructive`, which also covers the sensitive calls such as Secrets, Memberships and shared ports, or `write`), calls pause until the User approves them in the UI, and so do the shell commands if `commands` is set. The User can switch the mode at runtime from the portal (`PATCH /v1/settings`). Approvals are a UX safety net, not the security boundary: authorization is always enforced by the Cluster.
30
+ - **Model.** The Users can sign in with their own Claude (Pro/Max) or ChatGPT subscriptions from the portal. The OAuth flows run inside the agent and the tokens never leave the Workspace. Alternatively the model is served by an Octelium LLM Service (`llm.provider: "octelium"`) reached through `octelium connect`, or by any provider supported by Pi.
31
+ - **Backend abstraction.** The HTTP protocol knows nothing about Pi: runs go through the `AgentBackend` interface (`src/agent/types.ts`).
32
+ - **Persistence.** Conversations, finalized messages, Pi sessions, uploads, artifacts and settings are stored in the data directory. An in-flight message is checkpointed and recovered as `interrupted` if the process dies. Restarting the agent resumes the conversations with their full context.
33
+
34
+ ## Running inside a Cordium Workspace
35
+
36
+ The Cordium `MainService.InitializeAgent` method provisions the agent of the calling User on demand: it creates the User's personal `octelium` Space (`octelium.<user>`, a system Space that hosts the Workspaces of all the Octelium-managed agents of the User), the `cordium-agent.octelium.<user>` Template and a Workspace that serves the agent as its default Application on port `8080`, and references that Workspace in the User's `UserConfig` (`status.agentWorkspaceRef`). Subsequent calls reconcile the Template and recreate the Workspace if it was deleted. The Template installs Node.js upon the first start of a Workspace if the image lacks it (`ON_CREATE`) and starts `npx --yes --prefer-online @octelium/cordium-agent@<version> serve` on every start (`POST_START`). It is generated from the `spec.agent` section of the Cordium ClusterConfig (`cordium man`):
37
+
38
+ | Field | Description |
39
+ | --- | --- |
40
+ | `isDisabled` | Disables `InitializeAgent` |
41
+ | `llm.service`, `llm.model` | The default LLM Service and model (i.e. `llm.service` and `llm.model` below) |
42
+ | `version` | The `@octelium/cordium-agent` npm version or dist-tag. Development builds default to their Git branch (`dev` when unknown) and production builds to their semver (`latest` when unknown) |
43
+ | `image`, `limit` | The Workspace image and compute resources |
44
+ | `config` | Any additional configuration (same structure as `config.json`), passed via `CORDIUM_AGENT_CONFIG_JSON` |
45
+
46
+ The web portal calls `InitializeAgent`, starts the Workspace and talks to the agent at the Workspace's hostname. The agent can also run in any other Workspace whose image has Node.js 22.19+ and `git`:
47
+
48
+ ```yaml
49
+ spec:
50
+ runtime:
51
+ envVars:
52
+ - key: CORDIUM_AGENT_CONFIG_JSON
53
+ value: '{"approvals":{"api":"write"}}'
54
+ tasks:
55
+ - name: cordium-agent
56
+ type: POST_START
57
+ isBackground: true
58
+ run: npx --yes --prefer-online @octelium/cordium-agent@latest serve
59
+ applications:
60
+ - name: agent
61
+ displayName: Cordium Agent
62
+ port: 8080
63
+ isDefault: true
64
+ ```
65
+
66
+ `npx @octelium/cordium-agent doctor` checks the configuration, the Cordium API access and the LLM access.
67
+
68
+ ## Configuration
69
+
70
+ The configuration is read, in increasing precedence, from the defaults, a JSON file (`--config`, `CORDIUM_AGENT_CONFIG` or `<dataDir>/config.json`), the `CORDIUM_AGENT_CONFIG_JSON` environment variable and the CLI flags. Unknown fields are rejected. See `config.example.json`.
71
+
72
+ | Field | Default | Description |
73
+ | --- | --- | --- |
74
+ | `dataDir` | `~/.cordium-agent` | Conversations, sessions, uploads, artifacts, skills, settings |
75
+ | `workDir` | `/workspace` if it exists, else `$HOME` | The agent's working directory |
76
+ | `logLevel` | `info` | `debug`, `info`, `warn`, `error` |
77
+ | `server.host`, `server.port` | `0.0.0.0`, `8080` | Listen address |
78
+ | `server.allowedOrigins` | `https://cordium.<domain>`, the portal of the Workspace's Region, `https://$CORDIUM_HOSTNAME` | Accepted `Origin` headers (plus the request's own origin) |
79
+ | `server.cors` | `false` | Emit CORS headers. Keep it off since the Cordium portal Service already handles CORS for `https://cordium.<domain>` |
80
+ | `server.authToken` | | Optional bearer token (or `?access_token=`) required for `/v1/*` |
81
+ | `server.maxUploadBytes` | 100 MiB | Upload limit |
82
+ | `octelium.mode` | `auto` | `proxy` (auth proxy socket), `direct` (`OCTELIUM_DOMAIN` + `OCTELIUM_ACCESS_TOKEN`, for development), `disabled` |
83
+ | `octelium.domain` | `OCTELIUM_DOMAIN` | Cluster domain |
84
+ | `octelium.timeoutSeconds` | `30` | Per-call deadline |
85
+ | `llm.provider` | `octelium` | `octelium`, `custom` or any Pi provider ID |
86
+ | `llm.service` | | The LLM Service (`name` or `name.namespace`). Its URL is resolved via the user API |
87
+ | `llm.baseUrl` | | Overrides the endpoint (required for `custom`) |
88
+ | `llm.api` | `openai-completions` | Pi API of the endpoint, e.g. `openai-responses`, `anthropic-messages`, `google-generative-ai` |
89
+ | `llm.model` | | Model ID. Discovered from the endpoint's model list if unset (`octelium`/`custom`) |
90
+ | `llm.apiKey`, `llm.apiKeyEnv` | | Provider credentials. Not needed with an Octelium LLM Service |
91
+ | `llm.thinkingLevel` | `medium` | `off` … `max` |
92
+ | `llm.contextWindow`, `llm.maxTokens`, `llm.reasoning`, `llm.input` | from Pi's catalog | Model metadata for unknown model IDs |
93
+ | `llm.loginProviders` | `anthropic`, `openai` | The Pi providers that the Users can sign in to with their own subscriptions (Claude Pro/Max, ChatGPT) |
94
+ | `agent.tools` | all | Pi built-in tools: `read`, `bash`, `edit`, `write`, `grep`, `find`, `ls` (`grep`/`find` are dropped if `rg`/`fd` are missing) |
95
+ | `agent.systemPromptAppend` | | Extra instructions |
96
+ | `agent.loadContextFiles` | `false` | Load `AGENTS.md`-style files from the working directory |
97
+ | `agent.maxConcurrentRuns` | `4` | Across conversations |
98
+ | `agent.sessionIdleTimeoutSeconds` | `1800` | Idle Pi sessions are disposed (and transparently reopened) |
99
+ | `agent.compaction`, `agent.maxRetries` | `true`, `3` | Context compaction and LLM retries |
100
+ | `agent.generateTitles` | `true` | Generate conversation titles with the LLM |
101
+ | `approvals.api` | `destructive` | The default approval mode: `never`, `destructive` (deletions and sensitive calls) or `write` (every call that is not read-only). The User can override it from the portal |
102
+ | `approvals.commands` | `false` | Require an approval for every shell command, in the agent's Workspace or in other Workspaces |
103
+ | `skills.repositories` | `octelium/octelium-skills@main` | Agent Skills repositories (including the `cordium` skill), cloned/updated at startup (best effort) |
104
+ | `skills.paths` | | Local skill directories |
105
+ | `webSearch` | | `{"provider": "brave" \| "tavily" \| "searxng", "baseUrl", "apiKey" \| "apiKeyEnv"}` |
106
+
107
+ ## HTTP API
108
+
109
+ All the types are exported from `@octelium/cordium-agent/protocol` (`src/protocol/index.ts`), which has no runtime dependencies. `make gen-api` copies it to the web portal.
110
+
111
+ | Method | Path | Description |
112
+ | --- | --- | --- |
113
+ | `GET` | `/healthz` | Liveness |
114
+ | `GET` | `/v1/info` | Version, protocol version, model, identity, settings, capabilities, issues |
115
+ | `GET` | `/v1/conversations` | List the conversations |
116
+ | `POST` | `/v1/conversations` | Create a conversation, optionally starting a run: `{"title"?, "input"?: {"text", "attachments"?}}` |
117
+ | `GET` | `/v1/conversations/{id}` | The conversation, its messages and the snapshot of its active run |
118
+ | `PATCH` | `/v1/conversations/{id}` | Rename: `{"title"}` |
119
+ | `DELETE` | `/v1/conversations/{id}` | Cancel its run and delete it |
120
+ | `POST` | `/v1/conversations/{id}/runs` | Start a run: `{"input": {"text", "attachments"?}}` (`409` if a run is active) |
121
+ | `GET` | `/v1/runs/{id}` | Run snapshot (run + in-progress assistant message) |
122
+ | `GET` | `/v1/runs/{id}/events` | SSE stream of the run's events |
123
+ | `POST` | `/v1/runs/{id}/cancel` | Cancel the run |
124
+ | `POST` | `/v1/runs/{id}/approvals/{approvalId}` | `{"decision": "approve" \| "reject", "reason"?}` |
125
+ | `POST` | `/v1/files?name=<file name>` | Upload a file (raw body). Returns a `FileInfo` whose `id` can be attached to a run |
126
+ | `GET` | `/v1/artifacts/{id}` | Artifact metadata |
127
+ | `GET` | `/v1/artifacts/{id}/content` | Download an artifact (`attachment`, sandboxed CSP; `?inline=1` for safe types) |
128
+ | `GET` | `/v1/models` | The current model, the thinking level and the available models |
129
+ | `PUT` | `/v1/model` | Switch the model: `{"provider", "id", "thinkingLevel"?}` |
130
+ | `GET` | `/v1/settings` | The approval settings |
131
+ | `PATCH` | `/v1/settings` | Update them: `{"approvals": {"api"?, "commands"?}}` |
132
+ | `GET` | `/v1/auth/providers` | The subscription providers and whether they are signed in |
133
+ | `DELETE` | `/v1/auth/providers/{id}` | Sign out |
134
+ | `POST` | `/v1/auth/logins` | Start signing in: `{"provider", "selectModel"?}`. Returns a `LoginSession` |
135
+ | `GET` | `/v1/auth/logins/{id}` | Poll a `LoginSession` (`events` such as `auth_url`, the pending `prompt`, `status`) |
136
+ | `POST` | `/v1/auth/logins/{id}/prompts/{promptId}` | Answer the pending prompt: `{"value"}` |
137
+ | `DELETE` | `/v1/auth/logins/{id}` | Cancel signing in |
138
+
139
+ Errors are `{"error": {"code", "message"}}`. `POST`/`PUT`/`PATCH` bodies must be `application/json`.
140
+
141
+ ### Messages, blocks and events
142
+
143
+ A run appends one user message and one assistant message to the conversation. A message is an ordered list of typed blocks: `markdown`, `thinking`, `tool` (with structured `details`: `api` calls with the method, risk, request, response and the referenced resources, `command` with the Workspace, exit code and duration, `file` with diffs, `workspaces` with Workspace summaries and `transfer`), `approval`, `table`, `chart`, `resources`, `artifact`, `notice` and `error`. Resources are linked as `octelium://resource/<apiVersion>/<Kind>/<name>`. Clients must ignore unknown block types and unknown fields; `PROTOCOL_VERSION` is bumped for incompatible changes only.
144
+
145
+ `GET /v1/runs/{id}/events` streams the `AgentEvent`s (`run.*`, `message.*`, `block.created`, `block.delta`, `block.updated`, `conversation.updated`) as SSE. The events of a run are replayed from the start, or after `Last-Event-ID` / `?after=<seq>`, so a client can reconnect or attach to a run in progress. The stream ends after a terminal run event; a finished run with nothing left to replay returns `204`.
146
+
147
+ ## Requirements on the Cluster side
148
+
149
+ - The portal Service allows the CORS origin `https://cordium.<domain>` with credentials and the portal's CSP allows `https://*.cordium.<domain>`, so that the portal can reach the agent at its Workspace's hostname. Other Workspace Applications are deliberately not allowed since they would be able to drive the agents of other Users.
150
+ - To use an Octelium LLM Service, the User must be authorized to access it.
151
+ - Do not share the agent's Application with other Users: the agent acts with the Workspace owner's identity.
152
+
153
+ ## Publishing
154
+
155
+ `.github/workflows/publish-agent.yaml` publishes the package using npm trusted publishing (GitHub OIDC). Configure the package's trusted publisher on npmjs.com with GitHub organization `octelium`, repository `cordium`, workflow filename `publish-agent.yaml`, no environment, and permission to run `npm publish`.
156
+
157
+ Pushing a `v*.*.*` Git tag or publishing a GitHub release publishes the tag's semver, removing the leading `v`, which is the version that the API server of that release runs. Stable releases use `latest`; semver prereleases and GitHub prereleases use `next`. Automatic runs skip versions already published by another event.
158
+
159
+ To publish manually, run the workflow from GitHub Actions, select the branch or Git tag and supply the npm `tag` (e.g. `dev` or `main` for the development builds of the API server). An optional `version` sets an explicit semver. Without it, a selected Git tag supplies the version, while a selected branch produces a unique prerelease containing the npm tag.
160
+
161
+ ## Development
162
+
163
+ ```bash
164
+ npm ci
165
+ npm test # node:test, no network needed (faux LLM + mock gRPC API with a fake Cordium)
166
+ npm run typecheck
167
+ npm run build # dist/
168
+ npm run dev # node src/cli.ts serve
169
+ node src/cli.ts api search "share workspace port"
170
+ node src/cli.ts api describe cordium.v1.MainService/CreateVolume
171
+ ```
172
+
173
+ Outside a Workspace, set `OCTELIUM_DOMAIN` and `OCTELIUM_ACCESS_TOKEN` to use the direct mode.
174
+
175
+ `apis/cordium.json` is regenerated by `make gen-api` (or `make gen-api-agent` after `make cp-pb`) from the `.proto` files via `scripts/gen-apis.mjs`.