tywrap 0.6.0 → 0.7.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.
Files changed (118) hide show
  1. package/dist/core/annotation-parser.d.ts.map +1 -1
  2. package/dist/core/annotation-parser.js +19 -14
  3. package/dist/core/annotation-parser.js.map +1 -1
  4. package/dist/core/discovery.d.ts +17 -0
  5. package/dist/core/discovery.d.ts.map +1 -1
  6. package/dist/core/discovery.js +59 -49
  7. package/dist/core/discovery.js.map +1 -1
  8. package/dist/core/generator.d.ts.map +1 -1
  9. package/dist/core/generator.js +40 -9
  10. package/dist/core/generator.js.map +1 -1
  11. package/dist/core/validation.d.ts +23 -0
  12. package/dist/core/validation.d.ts.map +1 -1
  13. package/dist/core/validation.js +52 -48
  14. package/dist/core/validation.js.map +1 -1
  15. package/dist/dev.d.ts.map +1 -1
  16. package/dist/dev.js +175 -133
  17. package/dist/dev.js.map +1 -1
  18. package/dist/runtime/base-bridge.d.ts +57 -0
  19. package/dist/runtime/base-bridge.d.ts.map +1 -0
  20. package/dist/runtime/base-bridge.js +72 -0
  21. package/dist/runtime/base-bridge.js.map +1 -0
  22. package/dist/runtime/bridge-codec.d.ts +15 -0
  23. package/dist/runtime/bridge-codec.d.ts.map +1 -1
  24. package/dist/runtime/bridge-codec.js +45 -48
  25. package/dist/runtime/bridge-codec.js.map +1 -1
  26. package/dist/runtime/http-transport.d.ts +11 -1
  27. package/dist/runtime/http-transport.d.ts.map +1 -1
  28. package/dist/runtime/http-transport.js +19 -0
  29. package/dist/runtime/http-transport.js.map +1 -1
  30. package/dist/runtime/http.d.ts +5 -12
  31. package/dist/runtime/http.d.ts.map +1 -1
  32. package/dist/runtime/http.js +6 -29
  33. package/dist/runtime/http.js.map +1 -1
  34. package/dist/runtime/index.d.ts +1 -1
  35. package/dist/runtime/index.d.ts.map +1 -1
  36. package/dist/runtime/index.js.map +1 -1
  37. package/dist/runtime/node.d.ts +12 -19
  38. package/dist/runtime/node.d.ts.map +1 -1
  39. package/dist/runtime/node.js +14 -34
  40. package/dist/runtime/node.js.map +1 -1
  41. package/dist/runtime/pooled-transport.d.ts +21 -2
  42. package/dist/runtime/pooled-transport.d.ts.map +1 -1
  43. package/dist/runtime/pooled-transport.js +16 -0
  44. package/dist/runtime/pooled-transport.js.map +1 -1
  45. package/dist/runtime/pyodide-bootstrap-core.generated.d.ts.map +1 -1
  46. package/dist/runtime/pyodide-bootstrap-core.generated.js +1 -1
  47. package/dist/runtime/pyodide-bootstrap-core.generated.js.map +1 -1
  48. package/dist/runtime/pyodide-transport.d.ts +12 -1
  49. package/dist/runtime/pyodide-transport.d.ts.map +1 -1
  50. package/dist/runtime/pyodide-transport.js +20 -0
  51. package/dist/runtime/pyodide-transport.js.map +1 -1
  52. package/dist/runtime/pyodide.d.ts +5 -12
  53. package/dist/runtime/pyodide.d.ts.map +1 -1
  54. package/dist/runtime/pyodide.js +6 -29
  55. package/dist/runtime/pyodide.js.map +1 -1
  56. package/dist/runtime/rpc-client.d.ts +32 -1
  57. package/dist/runtime/rpc-client.d.ts.map +1 -1
  58. package/dist/runtime/rpc-client.js +45 -24
  59. package/dist/runtime/rpc-client.js.map +1 -1
  60. package/dist/runtime/subprocess-transport.d.ts +26 -1
  61. package/dist/runtime/subprocess-transport.d.ts.map +1 -1
  62. package/dist/runtime/subprocess-transport.js +72 -35
  63. package/dist/runtime/subprocess-transport.js.map +1 -1
  64. package/dist/runtime/transport.d.ts +59 -0
  65. package/dist/runtime/transport.d.ts.map +1 -1
  66. package/dist/runtime/transport.js +1 -0
  67. package/dist/runtime/transport.js.map +1 -1
  68. package/dist/types/index.d.ts +35 -0
  69. package/dist/types/index.d.ts.map +1 -1
  70. package/dist/tywrap.d.ts +0 -5
  71. package/dist/tywrap.d.ts.map +1 -1
  72. package/dist/tywrap.js +212 -169
  73. package/dist/tywrap.js.map +1 -1
  74. package/dist/utils/cache.d.ts +11 -0
  75. package/dist/utils/cache.d.ts.map +1 -1
  76. package/dist/utils/cache.js +50 -58
  77. package/dist/utils/cache.js.map +1 -1
  78. package/dist/utils/codec.d.ts +2 -0
  79. package/dist/utils/codec.d.ts.map +1 -1
  80. package/dist/utils/codec.js +53 -2
  81. package/dist/utils/codec.js.map +1 -1
  82. package/dist/utils/python.d.ts.map +1 -1
  83. package/dist/utils/python.js +28 -17
  84. package/dist/utils/python.js.map +1 -1
  85. package/dist/utils/runtime.d.ts.map +1 -1
  86. package/dist/utils/runtime.js +22 -16
  87. package/dist/utils/runtime.js.map +1 -1
  88. package/dist/version.js +1 -1
  89. package/package.json +7 -1
  90. package/runtime/__pycache__/_tywrap_member_fixtures.cpython-311.pyc +0 -0
  91. package/runtime/__pycache__/safe_codec.cpython-311.pyc +0 -0
  92. package/runtime/__pycache__/tywrap_bridge_core.cpython-311.pyc +0 -0
  93. package/runtime/tywrap_bridge_core.py +55 -3
  94. package/src/core/annotation-parser.ts +23 -18
  95. package/src/core/discovery.ts +70 -54
  96. package/src/core/generator.ts +50 -11
  97. package/src/core/validation.ts +84 -48
  98. package/src/dev.ts +237 -153
  99. package/src/runtime/base-bridge.ts +106 -0
  100. package/src/runtime/bridge-codec.ts +58 -70
  101. package/src/runtime/http-transport.ts +21 -1
  102. package/src/runtime/http.ts +7 -51
  103. package/src/runtime/index.ts +1 -0
  104. package/src/runtime/node.ts +17 -52
  105. package/src/runtime/pooled-transport.ts +25 -2
  106. package/src/runtime/pyodide-bootstrap-core.generated.ts +1 -1
  107. package/src/runtime/pyodide-transport.ts +22 -0
  108. package/src/runtime/pyodide.ts +7 -52
  109. package/src/runtime/rpc-client.ts +56 -32
  110. package/src/runtime/subprocess-transport.ts +89 -40
  111. package/src/runtime/transport.ts +71 -0
  112. package/src/types/index.ts +37 -0
  113. package/src/tywrap.ts +274 -187
  114. package/src/utils/cache.ts +59 -61
  115. package/src/utils/codec.ts +61 -4
  116. package/src/utils/python.ts +33 -20
  117. package/src/utils/runtime.ts +24 -13
  118. package/src/version.ts +1 -1
