@maximem/synap-js-sdk 0.3.0 → 0.4.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/MIGRATING.md +147 -0
- package/README.md +95 -82
- package/bin/synap-js-sdk.js +45 -122
- package/dist/anticipation-cache-ARYEEKMU.cjs +10 -0
- package/dist/anticipation-cache-ARYEEKMU.cjs.map +1 -0
- package/dist/anticipation-cache-BMVF5sXb.d.cts +190 -0
- package/dist/anticipation-cache-BMVF5sXb.d.ts +190 -0
- package/dist/anticipation-cache-H7HEVWQC.js +10 -0
- package/dist/anticipation-cache-H7HEVWQC.js.map +1 -0
- package/dist/chunk-5SC3ELNK.js +856 -0
- package/dist/chunk-5SC3ELNK.js.map +1 -0
- package/dist/chunk-6LDUDKHS.js +832 -0
- package/dist/chunk-6LDUDKHS.js.map +1 -0
- package/dist/chunk-HR5Y3KXS.cjs +172 -0
- package/dist/chunk-HR5Y3KXS.cjs.map +1 -0
- package/dist/chunk-QBCVMPGK.js +28 -0
- package/dist/chunk-QBCVMPGK.js.map +1 -0
- package/dist/chunk-RB57I2IQ.cjs +832 -0
- package/dist/chunk-RB57I2IQ.cjs.map +1 -0
- package/dist/chunk-T3NZBIV2.js +172 -0
- package/dist/chunk-T3NZBIV2.js.map +1 -0
- package/dist/chunk-VXRCBMCY.cjs +856 -0
- package/dist/chunk-VXRCBMCY.cjs.map +1 -0
- package/dist/chunk-ZKOJDUN4.cjs +28 -0
- package/dist/chunk-ZKOJDUN4.cjs.map +1 -0
- package/dist/env-55ULHNJZ.cjs +11 -0
- package/dist/env-55ULHNJZ.cjs.map +1 -0
- package/dist/env-QCUKKW36.js +11 -0
- package/dist/env-QCUKKW36.js.map +1 -0
- package/dist/grpc/index.cjs +87 -0
- package/dist/grpc/index.cjs.map +1 -0
- package/dist/grpc/index.d.cts +162 -0
- package/dist/grpc/index.d.ts +162 -0
- package/dist/grpc/index.js +87 -0
- package/dist/grpc/index.js.map +1 -0
- package/dist/index.cjs +2702 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1491 -0
- package/dist/index.d.ts +1491 -0
- package/dist/index.js +2702 -0
- package/dist/index.js.map +1 -0
- package/dist/stream-client-ME5N5NK4.js +7 -0
- package/dist/stream-client-ME5N5NK4.js.map +1 -0
- package/dist/stream-client-ZN6ADZBR.cjs +7 -0
- package/dist/stream-client-ZN6ADZBR.cjs.map +1 -0
- package/package.json +68 -23
- package/.env.example +0 -39
- package/bridge/synap_bridge.py +0 -768
- package/src/bridge-manager.js +0 -262
- package/src/errors.js +0 -168
- package/src/index.js +0 -13
- package/src/runtime.js +0 -161
- package/src/setup-typescript.js +0 -161
- package/src/synap-client.js +0 -464
- package/types/index.d.ts +0 -475
package/MIGRATING.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# Migrating from 0.3.x to 0.4
|
|
2
|
+
|
|
3
|
+
`@maximem/synap-js-sdk` 0.4 is a **native TypeScript SDK**. It no longer spawns
|
|
4
|
+
a Python subprocess.
|
|
5
|
+
|
|
6
|
+
## The short version
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install @maximem/synap-js-sdk
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Then delete any `npx synap-js-sdk setup` step from your install or CI scripts.
|
|
13
|
+
Most code needs no other change.
|
|
14
|
+
|
|
15
|
+
## Breaking changes
|
|
16
|
+
|
|
17
|
+
### There is no setup step
|
|
18
|
+
|
|
19
|
+
0.3.x had two: `npx synap-js-sdk setup` (built a Python virtualenv) and
|
|
20
|
+
`npx synap-js-sdk setup-ts` (installed `typescript` + `@types/node` and wrote a
|
|
21
|
+
tsconfig). Neither exists in 0.4. Installing the package is the whole
|
|
22
|
+
installation, and types ship inside it.
|
|
23
|
+
|
|
24
|
+
### Python is no longer required, or used
|
|
25
|
+
|
|
26
|
+
0.3.x shipped a JSON-RPC bridge: Node spawned a Python interpreter and talked to
|
|
27
|
+
the real SDK over stdin/stdout. That required Python 3.11+ on every host, made
|
|
28
|
+
the package unusable anywhere without a process spawn, and meant every call
|
|
29
|
+
crossed a serialised pipe.
|
|
30
|
+
|
|
31
|
+
0.4 talks to the API directly.
|
|
32
|
+
|
|
33
|
+
- **Remove** `npx synap-js-sdk setup` from postinstall and CI.
|
|
34
|
+
- `~/.synap-js-sdk/.venv` is now orphaned. It is safe to delete.
|
|
35
|
+
- These environment variables no longer do anything: `SYNAP_JS_SDK_HOME`,
|
|
36
|
+
`SYNAP_PYTHON_BIN`, `SYNAP_PYTHON_BOOTSTRAP`, `SYNAP_PY_SDK_PACKAGE`,
|
|
37
|
+
`SYNAP_PY_SDK_VERSION`.
|
|
38
|
+
- The `synap-js-sdk` command still exists and still exits 0, so an un-updated
|
|
39
|
+
script will not break your build. It prints a notice and does nothing.
|
|
40
|
+
|
|
41
|
+
### Node 20 is the minimum
|
|
42
|
+
|
|
43
|
+
Node 18 is end-of-life, and `globalThis.crypto` is only unflagged from Node 19.
|
|
44
|
+
|
|
45
|
+
### `listen()` is now opt-in
|
|
46
|
+
|
|
47
|
+
0.3.x started a gRPC anticipation stream **automatically** during init. Every
|
|
48
|
+
user had one whether they wanted it or not.
|
|
49
|
+
|
|
50
|
+
In 0.4 you ask for it explicitly. Be aware of what that means for your bill:
|
|
51
|
+
the anticipation stream is what lets the SDK answer some retrievals from a
|
|
52
|
+
locally cached bundle. Without it, those turns become billed cloud fetches. If
|
|
53
|
+
you were relying on that behavior, opt back in.
|
|
54
|
+
|
|
55
|
+
> The stream needs the optional peers: `npm install @grpc/grpc-js
|
|
56
|
+
> @grpc/proto-loader`. It is Node-only. Edge runtimes and Workers cannot host
|
|
57
|
+
> gRPC at all, so importing the SDK there stays safe and only the stream is
|
|
58
|
+
> unavailable.
|
|
59
|
+
|
|
60
|
+
### The local cache no longer persists across restarts
|
|
61
|
+
|
|
62
|
+
The Python SDK cached to SQLite, so a restarted process kept its cache. The JS
|
|
63
|
+
SDK caches in memory.
|
|
64
|
+
|
|
65
|
+
This is a **billing** change, not only a latency one: a cache miss is a metered
|
|
66
|
+
retrieval. Long-lived servers are largely unaffected. Short-lived processes and
|
|
67
|
+
serverless functions will see more cloud fetches. A pluggable cache backend is
|
|
68
|
+
available if you want to add Redis.
|
|
69
|
+
|
|
70
|
+
### Deleting by user is gone
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
// 0.3.x -- silently did nothing in serverless, and reported success
|
|
74
|
+
await client.deleteMemory({ userId: 'u1' });
|
|
75
|
+
|
|
76
|
+
// 0.4
|
|
77
|
+
await client.memories.delete(memoryId);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The old form tracked memory ids in a process-local dictionary. In any
|
|
81
|
+
serverless or multi-process deployment that dictionary was empty, so the call
|
|
82
|
+
deleted nothing and returned `{ success: true, deletedCount: 0 }`. It now
|
|
83
|
+
throws instead of quietly lying.
|
|
84
|
+
|
|
85
|
+
### Timestamps are proper ISO-8601
|
|
86
|
+
|
|
87
|
+
The bridge stringified datetimes through Python's `str()`, producing
|
|
88
|
+
`2026-08-12 10:00:00+00:00` -- a space instead of the `T`. Native JS emits
|
|
89
|
+
`2026-08-12T10:00:00+00:00`. This is a fix, but it is still a change if you
|
|
90
|
+
were parsing those strings.
|
|
91
|
+
|
|
92
|
+
### True concurrency
|
|
93
|
+
|
|
94
|
+
The bridge serialised every call through one pipe. Concurrent calls are now
|
|
95
|
+
genuinely concurrent, which is faster and also means server rate limits the
|
|
96
|
+
pipe used to mask can now be reached. If you fan out hard, cap your own
|
|
97
|
+
concurrency.
|
|
98
|
+
|
|
99
|
+
## What did NOT change
|
|
100
|
+
|
|
101
|
+
Your call sites, in almost every case.
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
// Unchanged
|
|
105
|
+
const ctx = await client.user.context.fetch({ user_id: 'u1', search_query: ['email'] });
|
|
106
|
+
await client.memories.create({ document: 'text', user_id: 'u1' });
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
- Both the namespaced (`client.user.context.fetch`) and legacy camelCase
|
|
110
|
+
(`client.fetchUserContext`) surfaces still work.
|
|
111
|
+
- **They still return different shapes**, exactly as before: namespaced returns
|
|
112
|
+
raw `snake_case`, camelCase returns normalised `camelCase`. Converging them
|
|
113
|
+
would break one set of callers, so it is deferred.
|
|
114
|
+
- Both `user_id` and `userId` spellings are still accepted everywhere.
|
|
115
|
+
- `client.init()` still exists as a no-op.
|
|
116
|
+
|
|
117
|
+
## New in 0.4
|
|
118
|
+
|
|
119
|
+
- **Runs where Python could not**: Edge, Workers and browsers, for the HTTP
|
|
120
|
+
paths. Only the gRPC stream is Node-only.
|
|
121
|
+
- **Real types**, generated from the source rather than hand-written.
|
|
122
|
+
- **A typed error taxonomy** mirroring the Python SDK. Every error carries a
|
|
123
|
+
stable `.code`, which is what you should branch on:
|
|
124
|
+
|
|
125
|
+
```js
|
|
126
|
+
import { isSynapError } from '@maximem/synap-js-sdk';
|
|
127
|
+
|
|
128
|
+
try { await client.memories.create({ document }); }
|
|
129
|
+
catch (e) {
|
|
130
|
+
if (isSynapError(e) && e.code === 'insufficient_credits') { /* top up */ }
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Prefer `.code` over `instanceof` at a package boundary: with dual ESM/CJS a
|
|
135
|
+
consumer can end up holding two copies of a class. (`instanceof` is made to
|
|
136
|
+
work across copies too, but `.code` is the documented contract.)
|
|
137
|
+
- **Explicit lifecycle.** Call `await client.shutdown()` when you are done. The
|
|
138
|
+
SDK does not register `process.on('exit')` handlers: they leak a listener per
|
|
139
|
+
client, never fire in Lambda, and `process` does not exist in Workers.
|
|
140
|
+
|
|
141
|
+
## Staying on 0.3.x
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
npm install @maximem/synap-js-sdk@legacy
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
0.3.x remains installable under the `legacy` dist-tag and is not deprecated.
|
package/README.md
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
# @maximem/synap-js-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Native TypeScript SDK for [Synap](https://synap.maximem.ai) context and memory
|
|
4
|
+
management.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- Node.js 18+
|
|
8
|
-
- Python 3.8+
|
|
6
|
+
**No Python required.** 0.4 replaced the Python-subprocess bridge with a native
|
|
7
|
+
client. Upgrading from 0.3.x? See [MIGRATING.md](./MIGRATING.md).
|
|
9
8
|
|
|
10
9
|
## Install
|
|
11
10
|
|
|
@@ -13,109 +12,123 @@ Node.js wrapper for the Synap Python SDK.
|
|
|
13
12
|
npm install @maximem/synap-js-sdk
|
|
14
13
|
```
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
Requires Node.js 20+. **That is the whole installation.** There is no setup
|
|
16
|
+
command, and TypeScript needs no extra step: types ship in the package.
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Verified against TypeScript 5.7 and 7.0 with `moduleResolution` set to `node`,
|
|
19
|
+
`node16`, `nodenext` and `bundler`.
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
npx synap-js-sdk setup --sdk-version 0.2.0
|
|
22
|
-
```
|
|
21
|
+
## Quick start
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
```ts
|
|
24
|
+
import { SynapClient } from '@maximem/synap-js-sdk';
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const client = new SynapClient({ apiKey: process.env.SYNAP_API_KEY });
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
// Store
|
|
29
|
+
await client.memories.create({
|
|
30
|
+
document: 'The user prefers aisle seats on long-haul flights.',
|
|
31
|
+
user_id: 'user-123',
|
|
32
|
+
// Optional. Defaults to 'ai-chat-conversation'. It selects the extraction
|
|
33
|
+
// path, so setting it wrongly stores less from the same text.
|
|
34
|
+
document_type: 'ai-chat-conversation',
|
|
35
|
+
});
|
|
33
36
|
|
|
34
|
-
|
|
37
|
+
// Retrieve
|
|
38
|
+
const context = await client.user.context.fetch({
|
|
39
|
+
user_id: 'user-123',
|
|
40
|
+
search_query: ['seat preference'],
|
|
41
|
+
});
|
|
35
42
|
|
|
36
|
-
|
|
37
|
-
$env:USERPROFILE\.synap-js-sdk\.venv\Scripts\python.exe -c "import maximem_synap; print(maximem_synap.__version__)"
|
|
43
|
+
await client.shutdown();
|
|
38
44
|
```
|
|
39
45
|
|
|
40
|
-
##
|
|
46
|
+
## Scopes
|
|
41
47
|
|
|
42
|
-
|
|
48
|
+
Scopes are **client > customer > user**. A narrower request also matches
|
|
49
|
+
broader-scope memories.
|
|
43
50
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
```ts
|
|
52
|
+
await client.user.context.fetch({ user_id, customer_id });
|
|
53
|
+
await client.customer.context.fetch({ customer_id });
|
|
54
|
+
await client.client.context.fetch({});
|
|
55
|
+
```
|
|
47
56
|
|
|
48
|
-
|
|
57
|
+
`conversation_id` is **not** a scope tier. It groups turns within a scope, and
|
|
58
|
+
narrows a fetch rather than selecting a different one.
|
|
49
59
|
|
|
50
|
-
|
|
51
|
-
const { createClient } = require('@maximem/synap-js-sdk');
|
|
60
|
+
## Errors
|
|
52
61
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
62
|
+
Every error carries a stable `.code`. Branch on that rather than on the class,
|
|
63
|
+
because a dual ESM/CJS dependency graph can hand you two copies of the same
|
|
64
|
+
class:
|
|
56
65
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
await synap.addMemory({
|
|
61
|
-
userId: 'user-123',
|
|
62
|
-
customerId: 'customer-456',
|
|
63
|
-
conversationId: 'conv-123',
|
|
64
|
-
messages: [{ role: 'user', content: 'My name is Alex and I live in Austin.' }],
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const context = await synap.fetchUserContext({
|
|
68
|
-
userId: 'user-123',
|
|
69
|
-
customerId: 'customer-456',
|
|
70
|
-
conversationId: 'conv-123',
|
|
71
|
-
searchQuery: ['Where does the user live?'],
|
|
72
|
-
maxResults: 10,
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
console.log(context.facts);
|
|
76
|
-
|
|
77
|
-
const promptContext = await synap.getContextForPrompt({
|
|
78
|
-
conversationId: 'conv-123',
|
|
79
|
-
style: 'structured',
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
console.log(promptContext.formattedContext);
|
|
83
|
-
await synap.shutdown();
|
|
84
|
-
}
|
|
66
|
+
```ts
|
|
67
|
+
import { isSynapError } from '@maximem/synap-js-sdk';
|
|
85
68
|
|
|
86
|
-
|
|
69
|
+
try {
|
|
70
|
+
await client.memories.create({ document, user_id });
|
|
71
|
+
} catch (e) {
|
|
72
|
+
if (!isSynapError(e)) throw e;
|
|
73
|
+
switch (e.code) {
|
|
74
|
+
case 'insufficient_credits': /* top up */ break;
|
|
75
|
+
case 'rate_limit': /* e.retryAfterSeconds */ break;
|
|
76
|
+
case 'authentication': /* bad key */ break;
|
|
77
|
+
default: throw e;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
87
80
|
```
|
|
88
81
|
|
|
89
|
-
|
|
82
|
+
Transient errors are retried automatically. Ingestion is deliberately **not**
|
|
83
|
+
retried when a failure leaves the outcome unknown, because a retry would store
|
|
84
|
+
and bill twice.
|
|
90
85
|
|
|
91
|
-
|
|
86
|
+
## Runtime support
|
|
92
87
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
88
|
+
| Runtime | HTTP context + memories | gRPC anticipation stream |
|
|
89
|
+
|---|---|---|
|
|
90
|
+
| Node.js 20+ | Yes | Yes (opt-in) |
|
|
91
|
+
| Bun | Yes | Unverified |
|
|
92
|
+
| Deno 2 | Yes | Unverified |
|
|
93
|
+
| Vercel Edge | Yes | No |
|
|
94
|
+
| Cloudflare Workers | Yes | No |
|
|
95
|
+
| Browser | Yes (do not ship an API key) | No |
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
Edge and Workers cannot run gRPC at all: it needs raw TCP and `node:http2`,
|
|
98
|
+
which they do not provide. Bun and Deno have both, so gRPC is plausible on each,
|
|
99
|
+
but **bidirectional streaming has not been tested there**, so those cells stay
|
|
100
|
+
unverified rather than claimed either way.
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
Importing the SDK on Edge is safe: gRPC lives behind the
|
|
103
|
+
`@maximem/synap-js-sdk/grpc` subpath and is only ever loaded lazily.
|
|
103
104
|
|
|
104
|
-
|
|
105
|
-
npm install @maximem/synap-js-sdk && npx synap-js-sdk setup --sdk-version 0.2.0 && npx synap-js-sdk setup-ts
|
|
106
|
-
```
|
|
105
|
+
## Configuration
|
|
107
106
|
|
|
108
|
-
|
|
107
|
+
| Option | Default | Notes |
|
|
108
|
+
|---|---|---|
|
|
109
|
+
| `apiKey` | `SYNAP_API_KEY` | Required. |
|
|
110
|
+
| `clientId` | `SYNAP_CLIENT_ID` | Skips a `whoami` round trip. |
|
|
111
|
+
| `baseUrl` | prod | |
|
|
112
|
+
| `heartbeat` | `false` | Keeps the connection warm. Worth it for a long-lived process, pointless in serverless. |
|
|
113
|
+
| `timeouts` | 5s connect / 30s read | |
|
|
114
|
+
| `retryPolicy` | 3 attempts | |
|
|
109
115
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
- Temporal fields are exposed in JS/TS as `eventDate`, `validUntil`, `temporalCategory`, `temporalConfidence`, plus top-level `temporalEvents`.
|
|
116
|
+
Environment flags are read at call time, so you can toggle them at runtime:
|
|
117
|
+
`SYNAP_SDK_CACHE_RECALL_BYPASS`, `SYNAP_SDK_CACHE_HONOR_TTL_HINT`,
|
|
118
|
+
`SYNAP_SDK_CACHE_INVALIDATE_ON_WRITE`, `SYNAP_SDK_CACHE_COVERAGE_MIN`,
|
|
119
|
+
`SYNAP_SDK_CACHE_MAX_ENTRY_AGE`.
|
|
115
120
|
|
|
116
|
-
##
|
|
121
|
+
## Development
|
|
117
122
|
|
|
118
123
|
```bash
|
|
119
|
-
|
|
120
|
-
|
|
124
|
+
npm install
|
|
125
|
+
npm test
|
|
126
|
+
npm run build
|
|
127
|
+
npm run typecheck
|
|
128
|
+
npm run sync-behavior # after changing synap/sdk/CONTRACT/**
|
|
121
129
|
```
|
|
130
|
+
|
|
131
|
+
Retrieval behavior (recall-bypass patterns, BM25 thresholds, the stemmer) is
|
|
132
|
+
**not defined in this package**. It lives in `synap/sdk/CONTRACT/`, shared
|
|
133
|
+
byte-identically with the Python SDK, and both SDKs run the same conformance
|
|
134
|
+
corpus. Never edit the vendored copy in `src/behavior/`.
|
package/bin/synap-js-sdk.js
CHANGED
|
@@ -1,124 +1,47 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Compatibility shim.
|
|
4
|
+
*
|
|
5
|
+
* `npx synap-js-sdk setup` used to build a Python virtualenv and install the
|
|
6
|
+
* Python SDK into it. Since 1.0 the SDK is native TypeScript, so there is
|
|
7
|
+
* nothing to set up.
|
|
8
|
+
*
|
|
9
|
+
* The command is kept, and kept exiting 0, because it appears in published
|
|
10
|
+
* documentation and in customers' postinstall and CI scripts. Removing the
|
|
11
|
+
* binary would turn a no-longer-needed step into a hard failure on upgrade.
|
|
12
|
+
*
|
|
13
|
+
* ESM, not CommonJS: package.json declares "type": "module", so a `require`
|
|
14
|
+
* here would throw ERR_REQUIRE_ESM on every invocation.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const [, , command] = process.argv;
|
|
18
|
+
|
|
19
|
+
const NOTE = `
|
|
20
|
+
@maximem/synap-js-sdk 1.x is a native TypeScript SDK. It does not use Python,
|
|
21
|
+
so there is no setup step and this command does nothing.
|
|
22
|
+
|
|
23
|
+
If you are upgrading from 0.3.x:
|
|
24
|
+
- Remove any "npx synap-js-sdk setup" step from your install or CI scripts.
|
|
25
|
+
- ~/.synap-js-sdk/.venv is now orphaned and safe to delete.
|
|
26
|
+
- Node 20 or newer is required.
|
|
27
|
+
- listen() is now opt-in rather than started automatically.
|
|
28
|
+
|
|
29
|
+
See MIGRATING.md in the package for the full list.
|
|
30
|
+
`.trim();
|
|
31
|
+
|
|
32
|
+
switch (command) {
|
|
33
|
+
case 'setup':
|
|
34
|
+
case 'setup-ts':
|
|
35
|
+
case undefined:
|
|
36
|
+
console.log(NOTE);
|
|
37
|
+
break;
|
|
38
|
+
case '--version':
|
|
39
|
+
case '-v':
|
|
40
|
+
console.log(process.env['npm_package_version'] ?? '1.x');
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
console.log(`Unknown command: ${command}\n\n${NOTE}`);
|
|
44
|
+
// Still exit 0: an unknown subcommand in a legacy script should not break
|
|
45
|
+
// a customer's build on upgrade.
|
|
46
|
+
break;
|
|
30
47
|
}
|
|
31
|
-
|
|
32
|
-
function printHelp() {
|
|
33
|
-
console.log(`synap-js-sdk
|
|
34
|
-
|
|
35
|
-
Usage:
|
|
36
|
-
synap-js-sdk setup [options]
|
|
37
|
-
synap-js-sdk setup-ts [options]
|
|
38
|
-
|
|
39
|
-
setup options:
|
|
40
|
-
--python <bin> Python bootstrap binary (default: python3)
|
|
41
|
-
--sdk-home <path> SDK home (default: ~/.synap-js-sdk)
|
|
42
|
-
--venv <path> Virtualenv path (default: <sdk-home>/.venv)
|
|
43
|
-
--package <name> Python package name (default: maximem-synap)
|
|
44
|
-
--sdk-version <ver> Python SDK version to install
|
|
45
|
-
--no-deps Install without dependencies
|
|
46
|
-
--no-build-isolation Disable pip build isolation
|
|
47
|
-
--upgrade Use pip --upgrade
|
|
48
|
-
--force-recreate-venv Recreate virtualenv
|
|
49
|
-
|
|
50
|
-
setup-ts options:
|
|
51
|
-
--project-dir <path> Target Node project directory (default: cwd)
|
|
52
|
-
--package-manager <name> npm | pnpm | yarn | bun (auto-detect if omitted)
|
|
53
|
-
--skip-install Skip installing typescript and @types/node
|
|
54
|
-
--tsconfig-path <path> tsconfig output path (default: tsconfig.json)
|
|
55
|
-
--wrapper-path <path> Typed wrapper output path (default: src/synap.ts)
|
|
56
|
-
--no-wrapper Do not generate the typed wrapper file
|
|
57
|
-
--force Overwrite generated files when they already exist
|
|
58
|
-
|
|
59
|
-
global:
|
|
60
|
-
--help Show this help
|
|
61
|
-
`);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async function run() {
|
|
65
|
-
const args = parseArgs(process.argv.slice(2));
|
|
66
|
-
const command = args._[0];
|
|
67
|
-
|
|
68
|
-
if (!command || args.help || command === 'help') {
|
|
69
|
-
printHelp();
|
|
70
|
-
process.exit(0);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (command === 'setup') {
|
|
74
|
-
try {
|
|
75
|
-
const result = await setupPythonRuntime({
|
|
76
|
-
pythonBootstrap: args.python,
|
|
77
|
-
sdkHome: args['sdk-home'],
|
|
78
|
-
venvPath: args.venv,
|
|
79
|
-
pythonPackage: args.package,
|
|
80
|
-
pythonSdkVersion: args['sdk-version'],
|
|
81
|
-
noDeps: !!args['no-deps'],
|
|
82
|
-
noBuildIsolation: !!args['no-build-isolation'],
|
|
83
|
-
upgrade: !!args.upgrade,
|
|
84
|
-
forceRecreateVenv: !!args['force-recreate-venv'],
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
console.log('Synap JS SDK Python runtime setup complete.');
|
|
88
|
-
console.log(JSON.stringify(result, null, 2));
|
|
89
|
-
return;
|
|
90
|
-
} catch (error) {
|
|
91
|
-
console.error('Setup failed:');
|
|
92
|
-
console.error(error.message || String(error));
|
|
93
|
-
process.exit(1);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (command === 'setup-ts') {
|
|
98
|
-
try {
|
|
99
|
-
const result = await setupTypeScriptExtension({
|
|
100
|
-
projectDir: args['project-dir'],
|
|
101
|
-
packageManager: args['package-manager'],
|
|
102
|
-
skipInstall: !!args['skip-install'],
|
|
103
|
-
tsconfigPath: args['tsconfig-path'],
|
|
104
|
-
wrapperPath: args['wrapper-path'],
|
|
105
|
-
noWrapper: !!args['no-wrapper'],
|
|
106
|
-
force: !!args.force,
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
console.log('Synap JS SDK TypeScript extension setup complete.');
|
|
110
|
-
console.log(JSON.stringify(result, null, 2));
|
|
111
|
-
return;
|
|
112
|
-
} catch (error) {
|
|
113
|
-
console.error('TypeScript setup failed:');
|
|
114
|
-
console.error(error.message || String(error));
|
|
115
|
-
process.exit(1);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
console.error(`Unknown command: ${command}`);
|
|
120
|
-
printHelp();
|
|
121
|
-
process.exit(1);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
run();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkRB57I2IQcjs = require('./chunk-RB57I2IQ.cjs');
|
|
5
|
+
require('./chunk-ZKOJDUN4.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.ANY_SCOPE = _chunkRB57I2IQcjs.ANY_SCOPE; exports.AnticipationCache = _chunkRB57I2IQcjs.AnticipationCache;
|
|
10
|
+
//# sourceMappingURL=anticipation-cache-ARYEEKMU.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/anish/maximemai/maximem_synap/synap/sdk/js/dist/anticipation-cache-ARYEEKMU.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACF,iHAAC","file":"/Users/anish/maximemai/maximem_synap/synap/sdk/js/dist/anticipation-cache-ARYEEKMU.cjs"}
|