@j-tech-sa/taac-j-agent 0.0.0-stage → 0.4.3
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 +161 -0
- package/NOTICE +19 -0
- package/README.md +114 -2
- package/dist/client.d.ts +157 -0
- package/dist/client.js +644 -0
- package/dist/dispatch.d.ts +44 -0
- package/dist/dispatch.js +854 -0
- package/dist/eject.d.ts +22 -0
- package/dist/eject.js +128 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +19 -0
- package/dist/router.d.ts +35 -0
- package/dist/router.js +207 -0
- package/dist/seam.d.ts +55 -0
- package/dist/seam.js +285 -0
- package/dist/server.d.ts +143 -0
- package/dist/server.js +842 -0
- package/dist/session.d.ts +97 -0
- package/dist/session.js +390 -0
- package/dist/types.d.ts +282 -0
- package/dist/types.js +8 -0
- package/package.json +60 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner.
|
|
54
|
+
|
|
55
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
56
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
57
|
+
subsequently incorporated within the Work.
|
|
58
|
+
|
|
59
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
60
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
61
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
62
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
63
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
64
|
+
Work and such Derivative Works in Source or Object form.
|
|
65
|
+
|
|
66
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
(except as stated in this section) patent license to make, have made,
|
|
70
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
71
|
+
where such license applies only to those patent claims licensable
|
|
72
|
+
by such Contributor that are necessarily infringed by their
|
|
73
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
74
|
+
with the Work to which such Contribution(s) was submitted.
|
|
75
|
+
|
|
76
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
77
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
78
|
+
modifications, and in Source or Object form, provided that You
|
|
79
|
+
meet the following conditions:
|
|
80
|
+
|
|
81
|
+
(a) You must give any other recipients of the Work or
|
|
82
|
+
Derivative Works a copy of this License; and
|
|
83
|
+
|
|
84
|
+
(b) You must cause any modified files to carry prominent notices
|
|
85
|
+
stating that You changed the files; and
|
|
86
|
+
|
|
87
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
88
|
+
that You distribute, all copyright, patent, trademark, and
|
|
89
|
+
attribution notices from the Source form of the Work,
|
|
90
|
+
excluding those notices that do not pertain to any part of
|
|
91
|
+
the Derivative Works; and
|
|
92
|
+
|
|
93
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
94
|
+
distribution, then any Derivative Works that You distribute must
|
|
95
|
+
include a readable copy of the attribution notices contained
|
|
96
|
+
within such NOTICE file.
|
|
97
|
+
|
|
98
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
99
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
100
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
101
|
+
this License, without any additional terms or conditions.
|
|
102
|
+
|
|
103
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
104
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
105
|
+
except as required for reasonable and customary use in describing the
|
|
106
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
107
|
+
|
|
108
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
109
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
110
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
111
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
112
|
+
implied, including, without limitation, any warranties or conditions
|
|
113
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
114
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
115
|
+
appropriateness of using or redistributing the Work and assume any
|
|
116
|
+
risks associated with Your exercise of permissions under this License.
|
|
117
|
+
|
|
118
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
119
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
120
|
+
unless required by applicable law (such as deliberate and grossly
|
|
121
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
122
|
+
liable to You for damages, including any direct, indirect, special,
|
|
123
|
+
incidental, or consequential damages of any character arising as a
|
|
124
|
+
result of this License or out of the use or inability to use the
|
|
125
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
126
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
127
|
+
other commercial damages or losses), even if such Contributor
|
|
128
|
+
has been advised of the possibility of such damages.
|
|
129
|
+
|
|
130
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
131
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
132
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
133
|
+
or other liability obligations and/or rights consistent with this
|
|
134
|
+
License.
|
|
135
|
+
|
|
136
|
+
END OF TERMS AND CONDITIONS
|
|
137
|
+
|
|
138
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
139
|
+
|
|
140
|
+
To apply the Apache License to your work, attach the following
|
|
141
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
142
|
+
replaced with your own identifying information. (Don't include
|
|
143
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
144
|
+
comment syntax for the file format. We also recommend that a
|
|
145
|
+
file or class name and description of purpose be included on the
|
|
146
|
+
same "printed page" as the copyright notice for easier
|
|
147
|
+
identification within third-party archives.
|
|
148
|
+
|
|
149
|
+
Copyright 2026 J-Tech (Saudi Arabia)
|
|
150
|
+
|
|
151
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
152
|
+
you may not use this file except in compliance with the License.
|
|
153
|
+
You may obtain a copy of the License at
|
|
154
|
+
|
|
155
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
156
|
+
|
|
157
|
+
Unless required by applicable law or agreed to in writing, software
|
|
158
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
159
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
160
|
+
See the License for the specific language governing permissions and
|
|
161
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
@j-tech-sa/taac-j-agent (J-TaaC Resident UDS Adapter)
|
|
2
|
+
Copyright 2026 J-Tech (Saudi Arabia)
|
|
3
|
+
|
|
4
|
+
This product includes software developed by J-Tech (Saudi Arabia)
|
|
5
|
+
(https://github.com/J-Tech-sa/J-TaaC).
|
|
6
|
+
|
|
7
|
+
Brand & Trademark Notice (Apache License, Version 2.0, Section 6):
|
|
8
|
+
The marks and names "J-Tech", "J-TaaC", "J-Decision", "J-Agent", and "J-Star"
|
|
9
|
+
are trademarks/brand identifiers of J-Tech (Saudi Arabia)
|
|
10
|
+
and must always be written in English Latin letters across all code,
|
|
11
|
+
documentation, user interfaces, receipts, and logs. The Apache-2.0 License
|
|
12
|
+
does not grant permission to use these trade names or trademarks except as
|
|
13
|
+
required for reasonable and customary use in describing the origin of the
|
|
14
|
+
Work and reproducing the content of this NOTICE file.
|
|
15
|
+
|
|
16
|
+
Runtime Dependency Notices:
|
|
17
|
+
- @j-tech-sa/taac (Apache-2.0)
|
|
18
|
+
|
|
19
|
+
Third-party runtime dependencies: none (zero third-party runtime dependencies).
|
package/README.md
CHANGED
|
@@ -1,3 +1,115 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@j-tech-sa/taac-j-agent`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **Sub-`0.08 ms` Mode `0660` Unix Domain Socket (`UDS`) wire bridge connecting any standalone `@j-tech-sa/taac` runtime to on-premises `J-Agent` (`12B` – `1T+`) for `$0.00` token COGS and `0.0 B` WAN egress.**
|
|
4
|
+
|
|
5
|
+
`@j-tech-sa/taac-j-agent` provides the authenticated `UDS` server/client, semantic `ToolRouterPort` (`128D` MRL + bilingual `AR/EN` BM25), progressive compact-catalog and on-demand schema hydration seam helpers, and zero-residue clean eject — with **zero runtime dependency** on `J-Agent` being installed.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Key Capabilities & Outcomes
|
|
10
|
+
|
|
11
|
+
- **Standalone Mode `0660` UDS Server & Typed Client (`v0.4.2`):** `ResidentServer<TTools>` and `ResidentClient<TTools>` communicate over newline-delimited JSON (`NDJSON`) on Mode `0660` Unix Domain Sockets (and Windows named pipes) with bounded `maxConnections`, backpressure handling, idle socket timeouts, a `4 MB` `ERR_FRAME_OVERFLOW` ceiling, per-UID `0700` socket directories, `lstatSync` non-symlink checks, and graceful `stop()` frame-queue draining (`75` curated exports with `100%` JSDoc, `0` `export *`).
|
|
12
|
+
- **Dual-Compatible `RFC 8785` JCS + Zero-Downtime Key Rotation (`HMAC-SHA256`):** Validates both flat `SignedSessionEnvelope` and nested `v: 1` `JAgentSignedSessionEnvelope` frames using `crypto.timingSafeEqual` over 32-byte digests with `previousSecrets` zero-downtime secret rotation, `<= 60s` TTL (`5s` skew tolerance), opt-in caller credentials (`forwardCallerCredentials: false` default), and a fail-closed `10,000`-entry `NonceReplayCache` (`403 ERR_REPLAYED_NONCE` / `429 ERR_NONCE_CACHE_SATURATED`).
|
|
13
|
+
- **Tri-Plane Isolation & 4-Tier RBAC:** Enforces `plane-2` (admin/team) and `plane-3` (user) boundaries while rejecting any `plane-1` dispatch with `403_PLANE_ISOLATION_VIOLATION`. `auditor` calls are restricted to read-only `list`, `describe`, and `dryRun` on tools declaring `policy.minRole === 'auditor'` (mutating `execute`/`undo` and higher-role tools fail closed with `403 ERR_RBAC_DENIED`).
|
|
14
|
+
- **`500+` Bilingual & Semantic Routing (`ToolRouterPort`) & Paired Live UDS Proof:** `createMrlProbeToolRouter()` pairs a `128D` Matryoshka cosine probe with automatic bilingual `AR/EN` BM25 fallback (`createBilingualBm25Router()` / `getFilteredZoneACatalog()`), keeping filtered compact slices strictly `< 250` tokens. Verified live on offline `J-Agent B1: 12B` (`FS-04`: `50` bilingual tools, `67`-tok MRL routing, `createResidentServer` over Mode `0660` UDS, bidirectional `pii_ref:<16hex>`, `100%` pass at `0.0 B` WAN / `$0.00` COGS) across `N = 4` paired full-stack scenarios (`16` runs; `12B` `Pass (<= 1 repair)` `0/4 -> 3/4`, `Turn-1 Pass@1` `1/4` on `FS-03` vs `0/4` Control, upfront guide `-43.30%`, `meanPromptTokens` `+237.4%` [`8,249.00 -> 27,834.25`], and wall time `+23.66%` [`267.13 s -> 330.32 s`, `FS-01` `65.22% -> 0%`]), alongside cooperative UDS mid-progress cancellation (`499 ERR_ABORTED`).
|
|
15
|
+
- **Zero-Residue Clean Eject & Seam Helpers:** `getZoneACatalog`, `resolveDeferredTool` (`grammar_lazy: true`), `wrapUntrustedResult` (`<tool_result trust="untrusted">` with `512`-token cap), `exportGoldenTestFixtures`, `isTrajectoryEligible`, `bindDomainPortToUds`, and `ejectResidentBridge()` (validates `/^[a-zA-Z0-9_-]+$/` and strictly preserves shared workstation SHM segments).
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Socket Separation Convention
|
|
20
|
+
|
|
21
|
+
| Direction | Helper | Default Path |
|
|
22
|
+
| :--- | :--- | :--- |
|
|
23
|
+
| **Forward** (`J-Agent` -> `J-TaaC` App `ResidentServer`) | `resolveTaacAppSocketPath(appId, runtimeDir?)` | `${runtimeDir \|\| XDG_RUNTIME_DIR \|\| '/tmp/j-taac-<uid>'}/j-taac-app-${appId}.sock` |
|
|
24
|
+
| **Reverse** (`J-TaaC` `bindDomainPortToUds` -> Host Specialists) | `resolveJAgentResidentSocketPath(runtimeDir?)` | `${runtimeDir \|\| XDG_RUNTIME_DIR \|\| '/tmp/j-taac-<uid>'}/j-agent-resident.sock` |
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pnpm add @j-tech-sa/taac-j-agent @j-tech-sa/taac
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
> **Note:** Node.js `>= 22.0.0` server/IPC adapter.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Quickstart: Authenticated UDS Server, Typed Client & MRL Tool Router
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import {
|
|
42
|
+
createResidentServer,
|
|
43
|
+
createResidentClient,
|
|
44
|
+
createMrlProbeToolRouter,
|
|
45
|
+
getFilteredZoneACatalog,
|
|
46
|
+
resolveTaacAppSocketPath,
|
|
47
|
+
ejectResidentBridge,
|
|
48
|
+
} from '@j-tech-sa/taac-j-agent';
|
|
49
|
+
import { runtime, registry, type BillingToolMap } from './tools.js';
|
|
50
|
+
|
|
51
|
+
export async function startResidentBridge(secret: string) {
|
|
52
|
+
// Optional 128D MRL semantic router (falls back cleanly to bilingual AR/EN BM25 on error)
|
|
53
|
+
const toolRouter = createMrlProbeToolRouter({
|
|
54
|
+
dimensions: 128,
|
|
55
|
+
embed: async (text) => new Float32Array(128).fill(text.length > 0 ? 1 : 0),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const filteredCatalog = await getFilteredZoneACatalog(registry, 'payout iban', {
|
|
59
|
+
router: toolRouter,
|
|
60
|
+
maxTokens: 240,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const socketPath = resolveTaacAppSocketPath('billing-app');
|
|
64
|
+
|
|
65
|
+
// 1. Start Mode 0660 UDS server accepting flat & nested J-Agent v:1 frames
|
|
66
|
+
const server = await createResidentServer<BillingToolMap>({
|
|
67
|
+
runtime,
|
|
68
|
+
secret,
|
|
69
|
+
socketPath,
|
|
70
|
+
toolRouter,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// 2. Connect zero-byte typed ResidentClient
|
|
74
|
+
const client = await createResidentClient<BillingToolMap>({
|
|
75
|
+
socketPath: server.path,
|
|
76
|
+
secret,
|
|
77
|
+
tenantId: 'tenant-prod',
|
|
78
|
+
callerId: 'agent-worker-1',
|
|
79
|
+
callerRole: 'team',
|
|
80
|
+
plane: 'plane-2',
|
|
81
|
+
wireFormat: 'flat',
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const input = { accountId: 'acct-101', iban: 'SA4420000001234567891234' };
|
|
85
|
+
const preview = await client.dryRunTool('billing.update_payout_iban', input);
|
|
86
|
+
const execRes = await client.executeTool('billing.update_payout_iban', input, {
|
|
87
|
+
dryRunApprovalToken: preview.dryRunApprovalToken,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
if (execRes.receipt?.undoToken) {
|
|
91
|
+
await client.undoToken(execRes.receipt.undoToken);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// 3. Multi-tool composite saga over Mode 0660 UDS
|
|
95
|
+
const txRes = await client.executeTransaction(
|
|
96
|
+
[{ toolId: 'billing.update_payout_iban', input }],
|
|
97
|
+
{ autoDryRun: true, idempotencyKey: 'tx-billing-001' }
|
|
98
|
+
);
|
|
99
|
+
if (txRes.groupUndoToken) {
|
|
100
|
+
await client.undoToken(txRes.groupUndoToken);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
await client.close();
|
|
104
|
+
await server.close();
|
|
105
|
+
ejectResidentBridge({ hostId: 'billing-app', socketPath });
|
|
106
|
+
|
|
107
|
+
return { filteredCatalog };
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## License & Repository
|
|
114
|
+
|
|
115
|
+
Licensed under **`Apache-2.0`** ([`./LICENSE`](./LICENSE) · [`./NOTICE`](./NOTICE)). Built in Saudi Arabia by **`J-Tech`** (`https://github.com/J-Tech-sa/J-TaaC`).
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* J-Tech Tools-as-a-Core (J-TaaC) — Scale 2 Resident UDS Client
|
|
3
|
+
*
|
|
4
|
+
* Provides a high-performance Unix Domain Socket client with chunk-list NDJSON streaming framing,
|
|
5
|
+
* maxMessageBytes protection, request/response correlation by message ID, configurable timeouts,
|
|
6
|
+
* and typed convenience helpers.
|
|
7
|
+
*/
|
|
8
|
+
import { type CallerCredentialsSnapshot, type ExecutionPlane, type InferToolMap, type Role, type ToolIds, type ToolInputById, type ToolOutputById, type ToolProgressEvent, type TransactionCommitReceipt, type TypedTransactionBatchStep } from '@j-tech-sa/taac';
|
|
9
|
+
import type { CompatibleResidentIpcMessage, CompatibleSessionEnvelope, JAgentSignedSessionEnvelope, ResidentClientOptions, ResidentIpcResponse, SignedSessionEnvelope } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Low-level transport options accepted by `ResidentClient.send`.
|
|
12
|
+
*/
|
|
13
|
+
export interface ResidentSendOptions {
|
|
14
|
+
readonly timeoutMs?: number | undefined;
|
|
15
|
+
readonly signal?: AbortSignal | undefined;
|
|
16
|
+
readonly onProgress?: ((event: ToolProgressEvent) => void) | undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Per-call envelope, RBAC, approval, idempotency, and credential options for typed `ResidentClient` calls.
|
|
20
|
+
*/
|
|
21
|
+
export interface ResidentDispatchCallOptions extends ResidentSendOptions {
|
|
22
|
+
readonly envelope?: CompatibleSessionEnvelope | undefined;
|
|
23
|
+
readonly plane?: ExecutionPlane | undefined;
|
|
24
|
+
readonly dryRunApprovalToken?: string | undefined;
|
|
25
|
+
readonly idempotencyKey?: string | undefined;
|
|
26
|
+
readonly autoDryRun?: boolean | undefined;
|
|
27
|
+
readonly allowIrreversibleSteps?: boolean | undefined;
|
|
28
|
+
readonly callerRole?: Role | undefined;
|
|
29
|
+
readonly callerId?: string | undefined;
|
|
30
|
+
readonly tenantId?: string | undefined;
|
|
31
|
+
readonly callerCredentials?: CallerCredentialsSnapshot | undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Normalizes inbound UDS JSON responses from either J-TaaC `ResidentServer`
|
|
35
|
+
* or J-Agent `ResidentAgenticBridge` (`{ id, ok, result, error }`).
|
|
36
|
+
*/
|
|
37
|
+
export declare function normalizeResidentResponse(raw: unknown): ResidentIpcResponse;
|
|
38
|
+
/**
|
|
39
|
+
* Typed Unix Domain Socket IPC client for communicating with a `ResidentServer` or J-Agent Resident bridge using NDJSON framing.
|
|
40
|
+
*/
|
|
41
|
+
export declare class ResidentClient<TTools = any> {
|
|
42
|
+
/** Phantom type carrier enabling `InferToolMap<typeof client>`. */
|
|
43
|
+
readonly __toolMap?: InferToolMap<TTools> | undefined;
|
|
44
|
+
private socket;
|
|
45
|
+
private readonly socketPath;
|
|
46
|
+
private readonly secret?;
|
|
47
|
+
private readonly defaultTimeoutMs;
|
|
48
|
+
private readonly maxMessageBytes;
|
|
49
|
+
/** Default tenant identifier embedded in generated session envelopes. */
|
|
50
|
+
readonly defaultTenantId?: string | undefined;
|
|
51
|
+
/** Default caller identifier embedded in generated session envelopes. */
|
|
52
|
+
readonly defaultCallerId?: string | undefined;
|
|
53
|
+
/** Default caller role embedded in generated session envelopes. */
|
|
54
|
+
readonly defaultCallerRole?: Role | undefined;
|
|
55
|
+
/** Default execution plane embedded in generated session envelopes and dispatches. */
|
|
56
|
+
readonly defaultPlane?: ExecutionPlane | undefined;
|
|
57
|
+
/** Outbound IPC wire framing format (`'flat'` J-TaaC or `'j-agent'` nested). */
|
|
58
|
+
readonly wireFormat: 'flat' | 'j-agent';
|
|
59
|
+
private readonly pendingRequests;
|
|
60
|
+
private pendingChunks;
|
|
61
|
+
private pendingBytes;
|
|
62
|
+
private isConnected;
|
|
63
|
+
private isConnecting;
|
|
64
|
+
private connectPromise;
|
|
65
|
+
private connectReject;
|
|
66
|
+
/**
|
|
67
|
+
* Configures a `ResidentClient` targeting `options.socketPath` (defaulting to `resolveJAgentResidentSocketPath`).
|
|
68
|
+
*/
|
|
69
|
+
constructor(options?: ResidentClientOptions);
|
|
70
|
+
/**
|
|
71
|
+
* Configured UDS socket path or Windows named pipe path targeted by this client.
|
|
72
|
+
*/
|
|
73
|
+
get path(): string;
|
|
74
|
+
/**
|
|
75
|
+
* Indicates whether the client currently holds an active connected socket.
|
|
76
|
+
*/
|
|
77
|
+
get connected(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Connects to the Resident UDS server if not already connected.
|
|
80
|
+
*/
|
|
81
|
+
connect(): Promise<void>;
|
|
82
|
+
private handleClientFrameOverflow;
|
|
83
|
+
private processInboundLine;
|
|
84
|
+
/**
|
|
85
|
+
* Parses incoming NDJSON chunks using chunk-list framing, enforces maxMessageBytes,
|
|
86
|
+
* and fulfills correlated request promises.
|
|
87
|
+
*/
|
|
88
|
+
private handleData;
|
|
89
|
+
private handleClose;
|
|
90
|
+
/**
|
|
91
|
+
* Sends an IPC message (flat J-TaaC or nested J-Agent wire frame) and awaits its correlated response.
|
|
92
|
+
*/
|
|
93
|
+
send<TData = unknown>(message: CompatibleResidentIpcMessage, timeoutOrOptions?: number | ResidentSendOptions): Promise<ResidentIpcResponse<TData>>;
|
|
94
|
+
private resolveCallEnvelope;
|
|
95
|
+
/**
|
|
96
|
+
* Typed zero-runtime-byte `dryRun` invocation using `InferToolMap<TTools>`.
|
|
97
|
+
*/
|
|
98
|
+
dryRunTool<K extends ToolIds<TTools>>(toolId: K, args: ToolInputById<TTools, K>, options?: ResidentDispatchCallOptions): Promise<ResidentIpcResponse>;
|
|
99
|
+
/**
|
|
100
|
+
* Typed zero-runtime-byte `execute` invocation using `InferToolMap<TTools>`.
|
|
101
|
+
*/
|
|
102
|
+
executeTool<K extends ToolIds<TTools>>(toolId: K, args: ToolInputById<TTools, K>, options?: ResidentDispatchCallOptions): Promise<ResidentIpcResponse<ToolOutputById<TTools, K>>>;
|
|
103
|
+
/**
|
|
104
|
+
* Executes a multi-tool composite transaction over Mode 0660 UDS (`groupUndoToken` + `LIFO` rollback).
|
|
105
|
+
*/
|
|
106
|
+
executeTransaction(steps: readonly TypedTransactionBatchStep<TTools>[], options?: ResidentDispatchCallOptions): Promise<ResidentIpcResponse<TransactionCommitReceipt<any>>>;
|
|
107
|
+
/**
|
|
108
|
+
* Reverses a single `undoToken` or composite `groupUndoToken` over Mode 0660 UDS.
|
|
109
|
+
*/
|
|
110
|
+
undoToken(undoToken: string, options?: ResidentDispatchCallOptions): Promise<ResidentIpcResponse>;
|
|
111
|
+
/**
|
|
112
|
+
* Queries the Zone A compact catalog (with optional bilingual / semantic query filtering < 250 tok).
|
|
113
|
+
*/
|
|
114
|
+
listCatalog(options?: ResidentDispatchCallOptions & {
|
|
115
|
+
readonly query?: string | undefined;
|
|
116
|
+
readonly maxTokens?: number | undefined;
|
|
117
|
+
readonly limit?: number | undefined;
|
|
118
|
+
}): Promise<ResidentIpcResponse<string>>;
|
|
119
|
+
/**
|
|
120
|
+
* Sends a ping to verify socket responsiveness.
|
|
121
|
+
*/
|
|
122
|
+
ping(timeoutMs?: number): Promise<ResidentIpcResponse>;
|
|
123
|
+
/**
|
|
124
|
+
* Convenience helper to create a flat J-TaaC signed session envelope using client secret.
|
|
125
|
+
*/
|
|
126
|
+
createEnvelope(params?: {
|
|
127
|
+
sessionId?: string;
|
|
128
|
+
tenantId?: string;
|
|
129
|
+
callerId?: string;
|
|
130
|
+
callerRole?: Role;
|
|
131
|
+
plane?: ExecutionPlane;
|
|
132
|
+
ttlMs?: number;
|
|
133
|
+
metadata?: Record<string, unknown>;
|
|
134
|
+
}): SignedSessionEnvelope;
|
|
135
|
+
/**
|
|
136
|
+
* Convenience helper to create a J-Agent nested `v: 1` signed session envelope using client secret.
|
|
137
|
+
*/
|
|
138
|
+
createJAgentEnvelope(params?: {
|
|
139
|
+
sessionId?: string;
|
|
140
|
+
tenantId?: string;
|
|
141
|
+
userId?: string;
|
|
142
|
+
callerId?: string;
|
|
143
|
+
userRole?: Role;
|
|
144
|
+
callerRole?: Role;
|
|
145
|
+
plane?: ExecutionPlane;
|
|
146
|
+
ttlMs?: number;
|
|
147
|
+
metadata?: Record<string, unknown>;
|
|
148
|
+
}): JAgentSignedSessionEnvelope;
|
|
149
|
+
/**
|
|
150
|
+
* Closes the client connection (including any in-progress connecting socket) and rejects any pending promises.
|
|
151
|
+
*/
|
|
152
|
+
close(): Promise<void>;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Factory helper to create and connect a ResidentClient.
|
|
156
|
+
*/
|
|
157
|
+
export declare function createResidentClient<TTools = any>(options?: ResidentClientOptions): Promise<ResidentClient<TTools>>;
|