@@ -102,6 +102,66 @@ export interface ProtocolResponse {
102
102
  };
103
103
  }
104
104
 
105
+ // =============================================================================
106
+ // TRANSPORT CAPABILITIES
107
+ // =============================================================================
108
+
109
+ /**
110
+ * Static, transport-level capability descriptor.
111
+ *
112
+ * Each backend exposes one of these via {@link Transport.capabilities} so callers
113
+ * can reason about what the wire channel can carry WITHOUT round-tripping to
114
+ * Python. These flags describe the transport itself (what bytes it can move and
115
+ * how it frames them) — they are deliberately separate from the bridge's runtime
116
+ * `meta` report ({@link BridgeInfo}), which describes the *Python environment*
117
+ * (which optional libraries happen to be importable). The transport descriptor is
118
+ * authoritative for transport-level flags; the meta report is authoritative for
119
+ * library availability.
120
+ *
121
+ * Honest for TODAY's behavior: `supportsChunking` and `supportsStreaming` are
122
+ * `false` on every backend — both are planned for 0.8.0 and no backend implements
123
+ * them yet. See docs/transport-capabilities.md for the full matrix.
124
+ */
125
+ export interface TransportCapabilities {
126
+ /** Which backend this transport drives. */
127
+ readonly backend: 'subprocess' | 'http' | 'pyodide';
128
+
129
+ /**
130
+ * Whether the transport can carry Arrow-encoded payloads (binary IPC frames)
131
+ * on the wire. Pyodide is JSON-only (pyarrow is unavailable in WASM), so it is
132
+ * `false` there; subprocess and HTTP can move Arrow bytes.
133
+ */
134
+ readonly supportsArrow: boolean;
135
+
136
+ /**
137
+ * Whether the transport can carry arbitrary binary data (e.g. Python `bytes`).
138
+ * All current backends carry binary via base64 envelopes, so this is `true`
139
+ * everywhere.
140
+ */
141
+ readonly supportsBinary: boolean;
142
+
143
+ /**
144
+ * Whether the transport splits a single logical message across multiple wire
145
+ * frames. Not implemented on any backend yet (planned for 0.8.0) — always
146
+ * `false`.
147
+ */
148
+ readonly supportsChunking: boolean;
149
+
150
+ /**
151
+ * Whether the transport can stream incremental results for a single request.
152
+ * Not implemented on any backend yet (planned for 0.8.0) — always `false`.
153
+ */
154
+ readonly supportsStreaming: boolean;
155
+
156
+ /**
157
+ * Maximum size, in bytes, of a single wire frame the transport will accept.
158
+ * `Number.POSITIVE_INFINITY` means the transport imposes no frame ceiling of
159
+ * its own (a higher layer — e.g. the codec's payload limit — may still cap the
160
+ * size). For the subprocess backend this is the JSONL line-length limit.
161
+ */
162
+ readonly maxFrameBytes: number;
163
+ }
164
+
105
165
  // =============================================================================
