@niq.run/lark-worker 0.1.0 → 0.1.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/README.md +71 -0
- package/package.json +6 -1
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# @niq.run/lark-worker
|
|
2
|
+
|
|
3
|
+
A **Feishu / Lark WebSocket bridge** for [niq](https://github.com/niq-run/niq).
|
|
4
|
+
It listens for Feishu messages, forwards them to a bound **reason worker** as
|
|
5
|
+
`worker.input` events, and pushes the reason worker's reply back into the
|
|
6
|
+
Feishu chat. Chat → worker routing is persistent and reconfigurable at runtime
|
|
7
|
+
(per-chat → default → fallback).
|
|
8
|
+
|
|
9
|
+
Built on [`@niq.run/worker-sdk`](https://www.npmjs.com/package/@niq.run/worker-sdk).
|
|
10
|
+
It is an out-of-process extension worker: it connects to a niq bus over
|
|
11
|
+
HTTP + SSE and is meant to be launched by the niq project supervisor (or by you,
|
|
12
|
+
for a standalone bridge).
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install -g @niq.run/lark-worker
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Run
|
|
21
|
+
|
|
22
|
+
The package ships a `niq-lark` bin (compiled app entry `dist/start.js`), so you
|
|
23
|
+
can start it directly — with `npx` (no install needed):
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
# npx — most convenient for launching, e.g. from a niq project's worker config
|
|
27
|
+
npx @niq.run/lark-worker --reason-worker reason.sales
|
|
28
|
+
|
|
29
|
+
# same thing once installed globally
|
|
30
|
+
niq-lark --reason-worker reason.sales
|
|
31
|
+
|
|
32
|
+
# or run it via node from a checkout
|
|
33
|
+
node dist/start.js --reason-worker reason.sales
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Connection to the bus comes from the environment the supervisor injects
|
|
37
|
+
(`NIQ_BUS_URL`, `NIQ_WORKER_ID`, `NIQ_WORKER_CREDENTIAL`), so a niq project can
|
|
38
|
+
spawn it with `npx @niq.run/lark-worker` and nothing else. CLI flags override
|
|
39
|
+
the env.
|
|
40
|
+
|
|
41
|
+
## Configuration
|
|
42
|
+
|
|
43
|
+
| Purpose | Env | Flag |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| Feishu app id | `LARK_APP_ID` | `--app-id` |
|
|
46
|
+
| Feishu app secret | `LARK_APP_SECRET` | `--app-secret` |
|
|
47
|
+
| Feishu/Lark domain | `LARK_DOMAIN` | `--domain` |
|
|
48
|
+
| Proactive message recipient | `LARK_DEFAULT_USER_ID` | `--default-user` |
|
|
49
|
+
| **Default reason worker** | `NIQ_REASON_WORKER` | `--reason-worker` |
|
|
50
|
+
| **Fallback reason worker** | `LARK_FALLBACK_REASON_WORKER` | `--fallback-reason-worker` |
|
|
51
|
+
| **Per-chat routing** | `LARK_REASON_WORKER_MAPPINGS` | `--reason-mappings` |
|
|
52
|
+
| Persisted routing state | `LARK_STATE_FILE` | `--state-file` |
|
|
53
|
+
|
|
54
|
+
At least one of the default or fallback reason worker must be configured.
|
|
55
|
+
Run `niq-lark --help` for the full flag list.
|
|
56
|
+
|
|
57
|
+
## Usage in code
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { LarkWorker, larkConfigFromEnv } from "@niq.run/lark-worker";
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Details
|
|
64
|
+
|
|
65
|
+
See [`src/README.md`](src/README.md) for the full design: the `worker.input`
|
|
66
|
+
flow, `lark.reason.*` runtime routing (`lark.reason.set` / `unset` / `get`),
|
|
67
|
+
and the persisted routing state (`LARK_STATE_FILE`).
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@niq.run/lark-worker",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Feishu/Lark WebSocket bridge Worker for niq — forwards Feishu messages to a bound reason worker and pushes its replies back. Built on @niq.run/worker-sdk.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/niq-run/workers.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://www.npmjs.com/package/@niq.run/lark-worker",
|
|
5
10
|
"type": "module",
|
|
6
11
|
"main": "./dist/worker.js",
|
|
7
12
|
"types": "./dist/worker.d.ts",
|