@forthix/forthic 0.10.0 → 0.12.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/cjs/common/runtime_client.d.ts +30 -0
- package/dist/cjs/common/runtime_client.js +10 -0
- package/dist/cjs/common/runtime_client.js.map +1 -0
- package/dist/cjs/common/type_utils.d.ts +7 -1
- package/dist/cjs/common/type_utils.js +13 -2
- package/dist/cjs/common/type_utils.js.map +1 -1
- package/dist/cjs/forthic/interpreter.js +6 -3
- package/dist/cjs/forthic/interpreter.js.map +1 -1
- package/dist/cjs/forthic/modules/standard/array_module.d.ts +17 -7
- package/dist/cjs/forthic/modules/standard/array_module.js +326 -78
- package/dist/cjs/forthic/modules/standard/array_module.js.map +1 -1
- package/dist/cjs/forthic/modules/standard/boolean_module.d.ts +5 -6
- package/dist/cjs/forthic/modules/standard/boolean_module.js +43 -60
- package/dist/cjs/forthic/modules/standard/boolean_module.js.map +1 -1
- package/dist/cjs/forthic/modules/standard/classic/classic_module.d.ts +56 -0
- package/dist/cjs/forthic/modules/standard/classic/classic_module.js +616 -0
- package/dist/cjs/forthic/modules/standard/classic/classic_module.js.map +1 -0
- package/dist/cjs/forthic/modules/standard/core_module.d.ts +11 -14
- package/dist/cjs/forthic/modules/standard/core_module.js +91 -97
- package/dist/cjs/forthic/modules/standard/core_module.js.map +1 -1
- package/dist/cjs/forthic/modules/standard/datetime_module.d.ts +4 -2
- package/dist/cjs/forthic/modules/standard/datetime_module.js +39 -20
- package/dist/cjs/forthic/modules/standard/datetime_module.js.map +1 -1
- package/dist/cjs/forthic/modules/standard/json_module.d.ts +0 -1
- package/dist/cjs/forthic/modules/standard/json_module.js +0 -15
- package/dist/cjs/forthic/modules/standard/json_module.js.map +1 -1
- package/dist/cjs/forthic/modules/standard/math_module.d.ts +7 -12
- package/dist/cjs/forthic/modules/standard/math_module.js +76 -137
- package/dist/cjs/forthic/modules/standard/math_module.js.map +1 -1
- package/dist/cjs/forthic/modules/standard/record_module.d.ts +15 -4
- package/dist/cjs/forthic/modules/standard/record_module.js +311 -45
- package/dist/cjs/forthic/modules/standard/record_module.js.map +1 -1
- package/dist/cjs/forthic/modules/standard/string_module.d.ts +14 -6
- package/dist/cjs/forthic/modules/standard/string_module.js +183 -60
- package/dist/cjs/forthic/modules/standard/string_module.js.map +1 -1
- package/dist/cjs/forthic/tokenizer.js +29 -1
- package/dist/cjs/forthic/tokenizer.js.map +1 -1
- package/dist/cjs/grpc/config_loader.d.ts +3 -0
- package/dist/cjs/grpc/config_loader.js +5 -0
- package/dist/cjs/grpc/config_loader.js.map +1 -1
- package/dist/cjs/grpc/remote_module.d.ts +3 -3
- package/dist/cjs/grpc/remote_module.js +1 -1
- package/dist/cjs/grpc/remote_module.js.map +1 -1
- package/dist/cjs/grpc/remote_word.d.ts +3 -3
- package/dist/cjs/grpc/remote_word.js +1 -1
- package/dist/cjs/grpc/remote_word.js.map +1 -1
- package/dist/cjs/grpc/runtime_manager.d.ts +5 -4
- package/dist/cjs/grpc/runtime_manager.js +2 -2
- package/dist/cjs/grpc/runtime_manager.js.map +1 -1
- package/dist/cjs/grpc/serializer.d.ts +2 -2
- package/dist/cjs/grpc/serializer.js +11 -10
- package/dist/cjs/grpc/serializer.js.map +1 -1
- package/dist/cjs/jsonrpc/browser-stub.d.ts +8 -0
- package/dist/cjs/jsonrpc/browser-stub.js +18 -0
- package/dist/cjs/jsonrpc/browser-stub.js.map +1 -0
- package/dist/cjs/jsonrpc/client.d.ts +31 -0
- package/dist/cjs/jsonrpc/client.js +98 -0
- package/dist/cjs/jsonrpc/client.js.map +1 -0
- package/dist/cjs/jsonrpc/errors.d.ts +18 -0
- package/dist/cjs/jsonrpc/errors.js +23 -0
- package/dist/cjs/jsonrpc/errors.js.map +1 -0
- package/dist/cjs/jsonrpc/index.d.ts +16 -0
- package/dist/cjs/jsonrpc/index.js +26 -0
- package/dist/cjs/jsonrpc/index.js.map +1 -0
- package/dist/cjs/jsonrpc/serializer.d.ts +8 -0
- package/dist/cjs/jsonrpc/serializer.js +14 -0
- package/dist/cjs/jsonrpc/serializer.js.map +1 -0
- package/dist/cjs/jsonrpc/server.d.ts +15 -0
- package/dist/cjs/jsonrpc/server.js +386 -0
- package/dist/cjs/jsonrpc/server.js.map +1 -0
- package/dist/cjs/websocket/serializer.d.ts +4 -4
- package/dist/cjs/websocket/serializer.js +15 -14
- package/dist/cjs/websocket/serializer.js.map +1 -1
- package/dist/esm/common/runtime_client.d.ts +30 -0
- package/dist/esm/common/runtime_client.js +9 -0
- package/dist/esm/common/runtime_client.js.map +1 -0
- package/dist/esm/common/type_utils.d.ts +7 -1
- package/dist/esm/common/type_utils.js +12 -2
- package/dist/esm/common/type_utils.js.map +1 -1
- package/dist/esm/forthic/interpreter.js +6 -3
- package/dist/esm/forthic/interpreter.js.map +1 -1
- package/dist/esm/forthic/modules/standard/array_module.d.ts +17 -7
- package/dist/esm/forthic/modules/standard/array_module.js +293 -72
- package/dist/esm/forthic/modules/standard/array_module.js.map +1 -1
- package/dist/esm/forthic/modules/standard/boolean_module.d.ts +5 -6
- package/dist/esm/forthic/modules/standard/boolean_module.js +38 -54
- package/dist/esm/forthic/modules/standard/boolean_module.js.map +1 -1
- package/dist/esm/forthic/modules/standard/classic/classic_module.d.ts +56 -0
- package/dist/esm/forthic/modules/standard/classic/classic_module.js +500 -0
- package/dist/esm/forthic/modules/standard/classic/classic_module.js.map +1 -0
- package/dist/esm/forthic/modules/standard/core_module.d.ts +11 -14
- package/dist/esm/forthic/modules/standard/core_module.js +76 -82
- package/dist/esm/forthic/modules/standard/core_module.js.map +1 -1
- package/dist/esm/forthic/modules/standard/datetime_module.d.ts +4 -2
- package/dist/esm/forthic/modules/standard/datetime_module.js +30 -17
- package/dist/esm/forthic/modules/standard/datetime_module.js.map +1 -1
- package/dist/esm/forthic/modules/standard/json_module.d.ts +0 -1
- package/dist/esm/forthic/modules/standard/json_module.js +0 -12
- package/dist/esm/forthic/modules/standard/json_module.js.map +1 -1
- package/dist/esm/forthic/modules/standard/math_module.d.ts +7 -12
- package/dist/esm/forthic/modules/standard/math_module.js +69 -117
- package/dist/esm/forthic/modules/standard/math_module.js.map +1 -1
- package/dist/esm/forthic/modules/standard/record_module.d.ts +15 -4
- package/dist/esm/forthic/modules/standard/record_module.js +292 -44
- package/dist/esm/forthic/modules/standard/record_module.js.map +1 -1
- package/dist/esm/forthic/modules/standard/string_module.d.ts +14 -6
- package/dist/esm/forthic/modules/standard/string_module.js +151 -54
- package/dist/esm/forthic/modules/standard/string_module.js.map +1 -1
- package/dist/esm/forthic/tokenizer.js +29 -1
- package/dist/esm/forthic/tokenizer.js.map +1 -1
- package/dist/esm/grpc/config_loader.d.ts +3 -0
- package/dist/esm/grpc/config_loader.js +5 -0
- package/dist/esm/grpc/config_loader.js.map +1 -1
- package/dist/esm/grpc/remote_module.d.ts +3 -3
- package/dist/esm/grpc/remote_module.js +1 -1
- package/dist/esm/grpc/remote_module.js.map +1 -1
- package/dist/esm/grpc/remote_word.d.ts +3 -3
- package/dist/esm/grpc/remote_word.js +1 -1
- package/dist/esm/grpc/remote_word.js.map +1 -1
- package/dist/esm/grpc/runtime_manager.d.ts +5 -4
- package/dist/esm/grpc/runtime_manager.js +2 -2
- package/dist/esm/grpc/runtime_manager.js.map +1 -1
- package/dist/esm/grpc/serializer.d.ts +2 -2
- package/dist/esm/grpc/serializer.js +12 -11
- package/dist/esm/grpc/serializer.js.map +1 -1
- package/dist/esm/jsonrpc/browser-stub.d.ts +8 -0
- package/dist/esm/jsonrpc/browser-stub.js +12 -0
- package/dist/esm/jsonrpc/browser-stub.js.map +1 -0
- package/dist/esm/jsonrpc/client.d.ts +31 -0
- package/dist/esm/jsonrpc/client.js +94 -0
- package/dist/esm/jsonrpc/client.js.map +1 -0
- package/dist/esm/jsonrpc/errors.d.ts +18 -0
- package/dist/esm/jsonrpc/errors.js +18 -0
- package/dist/esm/jsonrpc/errors.js.map +1 -0
- package/dist/esm/jsonrpc/index.d.ts +16 -0
- package/dist/esm/jsonrpc/index.js +16 -0
- package/dist/esm/jsonrpc/index.js.map +1 -0
- package/dist/esm/jsonrpc/serializer.d.ts +8 -0
- package/dist/esm/jsonrpc/serializer.js +9 -0
- package/dist/esm/jsonrpc/serializer.js.map +1 -0
- package/dist/esm/jsonrpc/server.d.ts +15 -0
- package/dist/esm/jsonrpc/server.js +349 -0
- package/dist/esm/jsonrpc/server.js.map +1 -0
- package/dist/esm/websocket/serializer.d.ts +4 -4
- package/dist/esm/websocket/serializer.js +16 -15
- package/dist/esm/websocket/serializer.js.map +1 -1
- package/package.json +15 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime_manager.js","sourceRoot":"","sources":["../../../src/grpc/runtime_manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime_manager.js","sourceRoot":"","sources":["../../../src/grpc/runtime_manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC;;GAEG;AACH,MAAM,OAAO,cAAc;IACjB,MAAM,CAAC,QAAQ,GAA0B,IAAI,CAAC;IAC9C,OAAO,CAA6B;IAE5C;QACE,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;YAC7B,cAAc,CAAC,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;QACjD,CAAC;QACD,OAAO,cAAc,CAAC,QAAQ,CAAC;IACjC,CAAC;IAED;;;;;;;OAOG;IACH,cAAc,CAAC,WAAmB,EAAE,OAAe;QACjD,sCAAsC;QACtC,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;QAEvC,cAAc;QACd,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAEtC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACH,cAAc,CAAC,WAAmB,EAAE,MAAqB;QACvD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACH,SAAS,CAAC,WAAmB;QAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;IAED;;;;;OAKG;IACH,SAAS,CAAC,WAAmB;QAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;IAED;;;;OAIG;IACH,qBAAqB;QACnB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,oBAAoB;QACpB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YAC3C,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK;QACV,IAAI,cAAc,CAAC,QAAQ,EAAE,CAAC;YAC5B,cAAc,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACnC,cAAc,CAAC,QAAQ,GAAG,IAAI,CAAC;QACjC,CAAC;IACH,CAAC"}
|
|
@@ -37,9 +37,9 @@ interface ZonedDateTimeValue {
|
|
|
37
37
|
* Serialize a JavaScript value to a StackValue protobuf message
|
|
38
38
|
* Uses shared type detection and maps to protobuf format
|
|
39
39
|
*/
|
|
40
|
-
export declare function serializeValue(value: any): StackValue;
|
|
40
|
+
export declare function serializeValue(value: any, path?: string): StackValue;
|
|
41
41
|
/**
|
|
42
42
|
* Deserialize a StackValue protobuf message to a JavaScript value
|
|
43
43
|
*/
|
|
44
|
-
export declare function deserializeValue(stackValue: StackValue): any;
|
|
44
|
+
export declare function deserializeValue(stackValue: StackValue, path?: string): any;
|
|
45
45
|
export {};
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Converts JavaScript values to/from protobuf StackValue format
|
|
4
4
|
* Uses shared type detection from common/type_utils
|
|
5
5
|
*/
|
|
6
|
-
import { getForthicType } from "../common/type_utils.js";
|
|
6
|
+
import { getForthicType, pathSegmentForKey } from "../common/type_utils.js";
|
|
7
7
|
/**
|
|
8
8
|
* Serialize a JavaScript value to a StackValue protobuf message
|
|
9
9
|
* Uses shared type detection and maps to protobuf format
|
|
10
10
|
*/
|
|
11
|
-
export function serializeValue(value) {
|
|
12
|
-
const type = getForthicType(value);
|
|
11
|
+
export function serializeValue(value, path = '') {
|
|
12
|
+
const type = getForthicType(value, path);
|
|
13
13
|
switch (type) {
|
|
14
14
|
case 'null':
|
|
15
15
|
return { null_value: {} };
|
|
@@ -24,15 +24,16 @@ export function serializeValue(value) {
|
|
|
24
24
|
case 'array':
|
|
25
25
|
return {
|
|
26
26
|
array_value: {
|
|
27
|
-
items: value.map((item) => serializeValue(item)),
|
|
27
|
+
items: value.map((item, i) => serializeValue(item, `${path}[${i}]`)),
|
|
28
28
|
},
|
|
29
29
|
};
|
|
30
|
-
case 'record':
|
|
30
|
+
case 'record': {
|
|
31
31
|
const fields = {};
|
|
32
32
|
for (const [key, val] of Object.entries(value)) {
|
|
33
|
-
fields[key] = serializeValue(val);
|
|
33
|
+
fields[key] = serializeValue(val, `${path}${pathSegmentForKey(key)}`);
|
|
34
34
|
}
|
|
35
35
|
return { record_value: { fields } };
|
|
36
|
+
}
|
|
36
37
|
case 'instant':
|
|
37
38
|
return {
|
|
38
39
|
instant_value: {
|
|
@@ -53,13 +54,13 @@ export function serializeValue(value) {
|
|
|
53
54
|
},
|
|
54
55
|
};
|
|
55
56
|
default:
|
|
56
|
-
throw new Error(`Unsupported Forthic type: ${type}`);
|
|
57
|
+
throw new Error(`Unsupported Forthic type: ${type}${path ? ` at path: ${path}` : ''}`);
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
/**
|
|
60
61
|
* Deserialize a StackValue protobuf message to a JavaScript value
|
|
61
62
|
*/
|
|
62
|
-
export function deserializeValue(stackValue) {
|
|
63
|
+
export function deserializeValue(stackValue, path = '') {
|
|
63
64
|
if ('int_value' in stackValue) {
|
|
64
65
|
return stackValue.int_value;
|
|
65
66
|
}
|
|
@@ -86,15 +87,15 @@ export function deserializeValue(stackValue) {
|
|
|
86
87
|
return Temporal.ZonedDateTime.from(stackValue.zoned_datetime_value.iso8601);
|
|
87
88
|
}
|
|
88
89
|
if ('array_value' in stackValue && stackValue.array_value) {
|
|
89
|
-
return stackValue.array_value.items.map((item) => deserializeValue(item));
|
|
90
|
+
return stackValue.array_value.items.map((item, i) => deserializeValue(item, `${path}[${i}]`));
|
|
90
91
|
}
|
|
91
92
|
if ('record_value' in stackValue && stackValue.record_value) {
|
|
92
93
|
const result = {};
|
|
93
94
|
for (const [key, val] of Object.entries(stackValue.record_value.fields)) {
|
|
94
|
-
result[key] = deserializeValue(val);
|
|
95
|
+
result[key] = deserializeValue(val, `${path}${pathSegmentForKey(key)}`);
|
|
95
96
|
}
|
|
96
97
|
return result;
|
|
97
98
|
}
|
|
98
|
-
throw new Error(
|
|
99
|
+
throw new Error(`Unknown stack value type${path ? ` at path: ${path}` : ''}`);
|
|
99
100
|
}
|
|
100
101
|
//# sourceMappingURL=serializer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../../src/grpc/serializer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../../src/grpc/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
* fetch-based and works in browsers, but the server depends on Node's
|
|
4
|
+
* `http` module and is unavailable in browser bundles.
|
|
5
|
+
*/
|
|
6
|
+
export declare function startJsonRpcServer(): never;
|
|
7
|
+
export { JsonRpcClient } from './client.js';
|
|
8
|
+
export { JsonRpcErrorCode } from './errors.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser stub for the JSON-RPC server. The JsonRpcClient itself is
|
|
3
|
+
* fetch-based and works in browsers, but the server depends on Node's
|
|
4
|
+
* `http` module and is unavailable in browser bundles.
|
|
5
|
+
*/
|
|
6
|
+
const BROWSER_SERVER_ERROR = 'startJsonRpcServer is only available in Node.js environments.';
|
|
7
|
+
export function startJsonRpcServer() {
|
|
8
|
+
throw new Error(BROWSER_SERVER_ERROR);
|
|
9
|
+
}
|
|
10
|
+
export { JsonRpcClient } from './client.js';
|
|
11
|
+
export { JsonRpcErrorCode } from './errors.js';
|
|
12
|
+
//# sourceMappingURL=browser-stub.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-stub.js","sourceRoot":"","sources":["../../../src/jsonrpc/browser-stub.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,oBAAoB,GACxB,+DAA+D,CAAC;AAElE,MAAM,UAAU,kBAAkB;IAChC,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;AACxC,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RuntimeClient, ModuleSummary, GetModuleInfoResponse } from '../common/runtime_client.js';
|
|
2
|
+
export type { ModuleSummary, GetModuleInfoResponse, WordInfo } from '../common/runtime_client.js';
|
|
3
|
+
type FetchLike = (url: string, init?: any) => Promise<{
|
|
4
|
+
ok: boolean;
|
|
5
|
+
status: number;
|
|
6
|
+
statusText: string;
|
|
7
|
+
text(): Promise<string>;
|
|
8
|
+
}>;
|
|
9
|
+
export interface JsonRpcClientOptions {
|
|
10
|
+
/** Custom fetch implementation; defaults to global fetch. */
|
|
11
|
+
fetchImpl?: FetchLike;
|
|
12
|
+
/** Optional path; defaults to /rpc. */
|
|
13
|
+
path?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare class JsonRpcClient implements RuntimeClient {
|
|
16
|
+
private endpoint;
|
|
17
|
+
private fetchImpl;
|
|
18
|
+
private nextId;
|
|
19
|
+
/**
|
|
20
|
+
* @param address - "host:port" or full URL. "host:port" is rewritten as
|
|
21
|
+
* `http://host:port<path>`. A full URL is used as-is and
|
|
22
|
+
* the `path` option is ignored.
|
|
23
|
+
*/
|
|
24
|
+
constructor(address?: string, options?: JsonRpcClientOptions);
|
|
25
|
+
executeWord(wordName: string, stack: any[]): Promise<any[]>;
|
|
26
|
+
executeSequence(wordNames: string[], stack: any[]): Promise<any[]>;
|
|
27
|
+
listModules(): Promise<ModuleSummary[]>;
|
|
28
|
+
getModuleInfo(moduleName: string): Promise<GetModuleInfoResponse>;
|
|
29
|
+
close(): void;
|
|
30
|
+
private call;
|
|
31
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-RPC 2.0 client for Forthic — speaks the same surface as GrpcClient
|
|
3
|
+
* (executeWord / executeSequence / listModules / getModuleInfo) so it can
|
|
4
|
+
* be used interchangeably via the RuntimeClient interface.
|
|
5
|
+
*
|
|
6
|
+
* Uses the global `fetch` (Node ≥18). For older Node, inject your own
|
|
7
|
+
* fetch via the constructor's `fetchImpl` option.
|
|
8
|
+
*/
|
|
9
|
+
import { serializeValue, deserializeValue } from '../grpc/serializer.js';
|
|
10
|
+
import { RemoteRuntimeError, parseErrorInfo } from '../grpc/errors.js';
|
|
11
|
+
import { JsonRpcErrorCode } from './errors.js';
|
|
12
|
+
export class JsonRpcClient {
|
|
13
|
+
endpoint;
|
|
14
|
+
fetchImpl;
|
|
15
|
+
nextId = 1;
|
|
16
|
+
/**
|
|
17
|
+
* @param address - "host:port" or full URL. "host:port" is rewritten as
|
|
18
|
+
* `http://host:port<path>`. A full URL is used as-is and
|
|
19
|
+
* the `path` option is ignored.
|
|
20
|
+
*/
|
|
21
|
+
constructor(address = 'localhost:8765', options = {}) {
|
|
22
|
+
const path = options.path ?? '/rpc';
|
|
23
|
+
if (/^https?:\/\//i.test(address)) {
|
|
24
|
+
this.endpoint = address;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this.endpoint = `http://${address}${path}`;
|
|
28
|
+
}
|
|
29
|
+
const fetchImpl = options.fetchImpl ?? globalThis.fetch;
|
|
30
|
+
if (typeof fetchImpl !== 'function') {
|
|
31
|
+
throw new Error('JsonRpcClient requires a fetch implementation. Use Node ≥18 or pass options.fetchImpl.');
|
|
32
|
+
}
|
|
33
|
+
this.fetchImpl = fetchImpl;
|
|
34
|
+
}
|
|
35
|
+
async executeWord(wordName, stack) {
|
|
36
|
+
const result = await this.call('executeWord', {
|
|
37
|
+
word_name: wordName,
|
|
38
|
+
stack: stack.map((v) => serializeValue(v)),
|
|
39
|
+
});
|
|
40
|
+
return (result.result_stack ?? []).map((v) => deserializeValue(v));
|
|
41
|
+
}
|
|
42
|
+
async executeSequence(wordNames, stack) {
|
|
43
|
+
const result = await this.call('executeSequence', {
|
|
44
|
+
word_names: wordNames,
|
|
45
|
+
stack: stack.map((v) => serializeValue(v)),
|
|
46
|
+
});
|
|
47
|
+
return (result.result_stack ?? []).map((v) => deserializeValue(v));
|
|
48
|
+
}
|
|
49
|
+
async listModules() {
|
|
50
|
+
const result = await this.call('listModules', {});
|
|
51
|
+
return result.modules ?? [];
|
|
52
|
+
}
|
|
53
|
+
async getModuleInfo(moduleName) {
|
|
54
|
+
return await this.call('getModuleInfo', { module_name: moduleName });
|
|
55
|
+
}
|
|
56
|
+
close() {
|
|
57
|
+
// Stateless over HTTP — nothing to close.
|
|
58
|
+
}
|
|
59
|
+
async call(method, params) {
|
|
60
|
+
const id = this.nextId++;
|
|
61
|
+
const body = JSON.stringify({ jsonrpc: '2.0', id, method, params });
|
|
62
|
+
let response;
|
|
63
|
+
try {
|
|
64
|
+
response = await this.fetchImpl(this.endpoint, {
|
|
65
|
+
method: 'POST',
|
|
66
|
+
headers: { 'Content-Type': 'application/json' },
|
|
67
|
+
body,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
throw new Error(`JSON-RPC transport error: ${err?.message ?? String(err)}`);
|
|
72
|
+
}
|
|
73
|
+
const text = await response.text();
|
|
74
|
+
if (!response.ok && !text) {
|
|
75
|
+
throw new Error(`JSON-RPC HTTP ${response.status}: ${response.statusText}`);
|
|
76
|
+
}
|
|
77
|
+
let envelope;
|
|
78
|
+
try {
|
|
79
|
+
envelope = JSON.parse(text);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
throw new Error(`JSON-RPC parse error (HTTP ${response.status}): ${err?.message ?? String(err)}`);
|
|
83
|
+
}
|
|
84
|
+
if (envelope.error) {
|
|
85
|
+
const { code, message, data } = envelope.error;
|
|
86
|
+
if (code === JsonRpcErrorCode.RuntimeError && data && typeof data === 'object') {
|
|
87
|
+
throw new RemoteRuntimeError(parseErrorInfo(data));
|
|
88
|
+
}
|
|
89
|
+
throw new Error(`JSON-RPC error ${code}: ${message}`);
|
|
90
|
+
}
|
|
91
|
+
return envelope.result;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/jsonrpc/client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAMvE,OAAO,E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EAAE,CAAC,CAAC;QAC9E,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,iBAAiB,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;QAC9E,CAAC;QAED,IAAI,QAAiC,CAAC;QACtC,IAAI,CAAC;YACH,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACb,8BAA8B,QAAQ,CAAC,MAAM,MAAM,GAAG,EAAE,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE,CACjF,CAAC;QACJ,CAAC;QAED,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;YACnB,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC;YAC/C,IAAI,IAAI,KAAK,gBAAgB,CAAC,YAAY,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC/E,MAAM,IAAI,kBAAkB,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;YACrD,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;QACxD,CAAC;QAED,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-RPC error types — reuses gRPC's RemoteRuntimeError + parseErrorInfo
|
|
3
|
+
* for the structured `data` payload of code -32000 responses.
|
|
4
|
+
*/
|
|
5
|
+
export { RemoteRuntimeError, parseErrorInfo, type RemoteErrorInfo, } from '../grpc/errors.js';
|
|
6
|
+
/** JSON-RPC standard error codes plus our custom server-defined codes. */
|
|
7
|
+
export declare const JsonRpcErrorCode: {
|
|
8
|
+
readonly ParseError: -32700;
|
|
9
|
+
readonly InvalidRequest: -32600;
|
|
10
|
+
readonly MethodNotFound: -32601;
|
|
11
|
+
readonly InvalidParams: -32602;
|
|
12
|
+
readonly InternalError: -32603;
|
|
13
|
+
/** Forthic runtime error — `data` carries the full ErrorInfo. */
|
|
14
|
+
readonly RuntimeError: -32000;
|
|
15
|
+
/** Unknown module name passed to getModuleInfo. */
|
|
16
|
+
readonly ModuleNotFound: -32001;
|
|
17
|
+
};
|
|
18
|
+
export type JsonRpcErrorCodeValue = (typeof JsonRpcErrorCode)[keyof typeof JsonRpcErrorCode];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-RPC error types — reuses gRPC's RemoteRuntimeError + parseErrorInfo
|
|
3
|
+
* for the structured `data` payload of code -32000 responses.
|
|
4
|
+
*/
|
|
5
|
+
export { RemoteRuntimeError, parseErrorInfo, } from '../grpc/errors.js';
|
|
6
|
+
/** JSON-RPC standard error codes plus our custom server-defined codes. */
|
|
7
|
+
export const JsonRpcErrorCode = {
|
|
8
|
+
ParseError: -32700,
|
|
9
|
+
InvalidRequest: -32600,
|
|
10
|
+
MethodNotFound: -32601,
|
|
11
|
+
InvalidParams: -32602,
|
|
12
|
+
InternalError: -32603,
|
|
13
|
+
/** Forthic runtime error — `data` carries the full ErrorInfo. */
|
|
14
|
+
RuntimeError: -32000,
|
|
15
|
+
/** Unknown module name passed to getModuleInfo. */
|
|
16
|
+
ModuleNotFound: -32001,
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/jsonrpc/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,kBAAkB,EAClB,cAAc,GAEf,MAAM,mBAAmB,CAAC;AAE3B,0EAA0E;AAC1E,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,UAAU,EAAE,CAAC,KAAK;IAClB,cAAc,EAAE,CAAC,KAAK;IACtB,cAAc,EAAE,CAAC,KAAK;IACtB,aAAa,EAAE,CAAC,KAAK;IACrB,aAAa,EAAE,CAAC,KAAK;IACrB,iEAAiE;IACjE,YAAY,EAAE,CAAC,KAAK;IACpB,mDAAmD;IACnD,cAAc,EAAE,CAAC,KAAK;CACd,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-RPC module for Node.js multi-runtime execution.
|
|
3
|
+
* Server uses Node's built-in http; client uses global fetch (Node ≥18).
|
|
4
|
+
*
|
|
5
|
+
* Mirrors @forthix/forthic/grpc surface so RuntimeManager / RemoteModule /
|
|
6
|
+
* RemoteWord work transparently against either transport.
|
|
7
|
+
*/
|
|
8
|
+
export { JsonRpcClient } from './client.js';
|
|
9
|
+
export { serve as startJsonRpcServer } from './server.js';
|
|
10
|
+
export { JsonRpcErrorCode } from './errors.js';
|
|
11
|
+
export { RemoteRuntimeError } from '../grpc/errors.js';
|
|
12
|
+
export { RemoteModule } from '../grpc/remote_module.js';
|
|
13
|
+
export { RuntimeManager } from '../grpc/runtime_manager.js';
|
|
14
|
+
export { ConfigLoader } from '../grpc/config_loader.js';
|
|
15
|
+
export type { ModuleSummary, WordInfo, GetModuleInfoResponse, RuntimeClient, } from '../common/runtime_client.js';
|
|
16
|
+
export type { RuntimeConfig, ForthicRuntimesConfig, ConnectionSettings, RuntimeTransport, } from '../grpc/config_loader.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-RPC module for Node.js multi-runtime execution.
|
|
3
|
+
* Server uses Node's built-in http; client uses global fetch (Node ≥18).
|
|
4
|
+
*
|
|
5
|
+
* Mirrors @forthix/forthic/grpc surface so RuntimeManager / RemoteModule /
|
|
6
|
+
* RemoteWord work transparently against either transport.
|
|
7
|
+
*/
|
|
8
|
+
export { JsonRpcClient } from './client.js';
|
|
9
|
+
export { serve as startJsonRpcServer } from './server.js';
|
|
10
|
+
export { JsonRpcErrorCode } from './errors.js';
|
|
11
|
+
export { RemoteRuntimeError } from '../grpc/errors.js';
|
|
12
|
+
// Reuse existing pieces: they already accept any RuntimeClient implementation.
|
|
13
|
+
export { RemoteModule } from '../grpc/remote_module.js';
|
|
14
|
+
export { RuntimeManager } from '../grpc/runtime_manager.js';
|
|
15
|
+
export { ConfigLoader } from '../grpc/config_loader.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/jsonrpc/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,KAAK,IAAI,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,+EAA+E;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-RPC serializer — re-exports the gRPC serializer.
|
|
3
|
+
*
|
|
4
|
+
* The StackValue tagged-union shape (`{ int_value }`, `{ string_value }`,
|
|
5
|
+
* `{ array_value: { items: [...] } }`, etc.) is JSON-clean, so the same
|
|
6
|
+
* (serializeValue, deserializeValue) functions work for both transports.
|
|
7
|
+
*/
|
|
8
|
+
export { serializeValue, deserializeValue } from '../grpc/serializer.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-RPC serializer — re-exports the gRPC serializer.
|
|
3
|
+
*
|
|
4
|
+
* The StackValue tagged-union shape (`{ int_value }`, `{ string_value }`,
|
|
5
|
+
* `{ array_value: { items: [...] } }`, etc.) is JSON-clean, so the same
|
|
6
|
+
* (serializeValue, deserializeValue) functions work for both transports.
|
|
7
|
+
*/
|
|
8
|
+
export { serializeValue, deserializeValue } from '../grpc/serializer.js';
|
|
9
|
+
//# sourceMappingURL=serializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../../src/jsonrpc/serializer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript JSON-RPC 2.0 Server for Forthic
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the four methods of the gRPC server:
|
|
5
|
+
* executeWord, executeSequence, listModules, getModuleInfo
|
|
6
|
+
*
|
|
7
|
+
* Transport: HTTP POST /rpc with JSON-RPC 2.0 envelopes.
|
|
8
|
+
* Uses Node's built-in `http` module — zero new dependencies.
|
|
9
|
+
*
|
|
10
|
+
* `executeSequence` is a single JSON-RPC call with an array of words; it is
|
|
11
|
+
* NOT a JSON-RPC batch. Batch envelopes are rejected with code -32600.
|
|
12
|
+
*/
|
|
13
|
+
import * as http from 'http';
|
|
14
|
+
export declare function serve(port?: number): Promise<http.Server>;
|
|
15
|
+
export declare function main(): Promise<void>;
|