106
166
  // TRANSPORT INTERFACE
107
167
  // =============================================================================
@@ -177,6 +237,16 @@ export interface Transport extends Disposable {
177
237
  * Returns `false` in all other states.
178
238
  */
179
239
  readonly isReady: boolean;
240
+
241
+ /**
242
+ * Static, transport-level capability descriptor.
243
+ *
244
+ * Returns what this transport can carry and how it frames messages, with
245
+ * honest values for the transport's current behavior (see
246
+ * {@link TransportCapabilities}). It does NOT depend on lifecycle state — it is
247
+ * safe to call before `init()` and after `dispose()`.
248
+ */
249
+ capabilities(): TransportCapabilities;
180
250
  }
181
251
 
182
252
  // =============================================================================
@@ -228,6 +298,7 @@ export function isTransport(value: unknown): value is Transport {
228
298
  typeof (value as Transport).init === 'function' &&
229
299
  typeof (value as Transport).send === 'function' &&
230
300
  typeof (value as Transport).dispose === 'function' &&
301
+ typeof (value as Transport).capabilities === 'function' &&
231
302
  'isReady' in value
232
303
  );
233
304
  }
@@ -13,6 +13,16 @@ export interface PythonModule {
13
13
  exports: string[];
14
14
  }
15
15
 
16
+ /**
17
+ * How a callable is bound on its owning class.
18
+ *
19
+ * Mirrors `IRFunction.method_kind` from the Python IR (tywrap_ir 0.3.0):
20
+ * `'instance'` (default, keeps `self`), `'class'` (keeps `cls`), or
21
+ * `'static'` (no implicit first parameter). Module-level functions retain the
22
+ * `'instance'` default; it is only meaningful for class members.
23
+ */
24
+ export type PythonMethodKind = 'instance' | 'class' | 'static';
25
+
16
26
  export interface PythonFunction {
17
27
  name: string;
18
28
  signature: FunctionSignature;
@@ -23,6 +33,28 @@ export interface PythonFunction {
23
33
  typeParameters?: PythonGenericParameter[];
24
34
  returnType: PythonType;
25
35
  parameters: Parameter[];
36
+ /**
37
+ * Binding of this callable on its owning class. Defaults to `'instance'`.
38
+ * @see PythonMethodKind
39
+ */
40
+ methodKind?: PythonMethodKind;
41
+ }
42
+
43
+ /**
44
+ * A `@property` or `functools.cached_property` exposed on a class.
45
+ *
46
+ * Mirrors `IRAccessor` from the Python IR (tywrap_ir 0.3.0). Distinct from
47
+ * {@link PythonClass.properties} (which model TypedDict/NamedTuple/dataclass
48
+ * data shapes): accessors are computed attributes backed by a getter.
49
+ */
50
+ export interface PythonAccessor {
51
+ name: string;
52
+ type: PythonType;
53
+ docstring?: string;
54
+ /** True when there is no setter. `undefined` when undeterminable. */
55
+ readOnly?: boolean;
56
+ /** True for `functools.cached_property`. */
57
+ isCached: boolean;
26
58
  }
27
59
 
28
60
  export interface PythonClass {
@@ -30,6 +62,11 @@ export interface PythonClass {
30
62
  bases: string[];
31
63
  methods: PythonFunction[];
32
64
  properties: Property[];
65
+ /**
66
+ * `@property` / `functools.cached_property` accessors, emitted as TS getters.
67
+ * @see PythonAccessor
68
+ */
69
+ accessors?: PythonAccessor[];
33
70
  docstring?: string;
34
71
  decorators: string[];
35
72
  kind?: 'class' | 'protocol' | 'typed_dict' | 'namedtuple' | 'dataclass' | 'pydantic';