@maximem/synap-js-sdk 0.2.2 → 0.2.4
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/.env.example +9 -17
- package/README.md +7 -13
- package/bridge/synap_bridge.py +7 -15
- package/package.json +1 -1
- package/src/bridge-manager.js +2 -3
- package/src/errors.js +0 -36
- package/types/index.d.ts +1 -6
package/.env.example
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
# ==============================
|
|
2
|
-
# REQUIRED
|
|
2
|
+
# REQUIRED
|
|
3
3
|
# ==============================
|
|
4
|
-
#
|
|
5
|
-
|
|
4
|
+
# API key from the Synap dashboard
|
|
5
|
+
SYNAP_API_KEY=
|
|
6
6
|
|
|
7
|
-
#
|
|
8
|
-
|
|
9
|
-
# Usually not required after credentials are already stored at ~/.synap/instances/<instance_id>.
|
|
10
|
-
SYNAP_BOOTSTRAP_TOKEN=
|
|
11
|
-
# Alias accepted by JS bridge (same value as SYNAP_BOOTSTRAP_TOKEN)
|
|
12
|
-
SYNAP_BOOTSTRAP_KEY=
|
|
7
|
+
# Instance ID (from the dashboard)
|
|
8
|
+
SYNAP_INSTANCE_ID=
|
|
13
9
|
|
|
10
|
+
# ==============================
|
|
11
|
+
# SERVER ENDPOINTS
|
|
12
|
+
# ==============================
|
|
14
13
|
# Synap HTTP endpoint
|
|
15
14
|
SYNAP_BASE_URL=http://<synap-api-host>:8000
|
|
16
15
|
|
|
@@ -23,7 +22,7 @@ SYNAP_GRPC_TLS=false
|
|
|
23
22
|
# OPTIONAL
|
|
24
23
|
# ==============================
|
|
25
24
|
# Managed runtime home used by `synap-js-sdk setup`
|
|
26
|
-
SYNAP_JS_SDK_HOME=/Users
|
|
25
|
+
SYNAP_JS_SDK_HOME=/Users/<you>/.synap-js-sdk
|
|
27
26
|
|
|
28
27
|
# Optional: override Python binary used by bridge/runtime
|
|
29
28
|
SYNAP_PYTHON_BIN=python3
|
|
@@ -38,10 +37,3 @@ SYNAP_PYTHON_BOOTSTRAP=python3
|
|
|
38
37
|
# ==============================
|
|
39
38
|
# Enable verbose telemetry event tracing in Python SDK
|
|
40
39
|
SYNAP_TELEMETRY_TRACE_EVENTS=
|
|
41
|
-
|
|
42
|
-
# Optional env-credential mode keys (only if Python SDK credentials_source=\"env\")
|
|
43
|
-
SYNAP_API_KEY=
|
|
44
|
-
SYNAP_REFRESH_TOKEN=
|
|
45
|
-
SYNAP_MTLS_CERT_PATH=
|
|
46
|
-
SYNAP_MTLS_KEY_PATH=
|
|
47
|
-
SYNAP_CLIENT_ID=
|
package/README.md
CHANGED
|
@@ -37,14 +37,13 @@ Windows:
|
|
|
37
37
|
$env:USERPROFILE\.synap-js-sdk\.venv\Scripts\python.exe -c "import maximem_synap; print(maximem_synap.__version__)"
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
## Required Environment
|
|
40
|
+
## Required Environment Variable
|
|
41
41
|
|
|
42
|
-
- `
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
- `SYNAP_GRPC_TLS`
|
|
42
|
+
- `SYNAP_API_KEY` (from the Synap dashboard — Instances → Generate API Key)
|
|
43
|
+
|
|
44
|
+
The SDK uses the default Synap cloud endpoints automatically. `SYNAP_BASE_URL`,
|
|
45
|
+
`SYNAP_GRPC_HOST`, `SYNAP_GRPC_PORT`, and `SYNAP_GRPC_TLS` are only needed for
|
|
46
|
+
advanced overrides such as local development or custom environments.
|
|
48
47
|
|
|
49
48
|
## Quick Start (JavaScript)
|
|
50
49
|
|
|
@@ -52,12 +51,7 @@ $env:USERPROFILE\.synap-js-sdk\.venv\Scripts\python.exe -c "import maximem_synap
|
|
|
52
51
|
const { createClient } = require('@maximem/synap-js-sdk');
|
|
53
52
|
|
|
54
53
|
const synap = createClient({
|
|
55
|
-
|
|
56
|
-
bootstrapToken: process.env.SYNAP_BOOTSTRAP_TOKEN,
|
|
57
|
-
baseUrl: process.env.SYNAP_BASE_URL,
|
|
58
|
-
grpcHost: process.env.SYNAP_GRPC_HOST,
|
|
59
|
-
grpcPort: Number(process.env.SYNAP_GRPC_PORT || 50051),
|
|
60
|
-
grpcUseTls: process.env.SYNAP_GRPC_TLS === 'true',
|
|
54
|
+
apiKey: process.env.SYNAP_API_KEY,
|
|
61
55
|
});
|
|
62
56
|
|
|
63
57
|
async function run() {
|
package/bridge/synap_bridge.py
CHANGED
|
@@ -164,18 +164,14 @@ async def handle_init(params: dict) -> dict:
|
|
|
164
164
|
timings: List[dict] = []
|
|
165
165
|
|
|
166
166
|
instance_id = params.get("instance_id", "")
|
|
167
|
-
|
|
167
|
+
api_key = params.get("api_key")
|
|
168
168
|
|
|
169
169
|
step = time.perf_counter()
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
)
|
|
176
|
-
except TypeError:
|
|
177
|
-
# Backward compatibility with older SDK constructors.
|
|
178
|
-
sdk = MaximemSynapSDK(instance_id=instance_id, _force_new=True)
|
|
170
|
+
sdk = MaximemSynapSDK(
|
|
171
|
+
instance_id=instance_id,
|
|
172
|
+
api_key=api_key,
|
|
173
|
+
_force_new=True,
|
|
174
|
+
)
|
|
179
175
|
append_step(timings, "construct_sdk", step)
|
|
180
176
|
|
|
181
177
|
config_kwargs = {"log_level": "DEBUG", "cache_backend": "sqlite"}
|
|
@@ -194,10 +190,7 @@ async def handle_init(params: dict) -> dict:
|
|
|
194
190
|
append_step(timings, "configure_sdk", step)
|
|
195
191
|
|
|
196
192
|
step = time.perf_counter()
|
|
197
|
-
|
|
198
|
-
await sdk.initialize(bootstrap_token=bootstrap_token)
|
|
199
|
-
else:
|
|
200
|
-
await sdk.initialize()
|
|
193
|
+
await sdk.initialize()
|
|
201
194
|
append_step(timings, "initialize_sdk", step)
|
|
202
195
|
|
|
203
196
|
grpc_listening = False
|
|
@@ -221,7 +214,6 @@ async def handle_init(params: dict) -> dict:
|
|
|
221
214
|
return {
|
|
222
215
|
"success": True,
|
|
223
216
|
"instance_id": instance_id,
|
|
224
|
-
"bootstrap_token_used": bool(bootstrap_token),
|
|
225
217
|
"grpc_listening": grpc_listening,
|
|
226
218
|
"bridgeTiming": {
|
|
227
219
|
"python_total_ms": ms_since(handler_start),
|
package/package.json
CHANGED
package/src/bridge-manager.js
CHANGED
|
@@ -59,9 +59,8 @@ class BridgeManager {
|
|
|
59
59
|
'init',
|
|
60
60
|
{
|
|
61
61
|
instance_id: instanceId,
|
|
62
|
-
|
|
63
|
-
|| process.env.
|
|
64
|
-
|| process.env.SYNAP_BOOTSTRAP_KEY,
|
|
62
|
+
api_key: this.options.apiKey
|
|
63
|
+
|| process.env.SYNAP_API_KEY,
|
|
65
64
|
base_url: this.options.baseUrl || process.env.SYNAP_BASE_URL,
|
|
66
65
|
grpc_host: this.options.grpcHost || process.env.SYNAP_GRPC_HOST,
|
|
67
66
|
grpc_port: Number(this.options.grpcPort || process.env.SYNAP_GRPC_PORT || 50051),
|
package/src/errors.js
CHANGED
|
@@ -79,34 +79,6 @@ class AuthenticationError extends SynapPermanentError {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
class CertificateExpiredError extends AuthenticationError {
|
|
83
|
-
constructor(message, correlationId) {
|
|
84
|
-
super(message, correlationId);
|
|
85
|
-
this.name = 'CertificateExpiredError';
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
class CertificateRenewalError extends AuthenticationError {
|
|
90
|
-
constructor(message, correlationId) {
|
|
91
|
-
super(message, correlationId);
|
|
92
|
-
this.name = 'CertificateRenewalError';
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
class BootstrapKeyInvalidError extends AuthenticationError {
|
|
97
|
-
constructor(message, correlationId) {
|
|
98
|
-
super(message, correlationId);
|
|
99
|
-
this.name = 'BootstrapKeyInvalidError';
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
class BootstrapError extends SynapPermanentError {
|
|
104
|
-
constructor(message, correlationId) {
|
|
105
|
-
super(message, correlationId);
|
|
106
|
-
this.name = 'BootstrapError';
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
82
|
class ContextNotFoundError extends SynapPermanentError {
|
|
111
83
|
constructor(message, correlationId) {
|
|
112
84
|
super(message, correlationId);
|
|
@@ -147,10 +119,6 @@ const ERROR_MAP = {
|
|
|
147
119
|
InvalidInstanceIdError,
|
|
148
120
|
InvalidConversationIdError,
|
|
149
121
|
AuthenticationError,
|
|
150
|
-
CertificateExpiredError,
|
|
151
|
-
CertificateRenewalError,
|
|
152
|
-
BootstrapKeyInvalidError,
|
|
153
|
-
BootstrapError,
|
|
154
122
|
ContextNotFoundError,
|
|
155
123
|
SessionExpiredError,
|
|
156
124
|
ListeningAlreadyActiveError,
|
|
@@ -175,10 +143,6 @@ module.exports = {
|
|
|
175
143
|
InvalidInstanceIdError,
|
|
176
144
|
InvalidConversationIdError,
|
|
177
145
|
AuthenticationError,
|
|
178
|
-
CertificateExpiredError,
|
|
179
|
-
CertificateRenewalError,
|
|
180
|
-
BootstrapKeyInvalidError,
|
|
181
|
-
BootstrapError,
|
|
182
146
|
ContextNotFoundError,
|
|
183
147
|
SessionExpiredError,
|
|
184
148
|
ListeningAlreadyActiveError,
|
package/types/index.d.ts
CHANGED
|
@@ -29,8 +29,7 @@ export interface BridgeLogHandler {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export interface SynapClientOptions {
|
|
32
|
-
|
|
33
|
-
bootstrapToken?: string;
|
|
32
|
+
apiKey?: string;
|
|
34
33
|
baseUrl?: string;
|
|
35
34
|
grpcHost?: string;
|
|
36
35
|
grpcPort?: number;
|
|
@@ -370,10 +369,6 @@ export class InvalidInputError extends SynapPermanentError {}
|
|
|
370
369
|
export class InvalidInstanceIdError extends InvalidInputError {}
|
|
371
370
|
export class InvalidConversationIdError extends InvalidInputError {}
|
|
372
371
|
export class AuthenticationError extends SynapPermanentError {}
|
|
373
|
-
export class CertificateExpiredError extends AuthenticationError {}
|
|
374
|
-
export class CertificateRenewalError extends AuthenticationError {}
|
|
375
|
-
export class BootstrapKeyInvalidError extends AuthenticationError {}
|
|
376
|
-
export class BootstrapError extends SynapPermanentError {}
|
|
377
372
|
export class ContextNotFoundError extends SynapPermanentError {}
|
|
378
373
|
export class SessionExpiredError extends SynapPermanentError {}
|
|
379
374
|
export class ListeningAlreadyActiveError extends SynapPermanentError {}
|