@comake/skl-js-engine 1.5.3 → 1.5.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/package.json +1 -1
- package/src/util/TripleUtil.ts +22 -2
- package/dist/JsExecutor/PermissionBuilder.d.ts +0 -14
- package/dist/JsExecutor/PermissionBuilder.d.ts.map +0 -1
- package/dist/JsExecutor/PermissionBuilder.js +0 -58
- package/dist/JsExecutor/PermissionBuilder.js.map +0 -1
- package/dist/JsExecutor/constants.d.ts +0 -27
- package/dist/JsExecutor/constants.d.ts.map +0 -1
- package/dist/JsExecutor/constants.js +0 -30
- package/dist/JsExecutor/constants.js.map +0 -1
- package/dist/JsExecutor/denoUtils.d.ts +0 -10
- package/dist/JsExecutor/denoUtils.d.ts.map +0 -1
- package/dist/JsExecutor/denoUtils.js +0 -24
- package/dist/JsExecutor/denoUtils.js.map +0 -1
- package/dist/JsExecutor/errors.d.ts +0 -40
- package/dist/JsExecutor/errors.d.ts.map +0 -1
- package/dist/JsExecutor/errors.js +0 -67
- package/dist/JsExecutor/errors.js.map +0 -1
- package/dist/JsExecutor/examples/basic/index.d.ts +0 -1
- package/dist/JsExecutor/examples/basic/index.d.ts.map +0 -1
- package/dist/JsExecutor/examples/basic/index.js +0 -46
- package/dist/JsExecutor/examples/basic/index.js.map +0 -1
- package/dist/JsExecutor/examples/basic/process.d.ts +0 -1
- package/dist/JsExecutor/examples/basic/process.d.ts.map +0 -1
- package/dist/JsExecutor/examples/basic/process.js +0 -34
- package/dist/JsExecutor/examples/basic/process.js.map +0 -1
- package/dist/JsExecutor/examples/jsExecutor/index.d.ts +0 -2
- package/dist/JsExecutor/examples/jsExecutor/index.d.ts.map +0 -1
- package/dist/JsExecutor/examples/jsExecutor/index.js +0 -47
- package/dist/JsExecutor/examples/jsExecutor/index.js.map +0 -1
- package/dist/JsExecutor/examples/jsExecutor/process.d.ts +0 -2
- package/dist/JsExecutor/examples/jsExecutor/process.d.ts.map +0 -1
- package/dist/JsExecutor/examples/jsExecutor/process.js +0 -58
- package/dist/JsExecutor/examples/jsExecutor/process.js.map +0 -1
- package/dist/JsExecutor/index.d.ts +0 -7
- package/dist/JsExecutor/index.d.ts.map +0 -1
- package/dist/JsExecutor/index.js +0 -36
- package/dist/JsExecutor/index.js.map +0 -1
- package/dist/JsExecutor/jsExecutor.d.ts +0 -68
- package/dist/JsExecutor/jsExecutor.d.ts.map +0 -1
- package/dist/JsExecutor/jsExecutor.js +0 -171
- package/dist/JsExecutor/jsExecutor.js.map +0 -1
- package/dist/JsExecutor/jsonRpc/JsonRpcClient.d.ts +0 -165
- package/dist/JsExecutor/jsonRpc/JsonRpcClient.d.ts.map +0 -1
- package/dist/JsExecutor/jsonRpc/JsonRpcClient.js +0 -335
- package/dist/JsExecutor/jsonRpc/JsonRpcClient.js.map +0 -1
- package/dist/JsExecutor/jsonRpc/JsonRpcServer.d.ts +0 -125
- package/dist/JsExecutor/jsonRpc/JsonRpcServer.d.ts.map +0 -1
- package/dist/JsExecutor/jsonRpc/JsonRpcServer.js +0 -391
- package/dist/JsExecutor/jsonRpc/JsonRpcServer.js.map +0 -1
- package/dist/JsExecutor/jsonRpc/index.d.ts +0 -4
- package/dist/JsExecutor/jsonRpc/index.d.ts.map +0 -1
- package/dist/JsExecutor/jsonRpc/index.js +0 -23
- package/dist/JsExecutor/jsonRpc/index.js.map +0 -1
- package/dist/JsExecutor/jsonRpc/types.d.ts +0 -193
- package/dist/JsExecutor/jsonRpc/types.d.ts.map +0 -1
- package/dist/JsExecutor/jsonRpc/types.js +0 -37
- package/dist/JsExecutor/jsonRpc/types.js.map +0 -1
- package/dist/JsExecutor/transport/Transport.d.ts +0 -74
- package/dist/JsExecutor/transport/Transport.d.ts.map +0 -1
- package/dist/JsExecutor/transport/Transport.js +0 -14
- package/dist/JsExecutor/transport/Transport.js.map +0 -1
- package/dist/JsExecutor/transport/base/BaseTransport.d.ts +0 -51
- package/dist/JsExecutor/transport/base/BaseTransport.d.ts.map +0 -1
- package/dist/JsExecutor/transport/base/BaseTransport.js +0 -68
- package/dist/JsExecutor/transport/base/BaseTransport.js.map +0 -1
- package/dist/JsExecutor/transport/index.d.ts +0 -13
- package/dist/JsExecutor/transport/index.d.ts.map +0 -1
- package/dist/JsExecutor/transport/index.js +0 -36
- package/dist/JsExecutor/transport/index.js.map +0 -1
- package/dist/JsExecutor/transport/process/ProcessManager.d.ts +0 -96
- package/dist/JsExecutor/transport/process/ProcessManager.d.ts.map +0 -1
- package/dist/JsExecutor/transport/process/ProcessManager.js +0 -219
- package/dist/JsExecutor/transport/process/ProcessManager.js.map +0 -1
- package/dist/JsExecutor/transport/stdio/ChildStdioTransport.d.ts +0 -87
- package/dist/JsExecutor/transport/stdio/ChildStdioTransport.d.ts.map +0 -1
- package/dist/JsExecutor/transport/stdio/ChildStdioTransport.js +0 -219
- package/dist/JsExecutor/transport/stdio/ChildStdioTransport.js.map +0 -1
- package/dist/JsExecutor/transport/stdio/ParentStdioTransport.d.ts +0 -81
- package/dist/JsExecutor/transport/stdio/ParentStdioTransport.d.ts.map +0 -1
- package/dist/JsExecutor/transport/stdio/ParentStdioTransport.js +0 -259
- package/dist/JsExecutor/transport/stdio/ParentStdioTransport.js.map +0 -1
- package/dist/JsExecutor/transport/utils/MessageUtils.d.ts +0 -68
- package/dist/JsExecutor/transport/utils/MessageUtils.d.ts.map +0 -1
- package/dist/JsExecutor/transport/utils/MessageUtils.js +0 -135
- package/dist/JsExecutor/transport/utils/MessageUtils.js.map +0 -1
- package/dist/JsExecutor/transport/utils/PollingUtils.d.ts +0 -53
- package/dist/JsExecutor/transport/utils/PollingUtils.d.ts.map +0 -1
- package/dist/JsExecutor/transport/utils/PollingUtils.js +0 -92
- package/dist/JsExecutor/transport/utils/PollingUtils.js.map +0 -1
- package/dist/JsExecutor/types.d.ts +0 -113
- package/dist/JsExecutor/types.d.ts.map +0 -1
- package/dist/JsExecutor/types.js +0 -3
- package/dist/JsExecutor/types.js.map +0 -1
- package/dist/SklEngine.d.ts +0 -132
- package/dist/SklEngine.d.ts.map +0 -1
- package/dist/SklEngine.js +0 -1508
- package/dist/SklEngine.js.map +0 -1
- package/dist/SklEngineOptions.d.ts +0 -58
- package/dist/SklEngineOptions.d.ts.map +0 -1
- package/dist/SklEngineOptions.js +0 -3
- package/dist/SklEngineOptions.js.map +0 -1
- package/dist/constants.d.ts +0 -96
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -103
- package/dist/constants.js.map +0 -1
- package/dist/customCapabilities.d.ts +0 -22
- package/dist/customCapabilities.d.ts.map +0 -1
- package/dist/customCapabilities.js +0 -45
- package/dist/customCapabilities.js.map +0 -1
- package/dist/examples/customCapabilitiesExample.d.ts +0 -2
- package/dist/examples/customCapabilitiesExample.d.ts.map +0 -1
- package/dist/examples/customCapabilitiesExample.js +0 -59
- package/dist/examples/customCapabilitiesExample.js.map +0 -1
- package/dist/executor.js +0 -216
- package/dist/hooks/globalHooks.d.ts +0 -50
- package/dist/hooks/globalHooks.d.ts.map +0 -1
- package/dist/hooks/globalHooks.js +0 -164
- package/dist/hooks/globalHooks.js.map +0 -1
- package/dist/hooks/types.d.ts +0 -9
- package/dist/hooks/types.d.ts.map +0 -1
- package/dist/hooks/types.js +0 -3
- package/dist/hooks/types.js.map +0 -1
- package/dist/index.d.ts +0 -41
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -68
- package/dist/index.js.map +0 -1
- package/dist/logger.d.ts +0 -35
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -119
- package/dist/logger.js.map +0 -1
- package/dist/mapping/Mapper.d.ts +0 -13
- package/dist/mapping/Mapper.d.ts.map +0 -1
- package/dist/mapping/Mapper.js +0 -64
- package/dist/mapping/Mapper.js.map +0 -1
- package/dist/storage/FindOperator.d.ts +0 -19
- package/dist/storage/FindOperator.d.ts.map +0 -1
- package/dist/storage/FindOperator.js +0 -23
- package/dist/storage/FindOperator.js.map +0 -1
- package/dist/storage/FindOptionsTypes.d.ts +0 -79
- package/dist/storage/FindOptionsTypes.d.ts.map +0 -1
- package/dist/storage/FindOptionsTypes.js +0 -3
- package/dist/storage/FindOptionsTypes.js.map +0 -1
- package/dist/storage/GroupOptionTypes.d.ts +0 -29
- package/dist/storage/GroupOptionTypes.d.ts.map +0 -1
- package/dist/storage/GroupOptionTypes.js +0 -3
- package/dist/storage/GroupOptionTypes.js.map +0 -1
- package/dist/storage/operator/And.d.ts +0 -4
- package/dist/storage/operator/And.d.ts.map +0 -1
- package/dist/storage/operator/And.js +0 -13
- package/dist/storage/operator/And.js.map +0 -1
- package/dist/storage/operator/Contains.d.ts +0 -3
- package/dist/storage/operator/Contains.d.ts.map +0 -1
- package/dist/storage/operator/Contains.js +0 -13
- package/dist/storage/operator/Contains.js.map +0 -1
- package/dist/storage/operator/Equal.d.ts +0 -5
- package/dist/storage/operator/Equal.d.ts.map +0 -1
- package/dist/storage/operator/Equal.js +0 -13
- package/dist/storage/operator/Equal.js.map +0 -1
- package/dist/storage/operator/Exists.d.ts +0 -3
- package/dist/storage/operator/Exists.d.ts.map +0 -1
- package/dist/storage/operator/Exists.js +0 -10
- package/dist/storage/operator/Exists.js.map +0 -1
- package/dist/storage/operator/GreaterThan.d.ts +0 -4
- package/dist/storage/operator/GreaterThan.d.ts.map +0 -1
- package/dist/storage/operator/GreaterThan.js +0 -13
- package/dist/storage/operator/GreaterThan.js.map +0 -1
- package/dist/storage/operator/GreaterThanOrEqual.d.ts +0 -4
- package/dist/storage/operator/GreaterThanOrEqual.d.ts.map +0 -1
- package/dist/storage/operator/GreaterThanOrEqual.js +0 -13
- package/dist/storage/operator/GreaterThanOrEqual.js.map +0 -1
- package/dist/storage/operator/In.d.ts +0 -4
- package/dist/storage/operator/In.d.ts.map +0 -1
- package/dist/storage/operator/In.js +0 -13
- package/dist/storage/operator/In.js.map +0 -1
- package/dist/storage/operator/Inverse.d.ts +0 -3
- package/dist/storage/operator/Inverse.d.ts.map +0 -1
- package/dist/storage/operator/Inverse.js +0 -13
- package/dist/storage/operator/Inverse.js.map +0 -1
- package/dist/storage/operator/InversePath.d.ts +0 -7
- package/dist/storage/operator/InversePath.d.ts.map +0 -1
- package/dist/storage/operator/InversePath.js +0 -13
- package/dist/storage/operator/InversePath.js.map +0 -1
- package/dist/storage/operator/InverseRelation.d.ts +0 -9
- package/dist/storage/operator/InverseRelation.d.ts.map +0 -1
- package/dist/storage/operator/InverseRelation.js +0 -13
- package/dist/storage/operator/InverseRelation.js.map +0 -1
- package/dist/storage/operator/InverseRelationOrder.d.ts +0 -8
- package/dist/storage/operator/InverseRelationOrder.d.ts.map +0 -1
- package/dist/storage/operator/InverseRelationOrder.js +0 -13
- package/dist/storage/operator/InverseRelationOrder.js.map +0 -1
- package/dist/storage/operator/LessThan.d.ts +0 -4
- package/dist/storage/operator/LessThan.d.ts.map +0 -1
- package/dist/storage/operator/LessThan.js +0 -13
- package/dist/storage/operator/LessThan.js.map +0 -1
- package/dist/storage/operator/LessThanOrEqual.d.ts +0 -4
- package/dist/storage/operator/LessThanOrEqual.d.ts.map +0 -1
- package/dist/storage/operator/LessThanOrEqual.js +0 -13
- package/dist/storage/operator/LessThanOrEqual.js.map +0 -1
- package/dist/storage/operator/Not.d.ts +0 -3
- package/dist/storage/operator/Not.d.ts.map +0 -1
- package/dist/storage/operator/Not.js +0 -13
- package/dist/storage/operator/Not.js.map +0 -1
- package/dist/storage/operator/OneOrMorePath.d.ts +0 -7
- package/dist/storage/operator/OneOrMorePath.d.ts.map +0 -1
- package/dist/storage/operator/OneOrMorePath.js +0 -13
- package/dist/storage/operator/OneOrMorePath.js.map +0 -1
- package/dist/storage/operator/Or.d.ts +0 -4
- package/dist/storage/operator/Or.d.ts.map +0 -1
- package/dist/storage/operator/Or.js +0 -13
- package/dist/storage/operator/Or.js.map +0 -1
- package/dist/storage/operator/Sequence.d.ts +0 -3
- package/dist/storage/operator/Sequence.d.ts.map +0 -1
- package/dist/storage/operator/Sequence.js +0 -13
- package/dist/storage/operator/Sequence.js.map +0 -1
- package/dist/storage/operator/SequencePath.d.ts +0 -7
- package/dist/storage/operator/SequencePath.d.ts.map +0 -1
- package/dist/storage/operator/SequencePath.js +0 -13
- package/dist/storage/operator/SequencePath.js.map +0 -1
- package/dist/storage/operator/ZeroOrMorePath.d.ts +0 -7
- package/dist/storage/operator/ZeroOrMorePath.d.ts.map +0 -1
- package/dist/storage/operator/ZeroOrMorePath.js +0 -13
- package/dist/storage/operator/ZeroOrMorePath.js.map +0 -1
- package/dist/storage/query-adapter/QueryAdapter.d.ts +0 -99
- package/dist/storage/query-adapter/QueryAdapter.d.ts.map +0 -1
- package/dist/storage/query-adapter/QueryAdapter.js +0 -3
- package/dist/storage/query-adapter/QueryAdapter.js.map +0 -1
- package/dist/storage/query-adapter/sparql/SparqlQueryAdapter.d.ts +0 -40
- package/dist/storage/query-adapter/sparql/SparqlQueryAdapter.d.ts.map +0 -1
- package/dist/storage/query-adapter/sparql/SparqlQueryAdapter.js +0 -315
- package/dist/storage/query-adapter/sparql/SparqlQueryAdapter.js.map +0 -1
- package/dist/storage/query-adapter/sparql/SparqlQueryAdapterOptions.d.ts +0 -34
- package/dist/storage/query-adapter/sparql/SparqlQueryAdapterOptions.d.ts.map +0 -1
- package/dist/storage/query-adapter/sparql/SparqlQueryAdapterOptions.js +0 -3
- package/dist/storage/query-adapter/sparql/SparqlQueryAdapterOptions.js.map +0 -1
- package/dist/storage/query-adapter/sparql/SparqlQueryBuilder.d.ts +0 -104
- package/dist/storage/query-adapter/sparql/SparqlQueryBuilder.d.ts.map +0 -1
- package/dist/storage/query-adapter/sparql/SparqlQueryBuilder.js +0 -1210
- package/dist/storage/query-adapter/sparql/SparqlQueryBuilder.js.map +0 -1
- package/dist/storage/query-adapter/sparql/SparqlUpdateBuilder.d.ts +0 -41
- package/dist/storage/query-adapter/sparql/SparqlUpdateBuilder.d.ts.map +0 -1
- package/dist/storage/query-adapter/sparql/SparqlUpdateBuilder.js +0 -305
- package/dist/storage/query-adapter/sparql/SparqlUpdateBuilder.js.map +0 -1
- package/dist/storage/query-adapter/sparql/VariableGenerator.d.ts +0 -5
- package/dist/storage/query-adapter/sparql/VariableGenerator.d.ts.map +0 -1
- package/dist/storage/query-adapter/sparql/VariableGenerator.js +0 -14
- package/dist/storage/query-adapter/sparql/VariableGenerator.js.map +0 -1
- package/dist/storage/query-adapter/sparql/query-executor/InMemorySparqlQueryExecutor.d.ts +0 -19
- package/dist/storage/query-adapter/sparql/query-executor/InMemorySparqlQueryExecutor.d.ts.map +0 -1
- package/dist/storage/query-adapter/sparql/query-executor/InMemorySparqlQueryExecutor.js +0 -90
- package/dist/storage/query-adapter/sparql/query-executor/InMemorySparqlQueryExecutor.js.map +0 -1
- package/dist/storage/query-adapter/sparql/query-executor/SparqlEndpointQueryExecutor.d.ts +0 -27
- package/dist/storage/query-adapter/sparql/query-executor/SparqlEndpointQueryExecutor.d.ts.map +0 -1
- package/dist/storage/query-adapter/sparql/query-executor/SparqlEndpointQueryExecutor.js +0 -116
- package/dist/storage/query-adapter/sparql/query-executor/SparqlEndpointQueryExecutor.js.map +0 -1
- package/dist/storage/query-adapter/sparql/query-executor/SparqlQueryExecutor.d.ts +0 -34
- package/dist/storage/query-adapter/sparql/query-executor/SparqlQueryExecutor.d.ts.map +0 -1
- package/dist/storage/query-adapter/sparql/query-executor/SparqlQueryExecutor.js +0 -3
- package/dist/storage/query-adapter/sparql/query-executor/SparqlQueryExecutor.js.map +0 -1
- package/dist/tools/explain-findall-sparql.d.ts +0 -2
- package/dist/tools/explain-findall-sparql.d.ts.map +0 -1
- package/dist/tools/explain-findall-sparql.js +0 -303
- package/dist/tools/explain-findall-sparql.js.map +0 -1
- package/dist/util/PerformanceLogger.d.ts +0 -28
- package/dist/util/PerformanceLogger.d.ts.map +0 -1
- package/dist/util/PerformanceLogger.js +0 -223
- package/dist/util/PerformanceLogger.js.map +0 -1
- package/dist/util/ReadCacheHelper.d.ts +0 -14
- package/dist/util/ReadCacheHelper.d.ts.map +0 -1
- package/dist/util/ReadCacheHelper.js +0 -61
- package/dist/util/ReadCacheHelper.js.map +0 -1
- package/dist/util/SparqlUtil.d.ts +0 -72
- package/dist/util/SparqlUtil.d.ts.map +0 -1
- package/dist/util/SparqlUtil.js +0 -456
- package/dist/util/SparqlUtil.js.map +0 -1
- package/dist/util/TripleUtil.d.ts +0 -10
- package/dist/util/TripleUtil.d.ts.map +0 -1
- package/dist/util/TripleUtil.js +0 -402
- package/dist/util/TripleUtil.js.map +0 -1
- package/dist/util/Types.d.ts +0 -271
- package/dist/util/Types.d.ts.map +0 -1
- package/dist/util/Types.js +0 -3
- package/dist/util/Types.js.map +0 -1
- package/dist/util/Util.d.ts +0 -26
- package/dist/util/Util.d.ts.map +0 -1
- package/dist/util/Util.js +0 -138
- package/dist/util/Util.js.map +0 -1
- package/dist/util/Vocabularies/Shared.d.ts +0 -13
- package/dist/util/Vocabularies/Shared.d.ts.map +0 -1
- package/dist/util/Vocabularies/Shared.js +0 -96
- package/dist/util/Vocabularies/Shared.js.map +0 -1
- package/dist/util/Vocabularies/helper.d.ts +0 -5
- package/dist/util/Vocabularies/helper.d.ts.map +0 -1
- package/dist/util/Vocabularies/helper.js +0 -10
- package/dist/util/Vocabularies/helper.js.map +0 -1
- package/dist/util/Vocabularies/index.d.ts +0 -8
- package/dist/util/Vocabularies/index.d.ts.map +0 -1
- package/dist/util/Vocabularies/index.js +0 -114
- package/dist/util/Vocabularies/index.js.map +0 -1
- package/dist/util/safeJsonStringify.d.ts +0 -1
- package/dist/util/safeJsonStringify.d.ts.map +0 -1
- package/dist/util/safeJsonStringify.js +0 -19
- package/dist/util/safeJsonStringify.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ParentStdioTransport.d.ts","sourceRoot":"","sources":["../../../../src/JsExecutor/transport/stdio/ParentStdioTransport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO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;;OAEG;IACU,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IAa7E;;OAEG;IACU,OAAO,CAAC,OAAO,GAAG,GAAG,EAAE,OAAO,GAAG,GAAG,EAC/C,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAC/C,OAAO,CAAC,OAAO,CAAC;IAOnB;;OAEG;IACU,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAOnF;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAcnC;;OAEG;IACI,OAAO,IAAI,OAAO;IAIzB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAsB1B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAsB1B;;OAEG;IACH,OAAO,CAAC,yBAAyB;IA2BjC;;OAEG;YACW,qBAAqB;IAiCnC;;OAEG;YACW,YAAY;CAe3B"}
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ParentStdioTransport = exports.StdioClientTransport = void 0;
|
|
4
|
-
const logger_1 = require("../../../logger");
|
|
5
|
-
const JsonRpcClient_1 = require("../../jsonRpc/JsonRpcClient");
|
|
6
|
-
const types_1 = require("../../jsonRpc/types");
|
|
7
|
-
const BaseTransport_1 = require("../base/BaseTransport");
|
|
8
|
-
const ProcessManager_1 = require("../process/ProcessManager");
|
|
9
|
-
const Transport_1 = require("../Transport");
|
|
10
|
-
const MessageUtils_1 = require("../utils/MessageUtils");
|
|
11
|
-
const PollingUtils_1 = require("../utils/PollingUtils");
|
|
12
|
-
/**
|
|
13
|
-
* Client transport implementation for stdio communication
|
|
14
|
-
*/
|
|
15
|
-
class StdioClientTransport {
|
|
16
|
-
constructor(processManager) {
|
|
17
|
-
this.processManager = processManager;
|
|
18
|
-
this.logger = logger_1.Logger.getInstance();
|
|
19
|
-
}
|
|
20
|
-
setName(name) {
|
|
21
|
-
this.name = name;
|
|
22
|
-
this.logger.setMetadata({ name, transport: 'StdioClientTransport' });
|
|
23
|
-
}
|
|
24
|
-
async send(message) {
|
|
25
|
-
this.logger.log('Sending message', message);
|
|
26
|
-
this.processManager.write(`${message}\n`);
|
|
27
|
-
}
|
|
28
|
-
onMessage(handler) {
|
|
29
|
-
this.messageHandler = handler;
|
|
30
|
-
// Note: Message handling is done in the main ParentStdioTransport class
|
|
31
|
-
// This is here for interface compliance
|
|
32
|
-
}
|
|
33
|
-
async close() {
|
|
34
|
-
this.messageHandler = undefined;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.StdioClientTransport = StdioClientTransport;
|
|
38
|
-
/**
|
|
39
|
-
* StdioTransport implementation for parent process communication with child
|
|
40
|
-
* This is the parent-side transport that manages a child process
|
|
41
|
-
*/
|
|
42
|
-
class ParentStdioTransport extends BaseTransport_1.BaseTransport {
|
|
43
|
-
constructor(executorScriptPath, server) {
|
|
44
|
-
super();
|
|
45
|
-
this.processManager = new ProcessManager_1.ProcessManager();
|
|
46
|
-
this.messageBuffer = new MessageUtils_1.MessageBuffer();
|
|
47
|
-
this.executorScriptPath = executorScriptPath;
|
|
48
|
-
this.server = server;
|
|
49
|
-
this.client = new JsonRpcClient_1.JsonRpcClient({
|
|
50
|
-
// 1 hour
|
|
51
|
-
defaultTimeout: 60 * 60 * 1000
|
|
52
|
-
});
|
|
53
|
-
this.clientTransport = new StdioClientTransport(this.processManager);
|
|
54
|
-
this.setupServerMethods();
|
|
55
|
-
this.setupEventHandlers();
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Initialize the transport connection
|
|
59
|
-
*/
|
|
60
|
-
async initialize(config, executionOptions) {
|
|
61
|
-
if (this.internalStatus !== Transport_1.TransportStatus.disconnected) {
|
|
62
|
-
throw new Error(`Cannot initialize transport in ${this.internalStatus} state`);
|
|
63
|
-
}
|
|
64
|
-
try {
|
|
65
|
-
this.setStatus(Transport_1.TransportStatus.connecting);
|
|
66
|
-
// Set up client transport
|
|
67
|
-
this.client.setTransport(this.clientTransport);
|
|
68
|
-
// Spawn the process
|
|
69
|
-
// Use spawnTimeout if provided, otherwise fall back to timeout or default
|
|
70
|
-
const spawnTimeout = config?.spawnTimeout ?? config?.timeout ?? 3000;
|
|
71
|
-
await this.processManager.spawn({
|
|
72
|
-
scriptPath: this.executorScriptPath,
|
|
73
|
-
executionOptions,
|
|
74
|
-
startupTimeout: spawnTimeout
|
|
75
|
-
});
|
|
76
|
-
// Set up process communication
|
|
77
|
-
this.setupProcessCommunication();
|
|
78
|
-
// Wait for process to be ready
|
|
79
|
-
// Use readyTimeout if provided, otherwise fall back to timeout or default
|
|
80
|
-
const readyTimeout = config?.readyTimeout ?? config?.timeout ?? 10000;
|
|
81
|
-
await this.waitForReady(readyTimeout);
|
|
82
|
-
this.setStatus(Transport_1.TransportStatus.connected);
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
this.setStatus(Transport_1.TransportStatus.error);
|
|
86
|
-
throw error;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Send a message through the transport
|
|
91
|
-
*/
|
|
92
|
-
async send(message) {
|
|
93
|
-
if (!this.isReady()) {
|
|
94
|
-
throw new Error('Transport is not ready');
|
|
95
|
-
}
|
|
96
|
-
// Expect message to have method and params for direct RPC calls
|
|
97
|
-
const rpcMessage = message;
|
|
98
|
-
if (rpcMessage.method) {
|
|
99
|
-
return this.client.request(rpcMessage.method, rpcMessage.params);
|
|
100
|
-
}
|
|
101
|
-
throw new Error('Message must have a method property for RPC calls');
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Make a direct RPC request to the child process
|
|
105
|
-
*/
|
|
106
|
-
async request(method, params, options) {
|
|
107
|
-
if (!this.isReady()) {
|
|
108
|
-
throw new Error('Transport is not ready');
|
|
109
|
-
}
|
|
110
|
-
return this.client.request(method, params, options);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Send a notification to the child process (no response expected)
|
|
114
|
-
*/
|
|
115
|
-
async notify(method, params) {
|
|
116
|
-
if (!this.isReady()) {
|
|
117
|
-
throw new Error('Transport is not ready');
|
|
118
|
-
}
|
|
119
|
-
return this.client.notify(method, params);
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Close the transport connection
|
|
123
|
-
*/
|
|
124
|
-
async close() {
|
|
125
|
-
if (this.internalStatus === Transport_1.TransportStatus.disconnected) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
this.setStatus(Transport_1.TransportStatus.disconnected);
|
|
129
|
-
// Close JSON-RPC client
|
|
130
|
-
await this.client.close();
|
|
131
|
-
// Terminate child process
|
|
132
|
-
await this.processManager.terminate();
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Check if the transport is ready for communication
|
|
136
|
-
*/
|
|
137
|
-
isReady() {
|
|
138
|
-
return this.internalStatus === Transport_1.TransportStatus.connected && this.processManager.isRunning();
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Set up server methods for handling incoming requests from Deno process
|
|
142
|
-
*/
|
|
143
|
-
setupServerMethods() {
|
|
144
|
-
// Handle status requests
|
|
145
|
-
this.server.registerMethod(types_1.STANDARD_METHODS.getStatus, async () => ({
|
|
146
|
-
status: 'ready',
|
|
147
|
-
uptime: process.uptime() * 1000,
|
|
148
|
-
memoryUsage: {
|
|
149
|
-
used: process.memoryUsage().heapUsed,
|
|
150
|
-
total: process.memoryUsage().heapTotal
|
|
151
|
-
}
|
|
152
|
-
}));
|
|
153
|
-
// Handle ping requests
|
|
154
|
-
this.server.registerMethod(types_1.STANDARD_METHODS.ping, async () => 'pong');
|
|
155
|
-
// Handle log notifications
|
|
156
|
-
this.server.registerMethod(types_1.STANDARD_METHODS.log, async (params) => {
|
|
157
|
-
if (this.messageHandler) {
|
|
158
|
-
await this.messageHandler(params);
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Set up event handlers
|
|
164
|
-
*/
|
|
165
|
-
setupEventHandlers() {
|
|
166
|
-
this.server.on('error', error => {
|
|
167
|
-
this.emit('error', error);
|
|
168
|
-
});
|
|
169
|
-
this.client.on('error', error => {
|
|
170
|
-
this.emit('error', error);
|
|
171
|
-
});
|
|
172
|
-
this.processManager.on('error', error => {
|
|
173
|
-
this.emit('error', error);
|
|
174
|
-
});
|
|
175
|
-
this.processManager.on('exit', (code, signal) => {
|
|
176
|
-
if (this.internalStatus === Transport_1.TransportStatus.connected) {
|
|
177
|
-
const error = new Error(`Process exited unexpectedly (code: ${code}, signal: ${signal})`);
|
|
178
|
-
this.setStatus(Transport_1.TransportStatus.error);
|
|
179
|
-
this.emit('error', error);
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Set up process communication handlers
|
|
185
|
-
*/
|
|
186
|
-
setupProcessCommunication() {
|
|
187
|
-
// Handle stdout data (responses from Deno process)
|
|
188
|
-
this.processManager.on('stdout', (data) => {
|
|
189
|
-
const messages = this.messageBuffer.addData(data.toString());
|
|
190
|
-
for (const messageData of messages) {
|
|
191
|
-
this.logger.log('Received message', messageData);
|
|
192
|
-
this.handleIncomingMessage(messageData).catch(error => {
|
|
193
|
-
this.emit('error', error);
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
// Handle stderr data (log messages and errors from Deno process)
|
|
198
|
-
this.processManager.on('stderr', (data) => {
|
|
199
|
-
const stderrOutput = data.toString().trim();
|
|
200
|
-
// Only treat messages starting with "ERROR:" as actual errors
|
|
201
|
-
if (stderrOutput.startsWith('ERROR:')) {
|
|
202
|
-
this.emit('error', new Error(`Deno process error: ${stderrOutput}`));
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
// Log normal stderr output as debug information
|
|
206
|
-
this.logger.log('Child process log', stderrOutput);
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Handle incoming message from Deno process with bidirectional routing
|
|
212
|
-
*/
|
|
213
|
-
async handleIncomingMessage(messageData) {
|
|
214
|
-
try {
|
|
215
|
-
const message = JSON.parse(messageData);
|
|
216
|
-
// Check if this is a response to our request (has 'result' or 'error' and 'id')
|
|
217
|
-
if ((0, MessageUtils_1.isResponse)(message)) {
|
|
218
|
-
// This is a response to a request we made - route to client
|
|
219
|
-
this.logger.log('Routing response to parent client', { id: message.id });
|
|
220
|
-
await this.client.handleIncomingMessage(messageData);
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
// This is a request or notification for us - route to server
|
|
224
|
-
this.logger.log('Routing request to parent server', { method: message.method, id: message.id });
|
|
225
|
-
const response = await this.server.processMessage(messageData);
|
|
226
|
-
this.logger.log('Sending response to parent process', response);
|
|
227
|
-
// Only send response if there is one (requests get responses, notifications don't)
|
|
228
|
-
if (response) {
|
|
229
|
-
const responseData = `${JSON.stringify(response)}\n`;
|
|
230
|
-
this.processManager.write(responseData);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
catch (error) {
|
|
235
|
-
// Silently ignore invalid JSON messages (likely log output from child process)
|
|
236
|
-
if (error instanceof SyntaxError && error.message.includes('JSON')) {
|
|
237
|
-
this.logger.log('Ignoring invalid JSON message', { message: messageData });
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
// Re-throw other types of errors
|
|
241
|
-
this.emit('error', new Error(`Failed to handle incoming message: ${error.message}`));
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Wait for the process to be ready
|
|
246
|
-
*/
|
|
247
|
-
async waitForReady(timeout) {
|
|
248
|
-
// Use a reasonable ping timeout (1/4 of total timeout, min 500ms, max 2000ms)
|
|
249
|
-
const pingTimeout = Math.max(500, Math.min(2000, timeout / 4));
|
|
250
|
-
await (0, PollingUtils_1.pollUntilSuccess)(() => this.client.request(types_1.STANDARD_METHODS.ping, undefined, { timeout: pingTimeout }), {
|
|
251
|
-
timeout,
|
|
252
|
-
interval: 100,
|
|
253
|
-
// Let process start before first ping
|
|
254
|
-
initialDelay: 100
|
|
255
|
-
}, 'Transport initialization timed out');
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
exports.ParentStdioTransport = ParentStdioTransport;
|
|
259
|
-
//# sourceMappingURL=ParentStdioTransport.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ParentStdioTransport.js","sourceRoot":"","sources":["../../../../src/JsExecutor/transport/stdio/ParentStdioTransport.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AAEzC,+DAA4D;AAG5D,+CAAuD;AAEvD,yDAAsD;AACtD,8DAA2D;AAE3D,4CAA+C;AAC/C,wDAAkE;AAClE,wDAAyD;AAEzD;;GAEG;AACH,MAAa,oBAAoB;IAK/B,YAAoC,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;QAFjD,WAAM,GAAG,eAAM,CAAC,WAAW,EAAE,CAAC;IAEsB,CAAC;IAE/D,OAAO,CAAC,IAAY;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,sBAAsB,EAAE,CAAC,CAAC;IACvE,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,OAAe;QAC/B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,O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AC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;QAE/D,MAAM,IAAA,+BAAgB,EACpB,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,wBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,EACrF;YACE,OAAO;YACP,QAAQ,EAAE,GAAG;YACb,sCAAsC;YACtC,YAAY,EAAE,GAAG;SAClB,EACD,oCAAoC,CACrC,CAAC;IACJ,CAAC;CACF;AAlQD,oDAkQC","sourcesContent":["import { Logger } from '../../../logger';\nimport type { ClientTransport } from '../../jsonRpc/JsonRpcClient';\nimport { JsonRpcClient } from '../../jsonRpc/JsonRpcClient';\nimport type { JsonRpcServer } from '../../jsonRpc/JsonRpcServer';\nimport type { LogNotification, StatusRequest, StatusResponse } from '../../jsonRpc/types';\nimport { STANDARD_METHODS } from '../../jsonRpc/types';\nimport type { ExecutionOptions } from '../../types';\nimport { BaseTransport } from '../base/BaseTransport';\nimport { ProcessManager } from '../process/ProcessManager';\nimport type { TransportConfig } from '../Transport';\nimport { TransportStatus } from '../Transport';\nimport { isResponse, MessageBuffer } from '../utils/MessageUtils';\nimport { pollUntilSuccess } from '../utils/PollingUtils';\n\n/**\n * Client transport implementation for stdio communication\n */\nexport class StdioClientTransport implements ClientTransport {\n private messageHandler?: (message: string) => void;\n private name?: string;\n private readonly logger = Logger.getInstance();\n\n public constructor(private readonly processManager: ProcessManager) {}\n\n public setName(name: string): void {\n this.name = name;\n this.logger.setMetadata({ name, transport: 'StdioClientTransport' });\n }\n\n public async send(message: string): Promise<void> {\n this.logger.log('Sending message', message);\n this.processManager.write(`${message}\\n`);\n }\n\n public onMessage(handler: (message: string) => void): void {\n this.messageHandler = handler;\n // Note: Message handling is done in the main ParentStdioTransport class\n // This is here for interface compliance\n }\n\n public async close(): Promise<void> {\n this.messageHandler = undefined;\n }\n}\n\n/**\n * StdioTransport implementation for parent process communication with child\n * This is the parent-side transport that manages a child process\n */\nexport class ParentStdioTransport extends BaseTransport {\n private readonly processManager = new ProcessManager();\n private readonly server: JsonRpcServer;\n private readonly client: JsonRpcClient;\n private readonly clientTransport: StdioClientTransport;\n private readonly executorScriptPath: string;\n private readonly messageBuffer = new MessageBuffer();\n\n public constructor(executorScriptPath: string, server: JsonRpcServer) {\n super();\n this.executorScriptPath = executorScriptPath;\n this.server = server;\n this.client = new JsonRpcClient({\n // 1 hour\n defaultTimeout: 60 * 60 * 1000\n });\n this.clientTransport = new StdioClientTransport(this.processManager);\n\n this.setupServerMethods();\n this.setupEventHandlers();\n }\n\n /**\n * Initialize the transport connection\n */\n public async initialize(config?: TransportConfig, executionOptions?: ExecutionOptions): Promise<void> {\n if (this.internalStatus !== TransportStatus.disconnected) {\n throw new Error(`Cannot initialize transport in ${this.internalStatus} state`);\n }\n\n try {\n this.setStatus(TransportStatus.connecting);\n\n // Set up client transport\n this.client.setTransport(this.clientTransport);\n\n // Spawn the process\n // Use spawnTimeout if provided, otherwise fall back to timeout or default\n const spawnTimeout = config?.spawnTimeout ?? config?.timeout ?? 3000;\n await this.processManager.spawn({\n scriptPath: this.executorScriptPath,\n executionOptions,\n startupTimeout: spawnTimeout\n });\n\n // Set up process communication\n this.setupProcessCommunication();\n\n // Wait for process to be ready\n // Use readyTimeout if provided, otherwise fall back to timeout or default\n const readyTimeout = config?.readyTimeout ?? config?.timeout ?? 10000;\n await this.waitForReady(readyTimeout);\n\n this.setStatus(TransportStatus.connected);\n } catch (error: unknown) {\n this.setStatus(TransportStatus.error);\n throw error;\n }\n }\n\n /**\n * Send a message through the transport\n */\n public async send<TRequest, TResponse>(message: TRequest): Promise<TResponse> {\n if (!this.isReady()) {\n throw new Error('Transport is not ready');\n }\n\n // Expect message to have method and params for direct RPC calls\n const rpcMessage = message as any;\n if (rpcMessage.method) {\n return this.client.request(rpcMessage.method, rpcMessage.params);\n }\n throw new Error('Message must have a method property for RPC calls');\n }\n\n /**\n * Make a direct RPC request to the child process\n */\n public async request<TParams = any, TResult = any>(\n method: string,\n params?: TParams,\n options?: { timeout?: number; retries?: number }\n ): Promise<TResult> {\n if (!this.isReady()) {\n throw new Error('Transport is not ready');\n }\n return this.client.request<TParams, TResult>(method, params, options);\n }\n\n /**\n * Send a notification to the child process (no response expected)\n */\n public async notify<TParams = any>(method: string, params?: TParams): Promise<void> {\n if (!this.isReady()) {\n throw new Error('Transport is not ready');\n }\n return this.client.notify(method, params);\n }\n\n /**\n * Close the transport connection\n */\n public async close(): Promise<void> {\n if (this.internalStatus === TransportStatus.disconnected) {\n return;\n }\n\n this.setStatus(TransportStatus.disconnected);\n\n // Close JSON-RPC client\n await this.client.close();\n\n // Terminate child process\n await this.processManager.terminate();\n }\n\n /**\n * Check if the transport is ready for communication\n */\n public isReady(): boolean {\n return this.internalStatus === TransportStatus.connected && this.processManager.isRunning();\n }\n\n /**\n * Set up server methods for handling incoming requests from Deno process\n */\n private setupServerMethods(): void {\n // Handle status requests\n this.server.registerMethod<StatusRequest, StatusResponse>(STANDARD_METHODS.getStatus, async() => ({\n status: 'ready',\n uptime: process.uptime() * 1000,\n memoryUsage: {\n used: process.memoryUsage().heapUsed,\n total: process.memoryUsage().heapTotal\n }\n }));\n\n // Handle ping requests\n this.server.registerMethod(STANDARD_METHODS.ping, async() => 'pong');\n\n // Handle log notifications\n this.server.registerMethod<LogNotification, void>(STANDARD_METHODS.log, async params => {\n if (this.messageHandler) {\n await this.messageHandler(params);\n }\n });\n }\n\n /**\n * Set up event handlers\n */\n private setupEventHandlers(): void {\n this.server.on('error', error => {\n this.emit('error', error);\n });\n\n this.client.on('error', error => {\n this.emit('error', error);\n });\n\n this.processManager.on('error', error => {\n this.emit('error', error);\n });\n\n this.processManager.on('exit', (code, signal) => {\n if (this.internalStatus === TransportStatus.connected) {\n const error = new Error(`Process exited unexpectedly (code: ${code}, signal: ${signal})`);\n this.setStatus(TransportStatus.error);\n this.emit('error', error);\n }\n });\n }\n\n /**\n * Set up process communication handlers\n */\n private setupProcessCommunication(): void {\n // Handle stdout data (responses from Deno process)\n this.processManager.on('stdout', (data: Buffer) => {\n const messages = this.messageBuffer.addData(data.toString());\n\n for (const messageData of messages) {\n this.logger.log('Received message', messageData);\n this.handleIncomingMessage(messageData).catch(error => {\n this.emit('error', error);\n });\n }\n });\n\n // Handle stderr data (log messages and errors from Deno process)\n this.processManager.on('stderr', (data: Buffer) => {\n const stderrOutput = data.toString().trim();\n\n // Only treat messages starting with \"ERROR:\" as actual errors\n if (stderrOutput.startsWith('ERROR:')) {\n this.emit('error', new Error(`Deno process error: ${stderrOutput}`));\n } else {\n // Log normal stderr output as debug information\n this.logger.log('Child process log', stderrOutput);\n }\n });\n }\n\n /**\n * Handle incoming message from Deno process with bidirectional routing\n */\n private async handleIncomingMessage(messageData: string): Promise<void> {\n try {\n const message = JSON.parse(messageData);\n\n // Check if this is a response to our request (has 'result' or 'error' and 'id')\n if (isResponse(message)) {\n // This is a response to a request we made - route to client\n this.logger.log('Routing response to parent client', { id: message.id });\n await this.client.handleIncomingMessage(messageData);\n } else {\n // This is a request or notification for us - route to server\n this.logger.log('Routing request to parent server', { method: message.method, id: message.id });\n const response = await this.server.processMessage(messageData);\n this.logger.log('Sending response to parent process', response);\n\n // Only send response if there is one (requests get responses, notifications don't)\n if (response) {\n const responseData = `${JSON.stringify(response)}\\n`;\n this.processManager.write(responseData);\n }\n }\n } catch (error: unknown) {\n // Silently ignore invalid JSON messages (likely log output from child process)\n if (error instanceof SyntaxError && error.message.includes('JSON')) {\n this.logger.log('Ignoring invalid JSON message', { message: messageData });\n return;\n }\n\n // Re-throw other types of errors\n this.emit('error', new Error(`Failed to handle incoming message: ${(error as Error).message}`));\n }\n }\n\n /**\n * Wait for the process to be ready\n */\n private async waitForReady(timeout: number): Promise<void> {\n // Use a reasonable ping timeout (1/4 of total timeout, min 500ms, max 2000ms)\n const pingTimeout = Math.max(500, Math.min(2000, timeout / 4));\n\n await pollUntilSuccess(\n () => this.client.request(STANDARD_METHODS.ping, undefined, { timeout: pingTimeout }),\n {\n timeout,\n interval: 100,\n // Let process start before first ping\n initialDelay: 100\n },\n 'Transport initialization timed out'\n );\n }\n}\n"]}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { JsonRpcResponse } from '../../jsonRpc/types';
|
|
2
|
-
/**
|
|
3
|
-
* Safely parse a JSON message, returning undefined if parsing fails
|
|
4
|
-
* @param message - String message to parse
|
|
5
|
-
* @returns Parsed object or undefined if invalid JSON
|
|
6
|
-
*/
|
|
7
|
-
export declare function safeParse(message: string): any;
|
|
8
|
-
/**
|
|
9
|
-
* Check if a message is a JSON-RPC response (vs request/notification)
|
|
10
|
-
* @param message - Parsed message object
|
|
11
|
-
* @returns True if message is a response
|
|
12
|
-
*/
|
|
13
|
-
export declare function isResponse(message: any): boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Check if a message is a JSON-RPC request
|
|
16
|
-
* @param message - Parsed message object
|
|
17
|
-
* @returns True if message is a request
|
|
18
|
-
*/
|
|
19
|
-
export declare function isRequest(message: any): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Check if a message is a JSON-RPC notification
|
|
22
|
-
* @param message - Parsed message object
|
|
23
|
-
* @returns True if message is a notification
|
|
24
|
-
*/
|
|
25
|
-
export declare function isNotification(message: any): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Create a JSON-RPC error response
|
|
28
|
-
* @param id - Request ID
|
|
29
|
-
* @param code - Error code
|
|
30
|
-
* @param message - Error message
|
|
31
|
-
* @param data - Optional error data
|
|
32
|
-
* @returns JSON-RPC error response object
|
|
33
|
-
*/
|
|
34
|
-
export declare function createErrorResponse(id: string | number | null, code: number, message: string, data?: any): JsonRpcResponse;
|
|
35
|
-
/**
|
|
36
|
-
* Create a JSON-RPC success response
|
|
37
|
-
* @param id - Request ID
|
|
38
|
-
* @param result - Response result
|
|
39
|
-
* @returns JSON-RPC success response object
|
|
40
|
-
*/
|
|
41
|
-
export declare function createSuccessResponse(id: string | number, result: any): JsonRpcResponse;
|
|
42
|
-
/**
|
|
43
|
-
* Validate that a message is a valid JSON-RPC message
|
|
44
|
-
* @param message - Message to validate
|
|
45
|
-
* @returns True if valid JSON-RPC message
|
|
46
|
-
*/
|
|
47
|
-
export declare function isValidJsonRpc(message: any): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Buffer manager for handling streaming message data
|
|
50
|
-
*/
|
|
51
|
-
export declare class MessageBuffer {
|
|
52
|
-
private buffer;
|
|
53
|
-
/**
|
|
54
|
-
* Add data to the buffer and extract complete messages
|
|
55
|
-
* @param data - Incoming data chunk
|
|
56
|
-
* @returns Array of complete message strings
|
|
57
|
-
*/
|
|
58
|
-
addData(data: string): string[];
|
|
59
|
-
/**
|
|
60
|
-
* Clear the buffer
|
|
61
|
-
*/
|
|
62
|
-
clear(): void;
|
|
63
|
-
/**
|
|
64
|
-
* Get current buffer content (for debugging)
|
|
65
|
-
*/
|
|
66
|
-
getContent(): string;
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=MessageUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MessageUtils.d.ts","sourceRoot":"","sources":["../../../../src/JsExecutor/transport/utils/MessageUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAM9C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAMhD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAK/C;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAKpD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,GAAG,GACT,eAAe,CAUjB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,eAAe,CAMvF;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAKpD;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAM;IAEpB;;;;OAIG;IACI,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;IAWtC;;OAEG;IACI,KAAK,IAAI,IAAI;IAIpB;;OAEG;IACI,UAAU,IAAI,MAAM;CAG5B"}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageBuffer = exports.isValidJsonRpc = exports.createSuccessResponse = exports.createErrorResponse = exports.isNotification = exports.isRequest = exports.isResponse = exports.safeParse = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Safely parse a JSON message, returning undefined if parsing fails
|
|
6
|
-
* @param message - String message to parse
|
|
7
|
-
* @returns Parsed object or undefined if invalid JSON
|
|
8
|
-
*/
|
|
9
|
-
function safeParse(message) {
|
|
10
|
-
try {
|
|
11
|
-
return JSON.parse(message);
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
return undefined;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.safeParse = safeParse;
|
|
18
|
-
/**
|
|
19
|
-
* Check if a message is a JSON-RPC response (vs request/notification)
|
|
20
|
-
* @param message - Parsed message object
|
|
21
|
-
* @returns True if message is a response
|
|
22
|
-
*/
|
|
23
|
-
function isResponse(message) {
|
|
24
|
-
return message &&
|
|
25
|
-
typeof message === 'object' &&
|
|
26
|
-
('result' in message || 'error' in message) &&
|
|
27
|
-
'id' in message &&
|
|
28
|
-
!('method' in message);
|
|
29
|
-
}
|
|
30
|
-
exports.isResponse = isResponse;
|
|
31
|
-
/**
|
|
32
|
-
* Check if a message is a JSON-RPC request
|
|
33
|
-
* @param message - Parsed message object
|
|
34
|
-
* @returns True if message is a request
|
|
35
|
-
*/
|
|
36
|
-
function isRequest(message) {
|
|
37
|
-
return message &&
|
|
38
|
-
typeof message === 'object' &&
|
|
39
|
-
'method' in message &&
|
|
40
|
-
'id' in message;
|
|
41
|
-
}
|
|
42
|
-
exports.isRequest = isRequest;
|
|
43
|
-
/**
|
|
44
|
-
* Check if a message is a JSON-RPC notification
|
|
45
|
-
* @param message - Parsed message object
|
|
46
|
-
* @returns True if message is a notification
|
|
47
|
-
*/
|
|
48
|
-
function isNotification(message) {
|
|
49
|
-
return message &&
|
|
50
|
-
typeof message === 'object' &&
|
|
51
|
-
'method' in message &&
|
|
52
|
-
!('id' in message);
|
|
53
|
-
}
|
|
54
|
-
exports.isNotification = isNotification;
|
|
55
|
-
/**
|
|
56
|
-
* Create a JSON-RPC error response
|
|
57
|
-
* @param id - Request ID
|
|
58
|
-
* @param code - Error code
|
|
59
|
-
* @param message - Error message
|
|
60
|
-
* @param data - Optional error data
|
|
61
|
-
* @returns JSON-RPC error response object
|
|
62
|
-
*/
|
|
63
|
-
function createErrorResponse(id, code, message, data) {
|
|
64
|
-
return {
|
|
65
|
-
jsonrpc: '2.0',
|
|
66
|
-
id,
|
|
67
|
-
error: {
|
|
68
|
-
code,
|
|
69
|
-
message,
|
|
70
|
-
...data && { data }
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
exports.createErrorResponse = createErrorResponse;
|
|
75
|
-
/**
|
|
76
|
-
* Create a JSON-RPC success response
|
|
77
|
-
* @param id - Request ID
|
|
78
|
-
* @param result - Response result
|
|
79
|
-
* @returns JSON-RPC success response object
|
|
80
|
-
*/
|
|
81
|
-
function createSuccessResponse(id, result) {
|
|
82
|
-
return {
|
|
83
|
-
jsonrpc: '2.0',
|
|
84
|
-
id,
|
|
85
|
-
result
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
exports.createSuccessResponse = createSuccessResponse;
|
|
89
|
-
/**
|
|
90
|
-
* Validate that a message is a valid JSON-RPC message
|
|
91
|
-
* @param message - Message to validate
|
|
92
|
-
* @returns True if valid JSON-RPC message
|
|
93
|
-
*/
|
|
94
|
-
function isValidJsonRpc(message) {
|
|
95
|
-
return message &&
|
|
96
|
-
typeof message === 'object' &&
|
|
97
|
-
message.jsonrpc === '2.0' &&
|
|
98
|
-
(isRequest(message) || isNotification(message) || isResponse(message));
|
|
99
|
-
}
|
|
100
|
-
exports.isValidJsonRpc = isValidJsonRpc;
|
|
101
|
-
/**
|
|
102
|
-
* Buffer manager for handling streaming message data
|
|
103
|
-
*/
|
|
104
|
-
class MessageBuffer {
|
|
105
|
-
constructor() {
|
|
106
|
-
this.buffer = '';
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Add data to the buffer and extract complete messages
|
|
110
|
-
* @param data - Incoming data chunk
|
|
111
|
-
* @returns Array of complete message strings
|
|
112
|
-
*/
|
|
113
|
-
addData(data) {
|
|
114
|
-
this.buffer += data;
|
|
115
|
-
// Process complete JSON messages (newline-delimited)
|
|
116
|
-
const lines = this.buffer.split('\n');
|
|
117
|
-
// Keep incomplete line in buffer
|
|
118
|
-
this.buffer = lines.pop() ?? '';
|
|
119
|
-
return lines.filter((line) => line.trim());
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Clear the buffer
|
|
123
|
-
*/
|
|
124
|
-
clear() {
|
|
125
|
-
this.buffer = '';
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Get current buffer content (for debugging)
|
|
129
|
-
*/
|
|
130
|
-
getContent() {
|
|
131
|
-
return this.buffer;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
exports.MessageBuffer = MessageBuffer;
|
|
135
|
-
//# sourceMappingURL=MessageUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MessageUtils.js","sourceRoot":"","sources":["../../../../src/JsExecutor/transport/utils/MessageUtils.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACH,SAAgB,SAAS,CAAC,OAAe;IACvC,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC5B;IAAC,MAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAND,8BAMC;AAED;;;;GAIG;AACH,SAAgB,UAAU,CAAC,OAAY;IACrC,OAAO,OAAO;QACP,OAAO,OAAO,KAAK,QAAQ;QAC3B,CAAC,QAAQ,IAAI,OAAO,IAAI,OAAO,IAAI,OAAO,CAAC;QAC3C,IAAI,IAAI,OAAO;QACf,CAAC,CAAC,QAAQ,IAAI,OAAO,CAAC,CAAC;AAChC,CAAC;AAND,gCAMC;AAED;;;;GAIG;AACH,SAAgB,SAAS,CAAC,OAAY;IACpC,OAAO,OAAO;QACP,OAAO,OAAO,KAAK,QAAQ;QAC3B,QAAQ,IAAI,OAAO;QACnB,IAAI,IAAI,OAAO,CAAC;AACzB,CAAC;AALD,8BAKC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAAC,OAAY;IACzC,OAAO,OAAO;QACP,OAAO,OAAO,KAAK,QAAQ;QAC3B,QAAQ,IAAI,OAAO;QACnB,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC,CAAC;AAC5B,CAAC;AALD,wCAKC;AAED;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CACjC,EAA0B,EAC1B,IAAY,EACZ,OAAe,EACf,IAAU;IAEV,OAAO;QACL,OAAO,EAAE,KAAK;QACd,EAAE;QACF,KAAK,EAAE;YACL,IAAI;YACJ,OAAO;YACP,GAAG,IAAI,IAAI,EAAE,IAAI,EAAE;SACpB;KACF,CAAC;AACJ,CAAC;AAfD,kDAeC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,EAAmB,EAAE,MAAW;IACpE,OAAO;QACL,OAAO,EAAE,KAAK;QACd,EAAE;QACF,MAAM;KACP,CAAC;AACJ,CAAC;AAND,sDAMC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAAC,OAAY;IACzC,OAAO,OAAO;QACP,OAAO,OAAO,KAAK,QAAQ;QAC3B,OAAO,CAAC,OAAO,KAAK,KAAK;QACzB,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,cAAc,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;AAChF,CAAC;AALD,wCAKC;AAED;;GAEG;AACH,MAAa,aAAa;IAA1B;QACU,WAAM,GAAG,EAAE,CAAC;IA+BtB,CAAC;IA7BC;;;;OAIG;IACI,OAAO,CAAC,IAAY;QACzB,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC;QAEpB,qDAAqD;QACrD,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACtC,iCAAiC;QACjC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;QAEhC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAU,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACrD,CAAC;IAED;;OAEG;IACI,KAAK;QACV,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IAED;;OAEG;IACI,UAAU;QACf,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAhCD,sCAgCC","sourcesContent":["import type { JsonRpcResponse } from '../../jsonRpc/types';\n\n/**\n * Safely parse a JSON message, returning undefined if parsing fails\n * @param message - String message to parse\n * @returns Parsed object or undefined if invalid JSON\n */\nexport function safeParse(message: string): any {\n try {\n return JSON.parse(message);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Check if a message is a JSON-RPC response (vs request/notification)\n * @param message - Parsed message object\n * @returns True if message is a response\n */\nexport function isResponse(message: any): boolean {\n return message &&\n typeof message === 'object' &&\n ('result' in message || 'error' in message) &&\n 'id' in message &&\n !('method' in message);\n}\n\n/**\n * Check if a message is a JSON-RPC request\n * @param message - Parsed message object\n * @returns True if message is a request\n */\nexport function isRequest(message: any): boolean {\n return message &&\n typeof message === 'object' &&\n 'method' in message &&\n 'id' in message;\n}\n\n/**\n * Check if a message is a JSON-RPC notification\n * @param message - Parsed message object\n * @returns True if message is a notification\n */\nexport function isNotification(message: any): boolean {\n return message &&\n typeof message === 'object' &&\n 'method' in message &&\n !('id' in message);\n}\n\n/**\n * Create a JSON-RPC error response\n * @param id - Request ID\n * @param code - Error code\n * @param message - Error message\n * @param data - Optional error data\n * @returns JSON-RPC error response object\n */\nexport function createErrorResponse(\n id: string | number | null,\n code: number,\n message: string,\n data?: any\n): JsonRpcResponse {\n return {\n jsonrpc: '2.0',\n id,\n error: {\n code,\n message,\n ...data && { data }\n }\n };\n}\n\n/**\n * Create a JSON-RPC success response\n * @param id - Request ID\n * @param result - Response result\n * @returns JSON-RPC success response object\n */\nexport function createSuccessResponse(id: string | number, result: any): JsonRpcResponse {\n return {\n jsonrpc: '2.0',\n id,\n result\n };\n}\n\n/**\n * Validate that a message is a valid JSON-RPC message\n * @param message - Message to validate\n * @returns True if valid JSON-RPC message\n */\nexport function isValidJsonRpc(message: any): boolean {\n return message &&\n typeof message === 'object' &&\n message.jsonrpc === '2.0' &&\n (isRequest(message) || isNotification(message) || isResponse(message));\n}\n\n/**\n * Buffer manager for handling streaming message data\n */\nexport class MessageBuffer {\n private buffer = '';\n\n /**\n * Add data to the buffer and extract complete messages\n * @param data - Incoming data chunk\n * @returns Array of complete message strings\n */\n public addData(data: string): string[] {\n this.buffer += data;\n\n // Process complete JSON messages (newline-delimited)\n const lines = this.buffer.split('\\n');\n // Keep incomplete line in buffer\n this.buffer = lines.pop() ?? '';\n\n return lines.filter((line): string => line.trim());\n }\n\n /**\n * Clear the buffer\n */\n public clear(): void {\n this.buffer = '';\n }\n\n /**\n * Get current buffer content (for debugging)\n */\n public getContent(): string {\n return this.buffer;\n }\n}\n"]}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility for polling operations with timeout
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Options for polling with timeout
|
|
6
|
-
*/
|
|
7
|
-
export interface PollingOptions {
|
|
8
|
-
/** Total timeout in milliseconds */
|
|
9
|
-
timeout: number;
|
|
10
|
-
/** Polling interval in milliseconds (default: 100ms) */
|
|
11
|
-
interval?: number;
|
|
12
|
-
/** Initial delay before starting polling in milliseconds (default: 0ms) */
|
|
13
|
-
initialDelay?: number;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Poll a condition function until it returns true or timeout is reached
|
|
17
|
-
*
|
|
18
|
-
* @param conditionFn - Function that returns true when condition is met, false to continue polling
|
|
19
|
-
* @param options - Polling configuration
|
|
20
|
-
* @param timeoutErrorMessage - Custom error message for timeout
|
|
21
|
-
* @returns Promise that resolves when condition is met or rejects on timeout
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```typescript
|
|
25
|
-
* // Wait for process to be ready
|
|
26
|
-
* await pollUntilTrue(
|
|
27
|
-
* () => process.isRunning(),
|
|
28
|
-
* { timeout: 5000, interval: 100 },
|
|
29
|
-
* 'Process failed to start'
|
|
30
|
-
* );
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
export declare function pollUntilTrue(conditionFn: () => boolean | Promise<boolean>, options: PollingOptions, timeoutErrorMessage: string): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Poll an async operation until it succeeds or timeout is reached
|
|
36
|
-
*
|
|
37
|
-
* @param operationFn - Async function to retry until it succeeds
|
|
38
|
-
* @param options - Polling configuration
|
|
39
|
-
* @param timeoutErrorMessage - Custom error message for timeout
|
|
40
|
-
* @returns Promise that resolves with operation result or rejects on timeout
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```typescript
|
|
44
|
-
* // Wait for ping to succeed
|
|
45
|
-
* await pollUntilSuccess(
|
|
46
|
-
* () => client.ping(),
|
|
47
|
-
* { timeout: 10000, interval: 500 },
|
|
48
|
-
* 'Failed to connect'
|
|
49
|
-
* );
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export declare function pollUntilSuccess<T>(operationFn: () => Promise<T>, options: PollingOptions, timeoutErrorMessage: string): Promise<T>;
|
|
53
|
-
//# sourceMappingURL=PollingUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PollingUtils.d.ts","sourceRoot":"","sources":["../../../../src/JsExecutor/transport/utils/PollingUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2EAA2E;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,EAC7C,OAAO,EAAE,cAAc,EACvB,mBAAmB,EAAE,MAAM,GAC1B,OAAO,CAAC,IAAI,CAAC,CAyBf;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,WAAW,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC7B,OAAO,EAAE,cAAc,EACvB,mBAAmB,EAAE,MAAM,GAC1B,OAAO,CAAC,CAAC,CAAC,CAwBZ"}
|