orbit-code-ai 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.
- package/LICENSE +29 -0
- package/README.md +326 -0
- package/_agent_reference/components/audit-logging.md +129 -0
- package/_agent_reference/components/common-utils.md +146 -0
- package/_agent_reference/components/error-handling.md +117 -0
- package/_agent_reference/components/http-adapters.md +134 -0
- package/_agent_reference/components/input-adapters.md +101 -0
- package/_agent_reference/components/output-adapters.md +124 -0
- package/_agent_reference/components/property-reader.md +100 -0
- package/_agent_reference/components/retry.md +107 -0
- package/_agent_reference/config/naming-conventions.md +188 -0
- package/_agent_reference/config/properties-template.md +158 -0
- package/_agent_reference/config/queue-definition.md +141 -0
- package/_agent_reference/esql-coding-standards.md +112 -0
- package/_agent_reference/msgflow-xml-reference.md +207 -0
- package/_agent_reference/node_types_extended.md +211 -0
- package/_agent_reference/templates/file-flow.md +212 -0
- package/_agent_reference/templates/http-flow.md +185 -0
- package/_agent_reference/templates/mq-flow.md +248 -0
- package/bin/import-specifier.mjs +13 -0
- package/bin/import-specifier.test.mjs +13 -0
- package/bin/orbit +32 -0
- package/dist/cli.mjs +492705 -0
- package/package.json +149 -0
- package/skills/ace-app-http/SKILL.md +523 -0
- package/skills/ace-app-mq/SKILL.md +554 -0
- package/skills/apic-api/SKILL.md +645 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
NOTICE
|
|
2
|
+
|
|
3
|
+
This repository contains code derived from Anthropic's Orbit CLI.
|
|
4
|
+
|
|
5
|
+
The original Orbit source is proprietary software:
|
|
6
|
+
Copyright (c) Anthropic PBC. All rights reserved.
|
|
7
|
+
Subject to Anthropic's Commercial Terms of Service.
|
|
8
|
+
|
|
9
|
+
Modifications and additions by Orbit contributors are offered under
|
|
10
|
+
the MIT License where legally permissible:
|
|
11
|
+
|
|
12
|
+
MIT License
|
|
13
|
+
Copyright (c) 2026 Orbit contributors (modifications only)
|
|
14
|
+
|
|
15
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
16
|
+
a copy of the modifications made by Orbit contributors, to deal
|
|
17
|
+
in those modifications without restriction, including without limitation
|
|
18
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
19
|
+
and/or sell copies, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included
|
|
22
|
+
in all copies or substantial portions of the modifications.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
|
|
25
|
+
|
|
26
|
+
The underlying derived code remains subject to Anthropic's copyright.
|
|
27
|
+
This project does not have Anthropic's authorization to distribute
|
|
28
|
+
their proprietary source. Users and contributors should evaluate their
|
|
29
|
+
own legal position.
|
package/README.md
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
# Orbit
|
|
2
|
+
|
|
3
|
+
Orbit is an open-source coding-agent CLI for cloud and local model providers.
|
|
4
|
+
|
|
5
|
+
Use OpenAI-compatible APIs, Gemini, GitHub Models, Codex, Ollama, Atomic Chat, and other supported backends while keeping one terminal-first workflow: prompts, tools, agents, MCP, slash commands, and streaming output.
|
|
6
|
+
|
|
7
|
+
[](https://github.com/Gitlawb/orbit/actions/workflows/pr-checks.yml)
|
|
8
|
+
[](https://github.com/Gitlawb/orbit/tags)
|
|
9
|
+
[](https://github.com/Gitlawb/orbit/discussions)
|
|
10
|
+
[](SECURITY.md)
|
|
11
|
+
[](LICENSE)
|
|
12
|
+
|
|
13
|
+
[Quick Start](#quick-start) | [Setup Guides](#setup-guides) | [Providers](#supported-providers) | [Source Build](#source-build-and-local-development) | [VS Code Extension](#vs-code-extension) | [Community](#community)
|
|
14
|
+
|
|
15
|
+
## Why Orbit
|
|
16
|
+
|
|
17
|
+
- Use one CLI across cloud APIs and local model backends
|
|
18
|
+
- Save provider profiles inside the app with `/provider`
|
|
19
|
+
- Run with OpenAI-compatible services, Gemini, GitHub Models, Codex, Ollama, Atomic Chat, and other supported providers
|
|
20
|
+
- Keep coding-agent workflows in one place: bash, file tools, grep, glob, agents, tasks, MCP, and web tools
|
|
21
|
+
- Use the bundled VS Code extension for launch integration and theme support
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### Install
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install -g @gitlawb/orbit
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
If the install later reports `ripgrep not found`, install ripgrep system-wide and confirm `rg --version` works in the same terminal before starting Orbit.
|
|
32
|
+
|
|
33
|
+
### Start
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
orbit
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Inside Orbit:
|
|
40
|
+
|
|
41
|
+
- run `/provider` for guided provider setup and saved profiles
|
|
42
|
+
- run `/onboard-github` for GitHub Models onboarding
|
|
43
|
+
|
|
44
|
+
### Fastest OpenAI setup
|
|
45
|
+
|
|
46
|
+
macOS / Linux:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
export ORBIT_CODE_USE_OPENAI=1
|
|
50
|
+
export OPENAI_API_KEY=sk-your-key-here
|
|
51
|
+
export OPENAI_MODEL=gpt-4o
|
|
52
|
+
|
|
53
|
+
orbit
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Windows PowerShell:
|
|
57
|
+
|
|
58
|
+
```powershell
|
|
59
|
+
$env:ORBIT_CODE_USE_OPENAI="1"
|
|
60
|
+
$env:OPENAI_API_KEY="sk-your-key-here"
|
|
61
|
+
$env:OPENAI_MODEL="gpt-4o"
|
|
62
|
+
|
|
63
|
+
orbit
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Fastest local Ollama setup
|
|
67
|
+
|
|
68
|
+
macOS / Linux:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
export ORBIT_CODE_USE_OPENAI=1
|
|
72
|
+
export OPENAI_BASE_URL=http://localhost:11434/v1
|
|
73
|
+
export OPENAI_MODEL=qwen2.5-coder:7b
|
|
74
|
+
|
|
75
|
+
orbit
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Windows PowerShell:
|
|
79
|
+
|
|
80
|
+
```powershell
|
|
81
|
+
$env:ORBIT_CODE_USE_OPENAI="1"
|
|
82
|
+
$env:OPENAI_BASE_URL="http://localhost:11434/v1"
|
|
83
|
+
$env:OPENAI_MODEL="qwen2.5-coder:7b"
|
|
84
|
+
|
|
85
|
+
orbit
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Setup Guides
|
|
89
|
+
|
|
90
|
+
Beginner-friendly guides:
|
|
91
|
+
|
|
92
|
+
- [Non-Technical Setup](docs/non-technical-setup.md)
|
|
93
|
+
- [Windows Quick Start](docs/quick-start-windows.md)
|
|
94
|
+
- [macOS / Linux Quick Start](docs/quick-start-mac-linux.md)
|
|
95
|
+
|
|
96
|
+
Advanced and source-build guides:
|
|
97
|
+
|
|
98
|
+
- [Advanced Setup](docs/advanced-setup.md)
|
|
99
|
+
- [Android Install](ANDROID_INSTALL.md)
|
|
100
|
+
|
|
101
|
+
## Supported Providers
|
|
102
|
+
|
|
103
|
+
| Provider | Setup Path | Notes |
|
|
104
|
+
| --- | --- | --- |
|
|
105
|
+
| OpenAI-compatible | `/provider` or env vars | Works with OpenAI, OpenRouter, DeepSeek, Groq, Mistral, LM Studio, and other compatible `/v1` servers |
|
|
106
|
+
| Gemini | `/provider` or env vars | Supports API key, access token, or local ADC workflow on current `main` |
|
|
107
|
+
| GitHub Models | `/onboard-github` | Interactive onboarding with saved credentials |
|
|
108
|
+
| Codex | `/provider` | Uses existing Codex credentials when available |
|
|
109
|
+
| Ollama | `/provider` or env vars | Local inference with no API key |
|
|
110
|
+
| Atomic Chat | advanced setup | Local Apple Silicon backend |
|
|
111
|
+
| Bedrock / Vertex / Foundry | env vars | Additional provider integrations for supported environments |
|
|
112
|
+
|
|
113
|
+
## What Works
|
|
114
|
+
|
|
115
|
+
- **Tool-driven coding workflows**: Bash, file read/write/edit, grep, glob, agents, tasks, MCP, and slash commands
|
|
116
|
+
- **Streaming responses**: Real-time token output and tool progress
|
|
117
|
+
- **Tool calling**: Multi-step tool loops with model calls, tool execution, and follow-up responses
|
|
118
|
+
- **Images**: URL and base64 image inputs for providers that support vision
|
|
119
|
+
- **Provider profiles**: Guided setup plus saved `.orbit-profile.json` support
|
|
120
|
+
- **Local and remote model backends**: Cloud APIs, local servers, and Apple Silicon local inference
|
|
121
|
+
|
|
122
|
+
## Provider Notes
|
|
123
|
+
|
|
124
|
+
Orbit supports multiple providers, but behavior is not identical across all of them.
|
|
125
|
+
|
|
126
|
+
- Anthropic-specific features may not exist on other providers
|
|
127
|
+
- Tool quality depends heavily on the selected model
|
|
128
|
+
- Smaller local models can struggle with long multi-step tool flows
|
|
129
|
+
- Some providers impose lower output caps than the CLI defaults, and Orbit adapts where possible
|
|
130
|
+
|
|
131
|
+
For best results, use models with strong tool/function calling support.
|
|
132
|
+
|
|
133
|
+
## Agent Routing
|
|
134
|
+
|
|
135
|
+
Orbit can route different agents to different models through settings-based routing. This is useful for cost optimization or splitting work by model strength.
|
|
136
|
+
|
|
137
|
+
Add to `~/.orbit/settings.json`:
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"agentModels": {
|
|
142
|
+
"deepseek-chat": {
|
|
143
|
+
"base_url": "https://api.deepseek.com/v1",
|
|
144
|
+
"api_key": "sk-your-key"
|
|
145
|
+
},
|
|
146
|
+
"gpt-4o": {
|
|
147
|
+
"base_url": "https://api.openai.com/v1",
|
|
148
|
+
"api_key": "sk-your-key"
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
"agentRouting": {
|
|
152
|
+
"Explore": "deepseek-chat",
|
|
153
|
+
"Plan": "gpt-4o",
|
|
154
|
+
"general-purpose": "gpt-4o",
|
|
155
|
+
"frontend-dev": "deepseek-chat",
|
|
156
|
+
"default": "gpt-4o"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
When no routing match is found, the global provider remains the fallback.
|
|
162
|
+
|
|
163
|
+
> **Note:** `api_key` values in `settings.json` are stored in plaintext. Keep this file private and do not commit it to version control.
|
|
164
|
+
|
|
165
|
+
## Web Search and Fetch
|
|
166
|
+
|
|
167
|
+
By default, `WebSearch` works on non-Anthropic models using DuckDuckGo. This gives GPT-4o, DeepSeek, Gemini, Ollama, and other OpenAI-compatible providers a free web search path out of the box.
|
|
168
|
+
|
|
169
|
+
> **Note:** DuckDuckGo fallback works by scraping search results and may be rate-limited, blocked, or subject to DuckDuckGo's Terms of Service. If you want a more reliable supported option, configure Firecrawl.
|
|
170
|
+
|
|
171
|
+
For Anthropic-native backends and Codex responses, Orbit keeps the native provider web search behavior.
|
|
172
|
+
|
|
173
|
+
`WebFetch` works, but its basic HTTP plus HTML-to-markdown path can still fail on JavaScript-rendered sites or sites that block plain HTTP requests.
|
|
174
|
+
|
|
175
|
+
Set a [Firecrawl](https://firecrawl.dev) API key if you want Firecrawl-powered search/fetch behavior:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
export FIRECRAWL_API_KEY=your-key-here
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
With Firecrawl enabled:
|
|
182
|
+
|
|
183
|
+
- `WebSearch` can use Firecrawl's search API while DuckDuckGo remains the default free path for non-Orbit models
|
|
184
|
+
- `WebFetch` uses Firecrawl's scrape endpoint instead of raw HTTP, handling JS-rendered pages correctly
|
|
185
|
+
|
|
186
|
+
Free tier at [firecrawl.dev](https://firecrawl.dev) includes 500 credits. The key is optional.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Headless gRPC Server
|
|
191
|
+
|
|
192
|
+
Orbit can be run as a headless gRPC service, allowing you to integrate its agentic capabilities (tools, bash, file editing) into other applications, CI/CD pipelines, or custom user interfaces. The server uses bidirectional streaming to send real-time text chunks, tool calls, and request permissions for sensitive commands.
|
|
193
|
+
|
|
194
|
+
### 1. Start the gRPC Server
|
|
195
|
+
|
|
196
|
+
Start the core engine as a gRPC service on `localhost:50051`:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
npm run dev:grpc
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
#### Configuration
|
|
203
|
+
|
|
204
|
+
| Variable | Default | Description |
|
|
205
|
+
|-----------|-------------|------------------------------------------------|
|
|
206
|
+
| `GRPC_PORT` | `50051` | Port the gRPC server listens on |
|
|
207
|
+
| `GRPC_HOST` | `localhost` | Bind address. Use `0.0.0.0` to expose on all interfaces (not recommended without authentication) |
|
|
208
|
+
|
|
209
|
+
### 2. Run the Test CLI Client
|
|
210
|
+
|
|
211
|
+
We provide a lightweight CLI client that communicates exclusively over gRPC. It acts just like the main interactive CLI, rendering colors, streaming tokens, and prompting you for tool permissions (y/n) via the gRPC `action_required` event.
|
|
212
|
+
|
|
213
|
+
In a separate terminal, run:
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
npm run dev:grpc:cli
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
*Note: The gRPC definitions are located in `src/proto/orbit.proto`. You can use this file to generate clients in Python, Go, Rust, or any other language.*
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Source Build And Local Development
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
bun install
|
|
227
|
+
bun run build
|
|
228
|
+
node dist/cli.mjs
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Helpful commands:
|
|
232
|
+
|
|
233
|
+
- `bun run dev`
|
|
234
|
+
- `bun test`
|
|
235
|
+
- `bun run test:coverage`
|
|
236
|
+
- `bun run security:pr-scan -- --base origin/main`
|
|
237
|
+
- `bun run smoke`
|
|
238
|
+
- `bun run doctor:runtime`
|
|
239
|
+
- `bun run verify:privacy`
|
|
240
|
+
- focused `bun test ...` runs for the areas you touch
|
|
241
|
+
|
|
242
|
+
## Testing And Coverage
|
|
243
|
+
|
|
244
|
+
Orbit uses Bun's built-in test runner for unit tests.
|
|
245
|
+
|
|
246
|
+
Run the full unit suite:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
bun test
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Generate unit test coverage:
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
bun run test:coverage
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Open the visual coverage report:
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
open coverage/index.html
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
If you already have `coverage/lcov.info` and only want to rebuild the UI:
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
bun run test:coverage:ui
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Use focused test runs when you only touch one area:
|
|
271
|
+
|
|
272
|
+
- `bun run test:provider`
|
|
273
|
+
- `bun run test:provider-recommendation`
|
|
274
|
+
- `bun test path/to/file.test.ts`
|
|
275
|
+
|
|
276
|
+
Recommended contributor validation before opening a PR:
|
|
277
|
+
|
|
278
|
+
- `bun run build`
|
|
279
|
+
- `bun run smoke`
|
|
280
|
+
- `bun run test:coverage` for broader unit coverage when your change affects shared runtime or provider logic
|
|
281
|
+
- focused `bun test ...` runs for the files and flows you changed
|
|
282
|
+
|
|
283
|
+
Coverage output is written to `coverage/lcov.info`, and Orbit also generates a git-activity-style heatmap at `coverage/index.html`.
|
|
284
|
+
## Repository Structure
|
|
285
|
+
|
|
286
|
+
- `src/` - core CLI/runtime
|
|
287
|
+
- `scripts/` - build, verification, and maintenance scripts
|
|
288
|
+
- `docs/` - setup, contributor, and project documentation
|
|
289
|
+
- `python/` - standalone Python helpers and their tests
|
|
290
|
+
- `vscode-extension/orbit-vscode/` - VS Code extension
|
|
291
|
+
- `.github/` - repo automation, templates, and CI configuration
|
|
292
|
+
- `bin/` - CLI launcher entrypoints
|
|
293
|
+
|
|
294
|
+
## VS Code Extension
|
|
295
|
+
|
|
296
|
+
The repo includes a VS Code extension in [`vscode-extension/orbit-vscode`](vscode-extension/orbit-vscode) for Orbit launch integration, provider-aware control-center UI, and theme support.
|
|
297
|
+
|
|
298
|
+
## Security
|
|
299
|
+
|
|
300
|
+
If you believe you found a security issue, see [SECURITY.md](SECURITY.md).
|
|
301
|
+
|
|
302
|
+
## Community
|
|
303
|
+
|
|
304
|
+
- Use [GitHub Discussions](https://github.com/Gitlawb/orbit/discussions) for Q&A, ideas, and community conversation
|
|
305
|
+
- Use [GitHub Issues](https://github.com/Gitlawb/orbit/issues) for confirmed bugs and actionable feature work
|
|
306
|
+
|
|
307
|
+
## Contributing
|
|
308
|
+
|
|
309
|
+
Contributions are welcome.
|
|
310
|
+
|
|
311
|
+
For larger changes, open an issue first so the scope is clear before implementation. Helpful validation commands include:
|
|
312
|
+
|
|
313
|
+
- `bun run build`
|
|
314
|
+
- `bun run test:coverage`
|
|
315
|
+
- `bun run smoke`
|
|
316
|
+
- focused `bun test ...` runs for touched areas
|
|
317
|
+
|
|
318
|
+
## Disclaimer
|
|
319
|
+
|
|
320
|
+
Orbit is an independent community project and is not affiliated with, endorsed by, or sponsored by Anthropic.
|
|
321
|
+
|
|
322
|
+
Orbit originated from the Orbit Code codebase and has since been substantially modified to support multiple providers and open use. "Orbit" and "Orbit Code" are trademarks of Anthropic PBC. See [LICENSE](LICENSE) for details.
|
|
323
|
+
|
|
324
|
+
## License
|
|
325
|
+
|
|
326
|
+
See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Audit & Logging
|
|
2
|
+
|
|
3
|
+
The framework provides configuration-driven audit logging with field masking. Every flow should audit both the incoming request and outgoing response.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Components
|
|
8
|
+
|
|
9
|
+
| Component | Type | Purpose |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| `AuditPoint.esql` | esql | Prepare audit message (11KB) |
|
|
12
|
+
| `AuditPoint_PrepareOutgoingAuditRequest.esql` | esql | Prepare outgoing-specific audit data |
|
|
13
|
+
| `LogAudit.subflow` | subflow | Log incoming request |
|
|
14
|
+
| `LogOutgoingAudit.subflow` | subflow | Log outgoing response |
|
|
15
|
+
| `LogError.subflow` | subflow | Log error event |
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## AuditPoint.esql
|
|
20
|
+
|
|
21
|
+
**Purpose**: Reads config from `Environment.Properties`, builds the audit XML structure, and routes to the audit queue.
|
|
22
|
+
|
|
23
|
+
**Key behavior**:
|
|
24
|
+
- Reads `AuditEnabled` and `LogEnabled` flags — does nothing if both are FALSE
|
|
25
|
+
- Extracts field values using XPath expressions defined in `value1`–`value10` properties
|
|
26
|
+
- Masks fields listed in `maskingIn` / `maskingOut` using EVAL (dynamic path resolution)
|
|
27
|
+
- Adds flow metadata: broker name, execution group, flow name, timestamps
|
|
28
|
+
|
|
29
|
+
**Masking**: Fields listed in `maskingIn`/`maskingOut` have their values replaced with `****` before logging. Example masked field: `*.Header.ChannelUserInfo.UserPassword`
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Standard Audit Structure
|
|
34
|
+
|
|
35
|
+
```xml
|
|
36
|
+
<Audit>
|
|
37
|
+
<auditHeader>
|
|
38
|
+
<audit>TRUE</audit>
|
|
39
|
+
<log>TRUE</log>
|
|
40
|
+
<retryCount>0</retryCount>
|
|
41
|
+
<requestId>unique-id</requestId>
|
|
42
|
+
<timestamp>2024-01-01T00:00:00.000Z</timestamp>
|
|
43
|
+
<flowStart>TRUE</flowStart> <!-- TRUE for incoming, FALSE for outgoing -->
|
|
44
|
+
<channelId>CHANNEL</channelId>
|
|
45
|
+
<userName>user</userName>
|
|
46
|
+
<serviceCode>SVC001</serviceCode>
|
|
47
|
+
<sessionId>session</sessionId>
|
|
48
|
+
<applicationName>AppName</applicationName>
|
|
49
|
+
<messageFlowName>FlowName</messageFlowName>
|
|
50
|
+
<brokerName>BrokerName</brokerName>
|
|
51
|
+
<executionGroupName>ExecGroup</executionGroupName>
|
|
52
|
+
<logType>Information</logType> <!-- Information | Error -->
|
|
53
|
+
<key1>CUSTOMER.NO</key1> <!-- label from config -->
|
|
54
|
+
<value1>12345678</value1> <!-- extracted from message -->
|
|
55
|
+
<!-- key2-key10, value2-value10 -->
|
|
56
|
+
<message><!-- full message body if LogEnabled=TRUE --></message>
|
|
57
|
+
</auditHeader>
|
|
58
|
+
</Audit>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Configuration (Properties XML)
|
|
64
|
+
|
|
65
|
+
Under the `Logging` group for each flow:
|
|
66
|
+
|
|
67
|
+
```xml
|
|
68
|
+
<group name="Logging">
|
|
69
|
+
<property name="LogEnabled" value="TRUE" />
|
|
70
|
+
<property name="AuditEnabled" value="TRUE" />
|
|
71
|
+
<property name="MaskingEnabled" value="TRUE" />
|
|
72
|
+
|
|
73
|
+
<!-- Audit key-value pairs: up to 10 fields to extract from message -->
|
|
74
|
+
<property name="key1" value="CUSTOMER.NO" />
|
|
75
|
+
<property name="value1" value="*.Body.CustomerId" />
|
|
76
|
+
<property name="key2" value="ACCOUNT.NO" />
|
|
77
|
+
<property name="value2" value="*.Body.AccountNumber" />
|
|
78
|
+
|
|
79
|
+
<!-- Fields to mask in incoming/outgoing audit -->
|
|
80
|
+
<property name="maskingIn">
|
|
81
|
+
<value>*.Header.ChannelUserInfo.UserPassword</value>
|
|
82
|
+
</property>
|
|
83
|
+
<property name="maskingOut">
|
|
84
|
+
<value>*.Header.ChannelUserInfo.UserPassword</value>
|
|
85
|
+
</property>
|
|
86
|
+
</group>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Notes**:
|
|
90
|
+
- `key1`–`key10`: human-readable label for audit records
|
|
91
|
+
- `value1`–`value10`: XPath-style path into the message tree to extract the value
|
|
92
|
+
- `maskingIn`: mask these paths in the incoming request audit
|
|
93
|
+
- `maskingOut`: mask these paths in the outgoing response audit
|
|
94
|
+
- Always mask `*.Header.ChannelUserInfo.UserPassword` at minimum
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Wiring in a Flow
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
[Input Adapter]
|
|
102
|
+
↓
|
|
103
|
+
PropertyReader ← must run first to load config
|
|
104
|
+
↓
|
|
105
|
+
LogAudit ← log incoming request (flowStart=TRUE)
|
|
106
|
+
↓
|
|
107
|
+
[... flow logic ...]
|
|
108
|
+
↓
|
|
109
|
+
LogOutgoingAudit ← log outgoing response (flowStart=FALSE)
|
|
110
|
+
↓
|
|
111
|
+
[Output Adapter]
|
|
112
|
+
|
|
113
|
+
Error path:
|
|
114
|
+
[Any failure] → ErrorHandler → LogError → [dead letter]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## ESQL Access Pattern for Audit Flags
|
|
120
|
+
|
|
121
|
+
```esql
|
|
122
|
+
-- Check if audit is enabled before doing audit work
|
|
123
|
+
DECLARE auditEnabled BOOLEAN;
|
|
124
|
+
SET auditEnabled = Environment.Properties.{ApplicationLabel}.{flowName}.Logging.AuditEnabled;
|
|
125
|
+
|
|
126
|
+
IF auditEnabled = TRUE THEN
|
|
127
|
+
-- proceed with audit
|
|
128
|
+
END IF;
|
|
129
|
+
```
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Common Utilities (CommonUtils.esql)
|
|
2
|
+
|
|
3
|
+
`CommonUtils.esql` is a 47KB shared ESQL library containing constants, queue routing, correlation ID generation, database access, and utility functions. Include it in every flow that needs routing or utility functions.
|
|
4
|
+
|
|
5
|
+
**Location**: `Qiwa/Framework/Lib/CommonUtils.esql`
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Error Code Constants
|
|
10
|
+
|
|
11
|
+
```esql
|
|
12
|
+
-- Always use these constants, never hardcode error codes
|
|
13
|
+
DECLARE ESB_SUCCESS_RESPONSE_CODE CONSTANT CHAR '00000000';
|
|
14
|
+
DECLARE ESB_RUNTIME_TECHNICAL_ERROR_CODE CONSTANT CHAR '99999999';
|
|
15
|
+
DECLARE ESB_MIDDLEWARE_DATABASE_ERROR_RESPONSE_CODE CONSTANT CHAR 'E0199998';
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Backend-specific error code ranges are also defined — read `ErrorHandler.esql` for the full list per backend system.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Key Functions
|
|
23
|
+
|
|
24
|
+
### Queue Routing
|
|
25
|
+
|
|
26
|
+
```esql
|
|
27
|
+
-- Set request and response queues based on ServiceCode from message header
|
|
28
|
+
-- Reads from MCR_CHANNESBFUNC_TBL database table
|
|
29
|
+
CALL SetQueues(IN serviceCode CHARACTER, OUT requestQueue CHARACTER, OUT responseQueue CHARACTER);
|
|
30
|
+
|
|
31
|
+
-- Get output queue for a specific channel
|
|
32
|
+
CALL getChannelOutQueue(IN channelId CHARACTER, IN serviceCode CHARACTER, OUT outQueue CHARACTER);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Correlation ID
|
|
36
|
+
|
|
37
|
+
```esql
|
|
38
|
+
-- Generate a unique correlation ID for tracking this message across systems
|
|
39
|
+
CALL getChannelCorrelationID(IN channelId CHARACTER, IN sessionId CHARACTER, OUT correlationId CHARACTER);
|
|
40
|
+
|
|
41
|
+
-- Get correlation ID from the ESB channel
|
|
42
|
+
CALL getEsbChannelId(IN channelId CHARACTER, OUT esbChannelId CHARACTER);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Timestamp
|
|
46
|
+
|
|
47
|
+
```esql
|
|
48
|
+
-- Get formatted timestamp string (ISO 8601)
|
|
49
|
+
CALL GetTimestampFormat(OUT timestamp CHARACTER);
|
|
50
|
+
-- Returns: '2024-01-15T14:30:00.000Z'
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Database Access
|
|
54
|
+
|
|
55
|
+
```esql
|
|
56
|
+
-- Execute a SQL query with error handling
|
|
57
|
+
-- DSN is configured at the integration node level
|
|
58
|
+
CALL MCRDB_Selection(IN sqlQuery CHARACTER, OUT resultSet ROW);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Flow Name Utility
|
|
62
|
+
|
|
63
|
+
```esql
|
|
64
|
+
-- Strip schema prefix from flow name for use in property lookups
|
|
65
|
+
CALL getFlowNameWithouSchema(IN fullFlowName CHARACTER, OUT flowName CHARACTER);
|
|
66
|
+
-- Input: 'Qiwa.BS_Account.GetAccountDetails'
|
|
67
|
+
-- Output: 'GetAccountDetails'
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Response Codes
|
|
71
|
+
|
|
72
|
+
```esql
|
|
73
|
+
-- Get the standard success code
|
|
74
|
+
CALL GetESBSuccessCode(OUT successCode CHARACTER);
|
|
75
|
+
-- Returns: '00000000'
|
|
76
|
+
|
|
77
|
+
-- Get default character set
|
|
78
|
+
CALL GetDefaultCharacterSet(OUT charset CHARACTER);
|
|
79
|
+
-- Returns: 'UTF-8'
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Shared Row (In-Memory Cache)
|
|
85
|
+
|
|
86
|
+
```esql
|
|
87
|
+
SHARED ROW CacheQueueTable;
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`CacheQueueTable` is used by `SetQueues()` to cache queue routing lookups. It persists across message invocations within the same execution group — do not clear it manually.
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Database Tables Referenced
|
|
95
|
+
|
|
96
|
+
| Table | Columns | Purpose |
|
|
97
|
+
|---|---|---|
|
|
98
|
+
| `MCR_CHANNESBFUNC_TBL` | `ESBFUNCID`, `ESBFUNCNAME`, `REQUEST_QUEUE_NAME`, `RESPONSE_QUEUE_NAME` | Queue routing by service code |
|
|
99
|
+
| `MCR_CHANNAUTH_TBL` | `CHANNID`, `ESBFUNCID` | Channel authorization check |
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Usage Pattern in ESQL
|
|
104
|
+
|
|
105
|
+
```esql
|
|
106
|
+
-- At top of your ESQL module, no explicit import needed —
|
|
107
|
+
-- CommonUtils is part of the shared library automatically
|
|
108
|
+
|
|
109
|
+
-- Example: get queues for this service
|
|
110
|
+
DECLARE reqQueue CHARACTER;
|
|
111
|
+
DECLARE resQueue CHARACTER;
|
|
112
|
+
DECLARE serviceCode CHARACTER;
|
|
113
|
+
SET serviceCode = InputRoot.XMLNSC.Root.Header.ServiceCode;
|
|
114
|
+
CALL SetQueues(serviceCode, reqQueue, resQueue);
|
|
115
|
+
|
|
116
|
+
-- Set output destination
|
|
117
|
+
SET Environment.Destination.MQ.DestinationData.queueName = reqQueue;
|
|
118
|
+
|
|
119
|
+
-- Example: generate correlation ID
|
|
120
|
+
DECLARE corrId CHARACTER;
|
|
121
|
+
CALL getChannelCorrelationID(
|
|
122
|
+
InputRoot.XMLNSC.Root.Header.ChannelId,
|
|
123
|
+
InputRoot.XMLNSC.Root.Header.SessionId,
|
|
124
|
+
corrId
|
|
125
|
+
);
|
|
126
|
+
SET OutputRoot.MQMD.CorrelId = CAST(corrId AS BLOB CCSID 1208);
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Standard Header Field Paths
|
|
132
|
+
|
|
133
|
+
```esql
|
|
134
|
+
-- Standard paths for common header fields
|
|
135
|
+
InputRoot.XMLNSC.Root.Header.TransactionId
|
|
136
|
+
InputRoot.XMLNSC.Root.Header.ChannelId
|
|
137
|
+
InputRoot.XMLNSC.Root.Header.ServiceCode
|
|
138
|
+
InputRoot.XMLNSC.Root.Header.SessionId
|
|
139
|
+
InputRoot.XMLNSC.Root.Header.RequestTime
|
|
140
|
+
InputRoot.XMLNSC.Root.Header.ChannelUserInfo.UserName
|
|
141
|
+
InputRoot.XMLNSC.Root.Header.ChannelUserInfo.UserPassword -- ALWAYS MASK
|
|
142
|
+
InputRoot.XMLNSC.Root.Header.ResponseStatus.Code
|
|
143
|
+
InputRoot.XMLNSC.Root.Header.ResponseStatus.Status
|
|
144
|
+
InputRoot.XMLNSC.Root.Header.ResponseStatus.EnglishMsg
|
|
145
|
+
InputRoot.XMLNSC.Root.Body -- service-specific data
|
|
146
|
+
```
|