@quantod/qq 0.3.7 → 1.0.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/dist/commands.d.ts +23 -7
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +134 -30
- package/dist/commands.js.map +1 -1
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +11 -17
- package/dist/db.js.map +1 -1
- package/dist/http.d.ts +7 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +113 -0
- package/dist/http.js.map +1 -0
- package/dist/index.js +52 -29
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.ts +2 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +232 -0
- package/dist/mcp.js.map +1 -0
- package/dist/resources/chrome.md +33 -0
- package/dist/resources/guide.md +491 -0
- package/dist/resources/pipeline_design.md +192 -0
- package/dist/sdk-templates/javascript.d.ts +2 -0
- package/dist/sdk-templates/javascript.d.ts.map +1 -0
- package/dist/sdk-templates/javascript.js +24 -0
- package/dist/sdk-templates/javascript.js.map +1 -0
- package/dist/sdk-templates/python.d.ts +2 -0
- package/dist/sdk-templates/python.d.ts.map +1 -0
- package/dist/sdk-templates/python.js +31 -0
- package/dist/sdk-templates/python.js.map +1 -0
- package/package.json +10 -3
- package/src/commands.ts +151 -32
- package/src/db.ts +12 -18
- package/src/http.ts +133 -0
- package/src/index.ts +51 -32
- package/src/mcp.ts +226 -0
- package/src/resources/chrome.md +33 -0
- package/src/resources/guide.md +491 -0
- package/src/resources/pipeline_design.md +192 -0
- package/src/sdk-templates/javascript.ts +20 -0
- package/src/sdk-templates/python.ts +27 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function renderPythonSdk(host: string, port: number, token: string): string {
|
|
2
|
+
return `import urllib.request, json as _json, urllib.parse
|
|
3
|
+
class BridgeError(Exception): pass
|
|
4
|
+
_BRIDGE_URL = 'http://${host}:${port}'
|
|
5
|
+
_BRIDGE_HEADERS = {'Authorization': 'Bearer ${token}', 'Content-Type': 'application/json'}
|
|
6
|
+
def _bridge_req(method, path, body=None):
|
|
7
|
+
data = _json.dumps(body).encode() if body is not None else None
|
|
8
|
+
req = urllib.request.Request(_BRIDGE_URL + path, data=data, headers=_BRIDGE_HEADERS, method=method)
|
|
9
|
+
try:
|
|
10
|
+
with urllib.request.urlopen(req) as r:
|
|
11
|
+
return _json.loads(r.read()) if r.status != 204 else None
|
|
12
|
+
except urllib.error.HTTPError as e:
|
|
13
|
+
return _json.loads(e.read())
|
|
14
|
+
except Exception as e:
|
|
15
|
+
raise BridgeError('Connection failed — call get_sdk again to refresh credentials') from e
|
|
16
|
+
def qq_push(pipeline, stage, id=None, payload=None, **opts):
|
|
17
|
+
return _bridge_req('POST', f'/pipelines/{pipeline}/push', {'stage': stage, 'id': id, 'payload': payload, **opts})
|
|
18
|
+
def qq_claim(pipeline, stage, **opts):
|
|
19
|
+
return _bridge_req('POST', f'/pipelines/{pipeline}/claim', {'stage': stage, **opts})
|
|
20
|
+
def qq_release(pipeline, seq, **opts):
|
|
21
|
+
return _bridge_req('POST', f'/pipelines/{pipeline}/release/{seq}', opts)
|
|
22
|
+
def qq_batch_read(pipeline, stage, **opts):
|
|
23
|
+
qs = urllib.parse.urlencode({'stage': stage, **opts})
|
|
24
|
+
return _bridge_req('GET', f'/pipelines/{pipeline}/items?{qs}')
|
|
25
|
+
def qq_status(pipeline):
|
|
26
|
+
return _bridge_req('GET', f'/pipelines/{pipeline}/status')`;
|
|
27
|
+
}
|