@onagent/claude-skill 0.0.1
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/LICENSE +128 -0
- package/README.md +61 -0
- package/bin/cli.js +30 -0
- package/package.json +26 -0
- package/skill/SKILL.md +237 -0
- package/skill/bin/onagent-darwin-arm64 +0 -0
- package/skill/bin/onagent-windows-amd64.exe +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
4
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
5
|
+
|
|
6
|
+
-----------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
Parameters
|
|
9
|
+
|
|
10
|
+
Licensor: Cai Ting Yu
|
|
11
|
+
Licensed Work: onagent
|
|
12
|
+
The Licensed Work is (c) 2026 Cai Ting Yu
|
|
13
|
+
Additional Use Grant: You may use the Licensed Work for any purpose,
|
|
14
|
+
including running it as part of a commercial
|
|
15
|
+
product or service that is not, in substance, a
|
|
16
|
+
hosted or managed version of the Licensed Work
|
|
17
|
+
itself made available to third parties (i.e., you
|
|
18
|
+
may not offer the Licensed Work, or a service
|
|
19
|
+
whose primary purpose is to provide the
|
|
20
|
+
functionality of the Licensed Work, as a
|
|
21
|
+
competing hosted/managed service to third
|
|
22
|
+
parties without a separate commercial license
|
|
23
|
+
from the Licensor).
|
|
24
|
+
|
|
25
|
+
[NOTE for future revisions: this Additional Use
|
|
26
|
+
Grant may be narrowed in a later release (e.g. to
|
|
27
|
+
restrict any commercial use without a separate
|
|
28
|
+
license) without affecting the terms already
|
|
29
|
+
granted to copies of the Licensed Work distributed
|
|
30
|
+
under this or an earlier release.]
|
|
31
|
+
|
|
32
|
+
Change Date: Four years from the date this version of the
|
|
33
|
+
Licensed Work is first published.
|
|
34
|
+
|
|
35
|
+
Change License: Apache License, Version 2.0
|
|
36
|
+
|
|
37
|
+
For information about alternative licensing arrangements for the Licensed
|
|
38
|
+
Work, please contact the Licensor at tim72117@gmail.com.
|
|
39
|
+
|
|
40
|
+
Notice
|
|
41
|
+
|
|
42
|
+
The Business Source License (this document, or the "License") is not an
|
|
43
|
+
Open Source license. However, the Licensed Work will eventually be made
|
|
44
|
+
available under an Open Source License, as stated in this License.
|
|
45
|
+
|
|
46
|
+
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
47
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
48
|
+
|
|
49
|
+
-----------------------------------------------------------------------------
|
|
50
|
+
|
|
51
|
+
Business Source License 1.1
|
|
52
|
+
|
|
53
|
+
Terms
|
|
54
|
+
|
|
55
|
+
The Licensor hereby grants you the right to copy, modify, create
|
|
56
|
+
derivative works, redistribute, and make non-production use of the
|
|
57
|
+
Licensed Work. The Licensor may make an Additional Use Grant, above,
|
|
58
|
+
permitting limited production use.
|
|
59
|
+
|
|
60
|
+
Effective on the Change Date, or the fourth anniversary of the first
|
|
61
|
+
publicly available distribution of a specific version of the Licensed
|
|
62
|
+
Work under this License, whichever comes first, the Licensor hereby
|
|
63
|
+
grants you rights under the terms of the Change License, and the rights
|
|
64
|
+
granted in the paragraph above terminate.
|
|
65
|
+
|
|
66
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
67
|
+
currently in effect as described in this License, you must purchase a
|
|
68
|
+
commercial license from the Licensor, its affiliated entities, or
|
|
69
|
+
authorized resellers, or you must refrain from using the Licensed Work.
|
|
70
|
+
|
|
71
|
+
All copies of the original and modified Licensed Work, and derivative
|
|
72
|
+
works of the Licensed Work, are subject to this License. This License
|
|
73
|
+
applies separately for each version of the Licensed Work and the Change
|
|
74
|
+
Date may vary for each version of the Licensed Work released by
|
|
75
|
+
Licensor.
|
|
76
|
+
|
|
77
|
+
You must conspicuously display this License on each original or
|
|
78
|
+
modified copy of the Licensed Work. If you receive the Licensed Work
|
|
79
|
+
in original or modified form from a third party, the terms and
|
|
80
|
+
conditions set forth in this License apply to your use of that work.
|
|
81
|
+
|
|
82
|
+
Any use of the Licensed Work in violation of this License will
|
|
83
|
+
automatically terminate your rights under this License for the current
|
|
84
|
+
and all other versions of the Licensed Work.
|
|
85
|
+
|
|
86
|
+
This License does not grant you any right in any trademark or logo of
|
|
87
|
+
Licensor or its affiliates (provided that you may use a trademark or
|
|
88
|
+
logo of Licensor as expressly required by this License).
|
|
89
|
+
|
|
90
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED
|
|
91
|
+
ON AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND
|
|
92
|
+
CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES
|
|
93
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT,
|
|
94
|
+
AND TITLE.
|
|
95
|
+
|
|
96
|
+
MariaDB hereby grants you permission to use this License's text to
|
|
97
|
+
license your works, and to refer to it using the trademark "Business
|
|
98
|
+
Source License", as long as you comply with the Covenants of Licensor
|
|
99
|
+
below.
|
|
100
|
+
|
|
101
|
+
Covenants of Licensor
|
|
102
|
+
|
|
103
|
+
In consideration of the right to use this License's text and the
|
|
104
|
+
"Business Source License" name and trademark, Licensor covenants to
|
|
105
|
+
MariaDB, and to all other recipients of the licensed work to be
|
|
106
|
+
provided by Licensor:
|
|
107
|
+
|
|
108
|
+
1. To specify as the Change License the GPL Version 2.0 or any later
|
|
109
|
+
version, or a license that is compatible with GPL Version 2.0 or a
|
|
110
|
+
later version, where "compatible" means that software provided
|
|
111
|
+
under the Change License can be included in a program with software
|
|
112
|
+
provided under GPL Version 2.0 or a later version. Licensor may
|
|
113
|
+
specify additional Change Licenses without limitation.
|
|
114
|
+
|
|
115
|
+
2. To either: (a) specify an additional grant of rights to use that
|
|
116
|
+
does not impose any additional restriction on the right granted in
|
|
117
|
+
this License, as the Additional Use Grant; or (b) insert the text
|
|
118
|
+
"None".
|
|
119
|
+
|
|
120
|
+
3. To specify a Change Date.
|
|
121
|
+
|
|
122
|
+
4. Not to modify this License in any other way.
|
|
123
|
+
|
|
124
|
+
Notice
|
|
125
|
+
|
|
126
|
+
The Business Source License (this document, or the "License") is not an
|
|
127
|
+
Open Source license. However, the Licensed Work will eventually be made
|
|
128
|
+
available under an Open Source License, as stated in this License.
|
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @onagent/claude-skill
|
|
2
|
+
|
|
3
|
+
Experimental npm packaging of the `onagent-cli-setup` Claude Code skill.
|
|
4
|
+
Published under the `@onagent` scope (matching `@onagent/bridge`), but the
|
|
5
|
+
installed CLI command stays the shorter, unscoped `claude-skill-onagent` —
|
|
6
|
+
see `bin` in `package.json`.
|
|
7
|
+
|
|
8
|
+
`skill/SKILL.md` in this directory is an independent copy of
|
|
9
|
+
`.claude/skills/onagent-cli-setup/SKILL.md` at the repo root — not a
|
|
10
|
+
symlink, and not automatically kept in sync. The two are allowed to drift
|
|
11
|
+
(this package's copy may describe platforms/binaries the root skill
|
|
12
|
+
doesn't bundle, or vice versa); when editing either one, decide deliberately
|
|
13
|
+
whether the other needs the same change instead of assuming it already
|
|
14
|
+
happened.
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
npx claude-skill-onagent # installs to ./.claude/skills/onagent-cli-setup
|
|
20
|
+
npx claude-skill-onagent --user # installs to ~/.claude/skills/onagent-cli-setup
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This is an explicit, user-invoked install (not a `postinstall` script) — npm
|
|
24
|
+
and GitHub are moving toward disabling install scripts by default, so
|
|
25
|
+
anything that auto-copies files on `npm install` is a fading, riskier
|
|
26
|
+
pattern. Running this only happens when someone actually types the command.
|
|
27
|
+
|
|
28
|
+
## Building the bundled binary
|
|
29
|
+
|
|
30
|
+
`skill/bin/` is gitignored — build it locally before publishing or testing:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
cd ../../backend
|
|
34
|
+
GOWORK=off GOOS=windows GOARCH=amd64 go build -trimpath -ldflags="-s -w" -o ../packages/claude-skill/skill/bin/onagent-windows-amd64.exe ./cmd/onagent
|
|
35
|
+
GOWORK=off GOOS=darwin GOARCH=arm64 go build -trimpath -ldflags="-s -w" -o ../packages/claude-skill/skill/bin/onagent-darwin-arm64 ./cmd/onagent
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`-trimpath -ldflags="-s -w"` matches `release-onagent.yml`'s own build flags
|
|
39
|
+
(strips debug symbols/DWARF info and local file paths) — cuts each binary
|
|
40
|
+
by roughly 30%.
|
|
41
|
+
|
|
42
|
+
Only Windows and Apple Silicon macOS are bundled right now. `SKILL.md`'s own
|
|
43
|
+
fallback instructions (`go install .../cmd/onagent@latest`, or clone +
|
|
44
|
+
build) cover Linux and Intel Mac until this package fetches the right
|
|
45
|
+
platform binary from onagent's GitHub Releases automatically.
|
|
46
|
+
|
|
47
|
+
## Publishing
|
|
48
|
+
|
|
49
|
+
Scoped packages (`@onagent/*`) default to private on npm — publish with
|
|
50
|
+
`--access public`, or npm rejects it:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
npm publish --access public
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
`LICENSE` in this directory is a copy of the repo root's `LICENSE` (BSL
|
|
59
|
+
1.1), copied rather than symlinked since npm's `files` packaging only sees
|
|
60
|
+
files inside this package directory. Keep it in sync manually if the root
|
|
61
|
+
`LICENSE` changes.
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Explicit-invocation installer (npx claude-skill-onagent), not a postinstall
|
|
3
|
+
// script — postinstall auto-copy is the pattern npm/GitHub are moving away
|
|
4
|
+
// from by disabling install scripts by default, so this only runs when the
|
|
5
|
+
// user actually asks for it.
|
|
6
|
+
import { cpSync, existsSync, mkdirSync } from 'node:fs'
|
|
7
|
+
import { dirname, join } from 'node:path'
|
|
8
|
+
import { fileURLToPath } from 'node:url'
|
|
9
|
+
import { homedir } from 'node:os'
|
|
10
|
+
|
|
11
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
12
|
+
const packageRoot = join(__dirname, '..')
|
|
13
|
+
const source = join(packageRoot, 'skill')
|
|
14
|
+
|
|
15
|
+
const userLevel = process.argv.includes('--user')
|
|
16
|
+
const target = userLevel
|
|
17
|
+
? join(homedir(), '.claude', 'skills', 'onagent-cli-setup')
|
|
18
|
+
: join(process.cwd(), '.claude', 'skills', 'onagent-cli-setup')
|
|
19
|
+
|
|
20
|
+
if (!existsSync(source)) {
|
|
21
|
+
console.error(`Bundled skill content missing at ${source} — package install may be corrupt.`)
|
|
22
|
+
process.exit(1)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
mkdirSync(dirname(target), { recursive: true })
|
|
26
|
+
cpSync(source, target, { recursive: true })
|
|
27
|
+
|
|
28
|
+
console.log(`Installed onagent-cli-setup skill to ${target}`)
|
|
29
|
+
console.log('Bundled binaries: skill/bin/onagent-windows-amd64.exe, skill/bin/onagent-darwin-arm64.')
|
|
30
|
+
console.log('On other platforms (Linux, Intel Mac), follow SKILL.md\'s fallback instructions (go install / build from source).')
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@onagent/claude-skill",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Claude Code skill installer for onagent-cli-setup, with bundled onagent CLI binaries for zero-setup use.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"claude-skill-onagent": "bin/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"skill",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"license": "Proprietary",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/tim72117/onagent.git",
|
|
18
|
+
"directory": "packages/claude-skill"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"claude-code",
|
|
22
|
+
"claude-skill",
|
|
23
|
+
"onagent"
|
|
24
|
+
],
|
|
25
|
+
"author": "Cai Ting Yu"
|
|
26
|
+
}
|
package/skill/SKILL.md
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: onagent-cli-setup
|
|
3
|
+
description: 協助使用者透過 onagent CLI 登入 onagent 平台、在 console 建立 app、定義並推送 tool 到 onagent 開發者平台。當使用者想串接 onagent SDK、建立 tool、或詢問如何使用 onagent CLI 時使用這個 skill。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# onagent CLI 設定與 Tool 串接
|
|
7
|
+
|
|
8
|
+
協助使用者完成 onagent 平台的完整串接流程:取得並登入 `onagent` CLI、在 console 建立 app 與設定必要參數、定義並推送 tool。
|
|
9
|
+
|
|
10
|
+
## 一、取得 onagent CLI 並登入
|
|
11
|
+
|
|
12
|
+
### 1. 檢查/取得 onagent CLI
|
|
13
|
+
|
|
14
|
+
**這個 skill 內建預先編譯好的 `onagent` 執行檔**,位於 `${CLAUDE_SKILL_DIR}/bin/`。目前實際內建了:
|
|
15
|
+
|
|
16
|
+
- `onagent-windows-amd64.exe`
|
|
17
|
+
- `onagent-darwin-arm64`(Apple Silicon macOS)
|
|
18
|
+
|
|
19
|
+
(下面的平台判斷邏輯涵蓋所有平台組合,未來若補回其他平台(Intel Mac、Linux 等)的執行檔,不需要再改這段邏輯,只要把對應檔案放進 `bin/` 目錄即可生效。)
|
|
20
|
+
|
|
21
|
+
`go install github.com/tim72117/onagent/cmd/onagent@latest` 現在也能用了(go.mod 的 module path 先前跟實際 repo 位置對不上導致 `go install` 失敗,這個問題已修好;`backend/` 本身就是 module root,所以路徑不含 `backend/`)。但即使如此,**優先使用上面內建的執行檔**:不需要本機裝 Go 工具鏈、不需要等編譯、也不依賴網路抓取私有相依套件。全域 PATH 上通常也不會有 `onagent` 指令,所以**不要**直接執行裸指令 `onagent`,而是要先判斷目前所在平台,再直接呼叫 `${CLAUDE_SKILL_DIR}/bin/` 底下對應的執行檔。
|
|
22
|
+
|
|
23
|
+
判斷平台的方式:
|
|
24
|
+
|
|
25
|
+
- **Unix-like(Linux / macOS)**:執行 `uname -sm` 取得 OS 與 CPU 架構,再對應成 `<os>-<arch>`:
|
|
26
|
+
- `Linux x86_64` → `linux-amd64`
|
|
27
|
+
- `Linux aarch64` / `Linux arm64` → `linux-arm64`
|
|
28
|
+
- `Darwin x86_64` → `darwin-amd64`
|
|
29
|
+
- `Darwin arm64` → `darwin-arm64`(bundled)
|
|
30
|
+
- **Windows**:直接使用 `windows-amd64`(bundled)。
|
|
31
|
+
|
|
32
|
+
判斷完成後,直接用 Bash 呼叫對應的檔案(記得先確認/賦予執行權限),例如:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Linux/macOS,以偵測到 linux-amd64 為例(Linux 目前不是 bundled,會落到下面的備援方案)
|
|
36
|
+
chmod +x "${CLAUDE_SKILL_DIR}/bin/onagent-linux-amd64"
|
|
37
|
+
"${CLAUDE_SKILL_DIR}/bin/onagent-linux-amd64" list-apps
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Apple Silicon macOS(bundled,實際存在)
|
|
42
|
+
chmod +x "${CLAUDE_SKILL_DIR}/bin/onagent-darwin-arm64"
|
|
43
|
+
"${CLAUDE_SKILL_DIR}/bin/onagent-darwin-arm64" list-apps
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Windows(bundled,實際存在)
|
|
48
|
+
"${CLAUDE_SKILL_DIR}/bin/onagent-windows-amd64.exe" list-apps
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
不要假設 `onagent` 已經加進 PATH,每次呼叫都應該用上述判斷邏輯組出完整路徑直接執行。如果之後在同一個 session 裡要重複呼叫,可以把判斷出來的完整路徑存進一個變數重複使用,但不要省略判斷平台這一步、也不要寫死成單一平台的路徑。
|
|
52
|
+
|
|
53
|
+
**判斷出來的檔案在 `bin/` 目錄下實際不存在時**(目前只有 `onagent-windows-amd64.exe` 和 `onagent-darwin-arm64` 真的存在,判斷出 Linux、Intel Mac 等其他平台一定會落到這裡),改用下面的「備援方案」,不要嘗試執行一個不存在的檔案。
|
|
54
|
+
|
|
55
|
+
#### 備援方案:自行 clone + 編譯
|
|
56
|
+
|
|
57
|
+
目前只內建 Windows 與 Apple Silicon macOS 的執行檔,判斷出其他平台(Linux、Intel Mac,或更少見的 linux/386、linux/arm 等)時都會落到這裡。如果本機已有 Go 工具鏈,最簡單的方式是:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
go install github.com/tim72117/onagent/cmd/onagent@latest
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
沒有 Go 工具鏈的話,才 fallback 用 clone 整個 repo 後在本機用 `go build` 編譯:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
git clone https://github.com/tim72117/onagent.git
|
|
67
|
+
cd onagent/backend
|
|
68
|
+
go build -o onagent ./cmd/onagent
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
編譯完成後會在 `backend` 目錄下產生 `onagent`(Windows 上是 `onagent.exe`)執行檔。之後可以用相對路徑(如 `./onagent` 或 `.\onagent.exe`)呼叫,或自行加進 PATH。
|
|
72
|
+
|
|
73
|
+
### 2. 登入
|
|
74
|
+
|
|
75
|
+
> 以下與後續章節為了簡潔,一律直接寫 `onagent login`、`onagent list-apps`、`onagent save-tools` 等指令;實際執行時請替換成上一步判斷出來的完整路徑,例如 `${CLAUDE_SKILL_DIR}/bin/onagent-linux-amd64 login --web`,而不是直接執行裸指令 `onagent`。
|
|
76
|
+
|
|
77
|
+
`onagent` 提供兩種登入方式,指向的後端與 console 網址預設都是 `https://onagent.shuttle.tools`,如需指向本機開發環境可用 `-api`、`-console` 參數覆蓋。
|
|
78
|
+
|
|
79
|
+
- **`onagent login --web [-api <url>] [-console <url>]`**:開啟瀏覽器走網頁登入流程。這是預設應該優先使用的方式,適合互動式終端機環境,也是唯一能確保跟 console 網頁 UI(例如之後建立 app、簽發 apiKey)使用同一組登入狀態的方式。
|
|
80
|
+
- **`onagent login [-api <url>]`**:在終端機互動輸入 email/password 登入,不會開瀏覽器。適合沒有瀏覽器可用的環境(例如純 SSH、CI/無頭環境),或使用者明確表示不想開瀏覽器時使用。
|
|
81
|
+
|
|
82
|
+
兩者只是登入的互動方式不同,登入後的本機憑證狀態是通用的,後續 `onagent` 指令不需要再指定是用哪種方式登入的。
|
|
83
|
+
|
|
84
|
+
執行時直接照使用者情境選一種即可;若不確定,優先嘗試 `onagent login --web`。
|
|
85
|
+
|
|
86
|
+
### 3. 確認登入成功
|
|
87
|
+
|
|
88
|
+
登入後可用 `onagent list-apps` 驗證憑證是否生效:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
onagent list-apps
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
- 如果回傳結果是 app 清單(即使是空清單),代表登入成功。
|
|
95
|
+
- 如果出現類似「not logged in」的錯誤訊息,代表尚未登入或憑證已失效,需要回到步驟 2 重新執行 `onagent login` 或 `onagent login --web`。
|
|
96
|
+
|
|
97
|
+
確認 `onagent list-apps` 不再出現「not logged in」錯誤後,才視為登入流程完成,可以繼續後續操作(例如在 console 建立 app、`onagent save-tools`)。
|
|
98
|
+
|
|
99
|
+
## 二、建立 App、發 Key、設定 Origin
|
|
100
|
+
|
|
101
|
+
建立 app、發 API key、設定 Allowed origin 三件事現在都已經有對應的 `onagent` CLI 指令,也都可以在 console 網頁 UI 完成,兩種方式效果相同、擇一即可。`onagent` 目前有 `login`、`login --web`、`list-apps`、`create-app`、`issue-key`、`set-origin`、`save-tools` 七個指令。
|
|
102
|
+
|
|
103
|
+
### 1. 建立 app
|
|
104
|
+
|
|
105
|
+
優先用 CLI 建立(記得替換成上一節判斷出來的完整路徑):
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
onagent create-app <appId>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
appId 合法格式必須符合正則 `^[a-zA-Z0-9][a-zA-Z0-9_-]*$`,也就是:
|
|
112
|
+
- 只能以英文字母或數字開頭
|
|
113
|
+
- 之後可以包含英文字母、數字、`-`、`_`
|
|
114
|
+
|
|
115
|
+
也可以在 https://onagent.shuttle.tools/app 登入後點「+ New app」手動建立,效果相同,只是多一道開瀏覽器的步驟。
|
|
116
|
+
|
|
117
|
+
### 2. 定義 tools
|
|
118
|
+
|
|
119
|
+
在 console 的 tool 編輯器裡定義 tool 並按 Save;也可以改用 `onagent save-tools <appId> <tools.yaml>` 從本機檔案推上去,效果相同(`save-tools` 只會把檔案裡的 `tools` 內容送出,且一律套用指令參數上的 `appId`,跟檔案裡寫的 `appId` 無關)。完整的 `tools.yaml` 撰寫格式與範例請見下一節「定義 tool 並用 onagent save-tools 推上去」。
|
|
120
|
+
|
|
121
|
+
### 3. 發 API key
|
|
122
|
+
|
|
123
|
+
優先用 CLI 發:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
onagent issue-key <appId>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
也可以在 console 裡按「Issue key」取得 `apiKey`,效果相同。**務必提醒使用者兩件事:**
|
|
130
|
+
- 明文的 `apiKey` **只會顯示這一次**,離開畫面(或終端機輸出捲走)後就再也看不到、拿不回來。
|
|
131
|
+
- 如果需要重新取得,只能「重新發一組」,而重新發一組會讓**舊的 key 立刻失效**。所以如果目前正式環境已經在用某一把 key,不要隨意重發,以免正式環境的連線瞬間全部失敗。
|
|
132
|
+
|
|
133
|
+
### 4. 設定 Allowed origin
|
|
134
|
+
|
|
135
|
+
優先用 CLI 設定:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
onagent set-origin <appId> <origin>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
`<origin>` 填你網站的完整 origin,例如 `https://your-site.example.com`(**不要**加路徑、**不要**加結尾斜線)。也可以在 console 的「Allowed origin」欄位填入同樣的值並按 Save origin,效果相同。
|
|
142
|
+
|
|
143
|
+
**這一步最容易被忽略,但沒做的話後果是整個串接完全失敗:只要 Allowed origin 沒設定,這個 app 的所有 WebSocket 連線都會被拒絕(fail-closed)——即使 `apiKey` 完全正確也一樣連不上。** 如果使用者回報「apiKey 明明是對的,但連線就是被拒絕/WebSocket 連不上」,第一件事就是提醒他們檢查這個 app 的 Allowed origin 是否已經設定、且與實際部署網域完全一致。
|
|
144
|
+
|
|
145
|
+
## 三、定義 tool 並用 onagent save-tools 推上去
|
|
146
|
+
|
|
147
|
+
除了在 console 網頁 UI 用 tool 編輯器手動定義 tool,也可以把 tool 定義寫成一份本機的 `tools.yaml` 檔案,再用 `onagent save-tools` 指令一次推上去,效果完全相同。當使用者的 tool 數量較多、需要版本控制、或想要重複套用到多個 app 時,優先建議這個方式。
|
|
148
|
+
|
|
149
|
+
### tools.yaml 的精確格式
|
|
150
|
+
|
|
151
|
+
檔案結構如下,各欄位規則務必照著寫,不要自行增減欄位:
|
|
152
|
+
|
|
153
|
+
- `appId`(最上層,可省略):可以寫,但沒有實際作用——執行 `onagent save-tools <appId> <file>` 時,一律以指令參數上的 `appId` 為準,檔案裡寫的值會被完全覆蓋、忽略不採用。
|
|
154
|
+
- `thought`(最上層,選填):want agent 的自訂 system prompt,可省略。
|
|
155
|
+
- `tools`(必填):一個陣列,每個元素是一個 tool 定義,包含:
|
|
156
|
+
- `name`(必填):必須符合正則 `^[a-zA-Z_][a-zA-Z0-9_]*$`(英文字母或底線開頭,之後只能是英文字母、數字、底線),同一個 app 裡不能重複。
|
|
157
|
+
- `description`(必填):給 LLM 判斷何時該呼叫這個 tool 的說明文字。
|
|
158
|
+
- `parameters`(必填):JSON Schema 的子集,用來描述這個 tool 接受的參數:
|
|
159
|
+
- `type`(必填):目前這一層通常固定寫 `object`。
|
|
160
|
+
- `properties`:物件,每個 key 是參數名稱,value 描述該參數的 `type`(支援 `string`、`number`、`integer`、`boolean`、`array`、`object`)與選填的 `description`。
|
|
161
|
+
- `required`(選填):陣列,列出哪些參數名稱是必填。
|
|
162
|
+
- 若某個參數本身是 `array`,用 `items` 描述元素型別;若是 `object`,用 `properties`(可再搭配 `required`)描述其欄位,可以巢狀。
|
|
163
|
+
- `returns`(選填):格式與 `parameters` 相同的 JSON Schema 子集,用來描述回傳值的形狀。這個欄位只用於 TypeScript 型別產生(codegen),不會送給 LLM,可以省略。
|
|
164
|
+
|
|
165
|
+
### 完整範例
|
|
166
|
+
|
|
167
|
+
```yaml
|
|
168
|
+
appId: my-app
|
|
169
|
+
thought: ""
|
|
170
|
+
tools:
|
|
171
|
+
- name: search_products
|
|
172
|
+
description: Search the product catalog by keyword.
|
|
173
|
+
parameters:
|
|
174
|
+
type: object
|
|
175
|
+
properties:
|
|
176
|
+
query:
|
|
177
|
+
type: string
|
|
178
|
+
description: The search keywords.
|
|
179
|
+
maxResults:
|
|
180
|
+
type: integer
|
|
181
|
+
required:
|
|
182
|
+
- query
|
|
183
|
+
returns:
|
|
184
|
+
type: array
|
|
185
|
+
items:
|
|
186
|
+
type: object
|
|
187
|
+
properties:
|
|
188
|
+
id: { type: string }
|
|
189
|
+
name: { type: string }
|
|
190
|
+
|
|
191
|
+
- name: add_to_cart
|
|
192
|
+
description: Add a product to the current user's shopping cart.
|
|
193
|
+
parameters:
|
|
194
|
+
type: object
|
|
195
|
+
properties:
|
|
196
|
+
productId:
|
|
197
|
+
type: string
|
|
198
|
+
description: The product's unique ID.
|
|
199
|
+
quantity:
|
|
200
|
+
type: integer
|
|
201
|
+
description: How many units to add. Defaults to 1 if omitted.
|
|
202
|
+
required:
|
|
203
|
+
- productId
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
把這份檔案存成本機檔案(例如 `tools.yaml`)後,用以下指令推上去:
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
onagent save-tools <appId> tools.yaml
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
`<appId>` 這個指令參數會覆蓋檔案內 `appId` 欄位寫的值——`onagent save-tools` 只會讀取並送出檔案裡的 `tools` 陣列,實際套用到哪個 app 完全由指令參數決定。這代表同一份 `tools.yaml` 可以原封不動地重複套用到多個不同的 appId,不需要為每個 app 各寫一份檔案、也不用記得同步修改檔案內的 `appId`。
|
|
213
|
+
|
|
214
|
+
執行前 `onagent` 會先在本機做一次 `Validate()`,通過才會送出。
|
|
215
|
+
|
|
216
|
+
### 常見驗證錯誤
|
|
217
|
+
|
|
218
|
+
協助使用者除錯時,優先檢查以下幾種最常見的驗證失敗原因:
|
|
219
|
+
|
|
220
|
+
- **tool name 不符合正則**:`name` 沒有以英文字母或底線開頭、或裡面含有連字號 `-`、空白、中文等不合法字元,都會被 `^[a-zA-Z_][a-zA-Z0-9_]*$` 擋下。
|
|
221
|
+
- **缺少 description**:`tools` 陣列裡任何一個 tool 沒填 `description`。
|
|
222
|
+
- **缺少 parameters.type**:`parameters` 底下沒有寫 `type`(或整個 `parameters` 欄位被省略)。
|
|
223
|
+
- **重複的 tool name**:同一個 app 的 `tools` 陣列裡出現兩個相同的 `name`。
|
|
224
|
+
|
|
225
|
+
遇到 `onagent save-tools` 報錯時,先對照上述四點逐一檢查 yaml 內容,而不是猜測是網路或權限問題。
|
|
226
|
+
|
|
227
|
+
## 完整流程總覽
|
|
228
|
+
|
|
229
|
+
1. 判斷目前平台(`uname -sm` 或 Windows),呼叫 skill 內建的 `${CLAUDE_SKILL_DIR}/bin/onagent-<os>-<arch>[.exe]`;目前只實際內建 Windows 與 Apple Silicon macOS,偵測到其他平台就用 `go install`(現在可以用了)或 clone repo 後 `go build` 自行編譯。
|
|
230
|
+
2. 執行 `onagent login --web`(或無瀏覽器環境用 `onagent login`)登入。
|
|
231
|
+
3. 用 `onagent list-apps` 確認不再出現「not logged in」,驗證登入成功。
|
|
232
|
+
4. 執行 `onagent create-app <appId>` 建立 app(也可以到 console 網頁 https://onagent.shuttle.tools/app 點「+ New app」手動建立,效果相同)。
|
|
233
|
+
5. 定義 tool:在 console 的 tool 編輯器手動輸入,或撰寫本機 `tools.yaml` 準備用 `onagent save-tools` 推送。
|
|
234
|
+
6. 執行 `onagent issue-key <appId>`(或在 console 按「Issue key」)取得 `apiKey`,並立刻妥善保存(**只顯示一次**,重發會讓舊 key 立刻失效)。
|
|
235
|
+
7. 執行 `onagent set-origin <appId> <origin>`(或在 console 設定「Allowed origin」)為實際部署網域並存檔(**未設定會 fail-closed,WebSocket 全部連不上**,即使 `apiKey` 正確也一樣)。
|
|
236
|
+
8. 若採用 `tools.yaml` 方式,執行 `onagent save-tools <appId> tools.yaml` 推送(指令參數的 `appId` 一律覆蓋檔案內的 `appId`)。
|
|
237
|
+
9. 若 `save-tools` 驗證失敗,依序檢查:tool name 正則、`description` 是否缺漏、`parameters.type` 是否缺漏、tool name 是否重複。
|
|
Binary file
|
|
Binary file
|